babylon.d.ts 1.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078
  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. /** All of the cameras added to this scene
  62. * @see http://doc.babylonjs.com/babylon101/cameras
  63. */
  64. cameras: Camera[];
  65. /**
  66. * All of the lights added to this scene
  67. * @see http://doc.babylonjs.com/babylon101/lights
  68. */
  69. lights: Light[];
  70. /**
  71. * All of the (abstract) meshes added to this scene
  72. */
  73. meshes: AbstractMesh[];
  74. /**
  75. * The list of skeletons added to the scene
  76. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77. */
  78. skeletons: Skeleton[];
  79. /**
  80. * All of the particle systems added to this scene
  81. * @see http://doc.babylonjs.com/babylon101/particles
  82. */
  83. particleSystems: IParticleSystem[];
  84. /**
  85. * Gets a list of Animations associated with the scene
  86. */
  87. animations: Animation[];
  88. /**
  89. * All of the animation groups added to this scene
  90. * @see http://doc.babylonjs.com/how_to/group
  91. */
  92. animationGroups: AnimationGroup[];
  93. /**
  94. * All of the multi-materials added to this scene
  95. * @see http://doc.babylonjs.com/how_to/multi_materials
  96. */
  97. multiMaterials: MultiMaterial[];
  98. /**
  99. * All of the materials added to this scene
  100. * @see http://doc.babylonjs.com/babylon101/materials
  101. */
  102. materials: Material[];
  103. /**
  104. * The list of morph target managers added to the scene
  105. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  106. */
  107. morphTargetManagers: MorphTargetManager[];
  108. /**
  109. * The list of geometries used in the scene.
  110. */
  111. geometries: Geometry[];
  112. /**
  113. * All of the tranform nodes added to this scene
  114. * @see http://doc.babylonjs.com/how_to/transformnode
  115. */
  116. transformNodes: TransformNode[];
  117. /**
  118. * ActionManagers available on the scene.
  119. */
  120. actionManagers: ActionManager[];
  121. /**
  122. * Sounds to keep.
  123. */
  124. sounds: Sound[];
  125. /**
  126. * Textures to keep.
  127. */
  128. textures: BaseTexture[];
  129. }
  130. }
  131. declare module BABYLON {
  132. /**
  133. * Set of assets to keep when moving a scene into an asset container.
  134. */
  135. class KeepAssets extends AbstractScene {
  136. }
  137. /**
  138. * Container with a set of assets that can be added or removed from a scene.
  139. */
  140. class AssetContainer extends AbstractScene {
  141. /**
  142. * The scene the AssetContainer belongs to.
  143. */
  144. scene: Scene;
  145. /**
  146. * Instantiates an AssetContainer.
  147. * @param scene The scene the AssetContainer belongs to.
  148. */
  149. constructor(scene: Scene);
  150. /**
  151. * Adds all the assets from the container to the scene.
  152. */
  153. addAllToScene(): void;
  154. /**
  155. * Removes all the assets in the container from the scene
  156. */
  157. removeAllFromScene(): void;
  158. private _moveAssets;
  159. /**
  160. * Removes all the assets contained in the scene and adds them to the container.
  161. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  162. */
  163. moveAllFromScene(keepAssets?: KeepAssets): void;
  164. /**
  165. * 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.
  166. * @returns the root mesh
  167. */
  168. createRootMesh(): Mesh;
  169. }
  170. }
  171. interface Window {
  172. mozIndexedDB: IDBFactory;
  173. webkitIndexedDB: IDBFactory;
  174. msIndexedDB: IDBFactory;
  175. webkitURL: typeof URL;
  176. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  177. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  178. WebGLRenderingContext: WebGLRenderingContext;
  179. MSGesture: MSGesture;
  180. CANNON: any;
  181. AudioContext: AudioContext;
  182. webkitAudioContext: AudioContext;
  183. PointerEvent: any;
  184. Math: Math;
  185. Uint8Array: Uint8ArrayConstructor;
  186. Float32Array: Float32ArrayConstructor;
  187. mozURL: typeof URL;
  188. msURL: typeof URL;
  189. VRFrameData: any;
  190. DracoDecoderModule: any;
  191. }
  192. interface WebGLRenderingContext {
  193. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  194. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  195. vertexAttribDivisor(index: number, divisor: number): void;
  196. createVertexArray(): any;
  197. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  198. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  199. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  200. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  201. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  202. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  203. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  204. createQuery(): WebGLQuery;
  205. deleteQuery(query: WebGLQuery): void;
  206. beginQuery(target: number, query: WebGLQuery): void;
  207. endQuery(target: number): void;
  208. getQueryParameter(query: WebGLQuery, pname: number): any;
  209. getQuery(target: number, pname: number): any;
  210. MAX_SAMPLES: number;
  211. RGBA8: number;
  212. READ_FRAMEBUFFER: number;
  213. DRAW_FRAMEBUFFER: number;
  214. UNIFORM_BUFFER: number;
  215. HALF_FLOAT_OES: number;
  216. RGBA16F: number;
  217. RGBA32F: number;
  218. R32F: number;
  219. RG32F: number;
  220. RGB32F: number;
  221. R16F: number;
  222. RG16F: number;
  223. RGB16F: number;
  224. RED: number;
  225. RG: number;
  226. R8: number;
  227. RG8: number;
  228. UNSIGNED_INT_24_8: number;
  229. DEPTH24_STENCIL8: number;
  230. drawBuffers(buffers: number[]): void;
  231. readBuffer(src: number): void;
  232. readonly COLOR_ATTACHMENT0: number;
  233. readonly COLOR_ATTACHMENT1: number;
  234. readonly COLOR_ATTACHMENT2: number;
  235. readonly COLOR_ATTACHMENT3: number;
  236. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  237. ANY_SAMPLES_PASSED: number;
  238. QUERY_RESULT_AVAILABLE: number;
  239. QUERY_RESULT: number;
  240. }
  241. interface Document {
  242. mozCancelFullScreen(): void;
  243. msCancelFullScreen(): void;
  244. mozFullScreen: boolean;
  245. msIsFullScreen: boolean;
  246. fullscreen: boolean;
  247. mozPointerLockElement: HTMLElement;
  248. msPointerLockElement: HTMLElement;
  249. webkitPointerLockElement: HTMLElement;
  250. }
  251. interface HTMLCanvasElement {
  252. msRequestPointerLock?(): void;
  253. mozRequestPointerLock?(): void;
  254. webkitRequestPointerLock?(): void;
  255. }
  256. interface CanvasRenderingContext2D {
  257. msImageSmoothingEnabled: boolean;
  258. }
  259. interface WebGLBuffer {
  260. references: number;
  261. capacity: number;
  262. is32Bits: boolean;
  263. }
  264. interface WebGLProgram {
  265. transformFeedback?: WebGLTransformFeedback | null;
  266. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  267. }
  268. interface MouseEvent {
  269. mozMovementX: number;
  270. mozMovementY: number;
  271. webkitMovementX: number;
  272. webkitMovementY: number;
  273. msMovementX: number;
  274. msMovementY: number;
  275. }
  276. interface Navigator {
  277. mozGetVRDevices: (any: any) => any;
  278. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  279. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  280. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  281. webkitGetGamepads(): Gamepad[];
  282. msGetGamepads(): Gamepad[];
  283. webkitGamepads(): Gamepad[];
  284. }
  285. interface HTMLVideoElement {
  286. mozSrcObject: any;
  287. }
  288. interface Screen {
  289. orientation: string;
  290. mozOrientation: string;
  291. }
  292. interface Math {
  293. fround(x: number): number;
  294. imul(a: number, b: number): number;
  295. }
  296. interface EXT_disjoint_timer_query {
  297. QUERY_COUNTER_BITS_EXT: number;
  298. TIME_ELAPSED_EXT: number;
  299. TIMESTAMP_EXT: number;
  300. GPU_DISJOINT_EXT: number;
  301. QUERY_RESULT_EXT: number;
  302. QUERY_RESULT_AVAILABLE_EXT: number;
  303. queryCounterEXT(query: WebGLQuery, target: number): void;
  304. createQueryEXT(): WebGLQuery;
  305. beginQueryEXT(target: number, query: WebGLQuery): void;
  306. endQueryEXT(target: number): void;
  307. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  308. deleteQueryEXT(query: WebGLQuery): void;
  309. }
  310. interface WebGLUniformLocation {
  311. _currentState: any;
  312. }
  313. declare module BABYLON {
  314. /**
  315. * Defines how a node can be built from a string name.
  316. */
  317. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  318. /**
  319. * Node is the basic class for all scene objects (Mesh, Light Camera).
  320. */
  321. class Node implements IBehaviorAware<Node> {
  322. private static _NodeConstructors;
  323. /**
  324. * Add a new node constructor
  325. * @param type defines the type name of the node to construct
  326. * @param constructorFunc defines the constructor function
  327. */
  328. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  329. /**
  330. * Returns a node constructor based on type name
  331. * @param type defines the type name
  332. * @param name defines the new node name
  333. * @param scene defines the hosting scene
  334. * @param options defines optional options to transmit to constructors
  335. * @returns the new constructor or null
  336. */
  337. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  338. /**
  339. * Gets or sets the name of the node
  340. */
  341. name: string;
  342. /**
  343. * Gets or sets the id of the node
  344. */
  345. id: string;
  346. /**
  347. * Gets or sets the unique id of the node
  348. */
  349. uniqueId: number;
  350. /**
  351. * Gets or sets a string used to store user defined state for the node
  352. */
  353. state: string;
  354. /**
  355. * Gets or sets an object used to store user defined information for the node
  356. */
  357. metadata: any;
  358. /**
  359. * Gets or sets a boolean used to define if the node must be serialized
  360. */
  361. doNotSerialize: boolean;
  362. /** @hidden */
  363. _isDisposed: boolean;
  364. /**
  365. * Gets a list of Animations associated with the node
  366. */
  367. animations: Animation[];
  368. private _ranges;
  369. /**
  370. * Callback raised when the node is ready to be used
  371. */
  372. onReady: (node: Node) => void;
  373. private _isEnabled;
  374. private _isReady;
  375. /** @hidden */
  376. _currentRenderId: number;
  377. private _parentRenderId;
  378. protected _childRenderId: number;
  379. /** @hidden */
  380. _waitingParentId: Nullable<string>;
  381. /** @hidden */
  382. _scene: Scene;
  383. /** @hidden */
  384. _cache: any;
  385. private _parentNode;
  386. private _children;
  387. /**
  388. * Gets a boolean indicating if the node has been disposed
  389. * @returns true if the node was disposed
  390. */
  391. isDisposed(): boolean;
  392. /**
  393. * Gets or sets the parent of the node
  394. */
  395. parent: Nullable<Node>;
  396. private _animationPropertiesOverride;
  397. /**
  398. * Gets or sets the animation properties override
  399. */
  400. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  401. /**
  402. * Gets a string idenfifying the name of the class
  403. * @returns "Node" string
  404. */
  405. getClassName(): string;
  406. /**
  407. * An event triggered when the mesh is disposed
  408. */
  409. onDisposeObservable: Observable<Node>;
  410. private _onDisposeObserver;
  411. /**
  412. * Sets a callback that will be raised when the node will be disposed
  413. */
  414. onDispose: () => void;
  415. /**
  416. * Creates a new Node
  417. * @param {string} name - the name and id to be given to this node
  418. * @param {BABYLON.Scene} the scene this node will be added to
  419. */
  420. constructor(name: string, scene?: Nullable<Scene>);
  421. /**
  422. * Gets the scene of the node
  423. * @returns a {BABYLON.Scene}
  424. */
  425. getScene(): Scene;
  426. /**
  427. * Gets the engine of the node
  428. * @returns a {BABYLON.Engine}
  429. */
  430. getEngine(): Engine;
  431. private _behaviors;
  432. /**
  433. * Attach a behavior to the node
  434. * @see http://doc.babylonjs.com/features/behaviour
  435. * @param behavior defines the behavior to attach
  436. * @returns the current Node
  437. */
  438. addBehavior(behavior: Behavior<Node>): Node;
  439. /**
  440. * Remove an attached behavior
  441. * @see http://doc.babylonjs.com/features/behaviour
  442. * @param behavior defines the behavior to attach
  443. * @returns the current Node
  444. */
  445. removeBehavior(behavior: Behavior<Node>): Node;
  446. /**
  447. * Gets the list of attached behaviors
  448. * @see http://doc.babylonjs.com/features/behaviour
  449. */
  450. readonly behaviors: Behavior<Node>[];
  451. /**
  452. * Gets an attached behavior by name
  453. * @param name defines the name of the behavior to look for
  454. * @see http://doc.babylonjs.com/features/behaviour
  455. * @returns null if behavior was not found else the requested behavior
  456. */
  457. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  458. /**
  459. * Returns the world matrix of the node
  460. * @returns a matrix containing the node's world matrix
  461. */
  462. getWorldMatrix(): Matrix;
  463. /** @hidden */
  464. _getWorldMatrixDeterminant(): number;
  465. /** @hidden */
  466. _initCache(): void;
  467. /** @hidden */
  468. updateCache(force?: boolean): void;
  469. /** @hidden */
  470. _updateCache(ignoreParentClass?: boolean): void;
  471. /** @hidden */
  472. _isSynchronized(): boolean;
  473. /** @hidden */
  474. _markSyncedWithParent(): void;
  475. /** @hidden */
  476. isSynchronizedWithParent(): boolean;
  477. /** @hidden */
  478. isSynchronized(updateCache?: boolean): boolean;
  479. /** @hidden */
  480. hasNewParent(update?: boolean): boolean;
  481. /**
  482. * Is this node ready to be used/rendered
  483. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  484. * @return true if the node is ready
  485. */
  486. isReady(completeCheck?: boolean): boolean;
  487. /**
  488. * Is this node enabled?
  489. * 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
  490. * @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
  491. * @return whether this node (and its parent) is enabled
  492. */
  493. isEnabled(checkAncestors?: boolean): boolean;
  494. /**
  495. * Set the enabled state of this node
  496. * @param value defines the new enabled state
  497. */
  498. setEnabled(value: boolean): void;
  499. /**
  500. * Is this node a descendant of the given node?
  501. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  502. * @param ancestor defines the parent node to inspect
  503. * @returns a boolean indicating if this node is a descendant of the given node
  504. */
  505. isDescendantOf(ancestor: Node): boolean;
  506. /** @hidden */
  507. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  508. /**
  509. * Will return all nodes that have this node as ascendant
  510. * @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
  511. * @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
  512. * @return all children nodes of all types
  513. */
  514. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  515. /**
  516. * Get all child-meshes of this node
  517. * @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
  518. * @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
  519. * @returns an array of {BABYLON.AbstractMesh}
  520. */
  521. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  522. /**
  523. * Get all child-transformNodes of this node
  524. * @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
  525. * @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
  526. * @returns an array of {BABYLON.TransformNode}
  527. */
  528. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  529. /**
  530. * Get all direct children of this node
  531. * @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
  532. * @returns an array of {BABYLON.Node}
  533. */
  534. getChildren(predicate?: (node: Node) => boolean): Node[];
  535. /** @hidden */
  536. _setReady(state: boolean): void;
  537. /**
  538. * Get an animation by name
  539. * @param name defines the name of the animation to look for
  540. * @returns null if not found else the requested animation
  541. */
  542. getAnimationByName(name: string): Nullable<Animation>;
  543. /**
  544. * Creates an animation range for this node
  545. * @param name defines the name of the range
  546. * @param from defines the starting key
  547. * @param to defines the end key
  548. */
  549. createAnimationRange(name: string, from: number, to: number): void;
  550. /**
  551. * Delete a specific animation range
  552. * @param name defines the name of the range to delete
  553. * @param deleteFrames defines if animation frames from the range must be deleted as well
  554. */
  555. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  556. /**
  557. * Get an animation range by name
  558. * @param name defines the name of the animation range to look for
  559. * @returns null if not found else the requested animation range
  560. */
  561. getAnimationRange(name: string): Nullable<AnimationRange>;
  562. /**
  563. * Will start the animation sequence
  564. * @param name defines the range frames for animation sequence
  565. * @param loop defines if the animation should loop (false by default)
  566. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  567. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  568. * @returns the object created for this animation. If range does not exist, it will return null
  569. */
  570. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  571. /**
  572. * Serialize animation ranges into a JSON compatible object
  573. * @returns serialization object
  574. */
  575. serializeAnimationRanges(): any;
  576. /**
  577. * Computes the world matrix of the node
  578. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  579. * @returns the world matrix
  580. */
  581. computeWorldMatrix(force?: boolean): Matrix;
  582. /**
  583. * Releases resources associated with this node.
  584. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  585. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  586. */
  587. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  588. /**
  589. * Parse animation range data from a serialization object and store them into a given node
  590. * @param node defines where to store the animation ranges
  591. * @param parsedNode defines the serialization object to read data from
  592. * @param scene defines the hosting scene
  593. */
  594. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  595. }
  596. }
  597. declare module BABYLON {
  598. /**
  599. * Define an interface for all classes that will hold resources
  600. */
  601. interface IDisposable {
  602. /**
  603. * Releases all held resources
  604. */
  605. dispose(): void;
  606. }
  607. /**
  608. * Interface used to let developers provide their own mesh selection mechanism
  609. */
  610. interface IActiveMeshCandidateProvider {
  611. /**
  612. * Return the list of active meshes
  613. * @param scene defines the current scene
  614. * @returns the list of active meshes
  615. */
  616. getMeshes(scene: Scene): AbstractMesh[];
  617. /**
  618. * Indicates if the meshes have been checked to make sure they are isEnabled()
  619. */
  620. readonly checksIsEnabled: boolean;
  621. }
  622. /**
  623. * This class is used by the onRenderingGroupObservable
  624. */
  625. class RenderingGroupInfo {
  626. /**
  627. * The Scene that being rendered
  628. */
  629. scene: Scene;
  630. /**
  631. * The camera currently used for the rendering pass
  632. */
  633. camera: Nullable<Camera>;
  634. /**
  635. * The ID of the renderingGroup being processed
  636. */
  637. renderingGroupId: number;
  638. }
  639. /**
  640. * Represents a scene to be rendered by the engine.
  641. * @see http://doc.babylonjs.com/features/scene
  642. */
  643. class Scene extends AbstractScene implements IAnimatable {
  644. private static _FOGMODE_NONE;
  645. private static _FOGMODE_EXP;
  646. private static _FOGMODE_EXP2;
  647. private static _FOGMODE_LINEAR;
  648. private static _uniqueIdCounter;
  649. /**
  650. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  651. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  652. */
  653. static MinDeltaTime: number;
  654. /**
  655. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  656. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  657. */
  658. static MaxDeltaTime: number;
  659. /** The fog is deactivated */
  660. static readonly FOGMODE_NONE: number;
  661. /** The fog density is following an exponential function */
  662. static readonly FOGMODE_EXP: number;
  663. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  664. static readonly FOGMODE_EXP2: number;
  665. /** The fog density is following a linear function. */
  666. static readonly FOGMODE_LINEAR: number;
  667. /**
  668. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  669. */
  670. autoClear: boolean;
  671. /**
  672. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  673. */
  674. autoClearDepthAndStencil: boolean;
  675. /**
  676. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  677. */
  678. clearColor: Color4;
  679. /**
  680. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  681. */
  682. ambientColor: Color3;
  683. /** @hidden */
  684. _environmentBRDFTexture: BaseTexture;
  685. /** @hidden */
  686. protected _environmentTexture: BaseTexture;
  687. /**
  688. * Texture used in all pbr material as the reflection texture.
  689. * As in the majority of the scene they are the same (exception for multi room and so on),
  690. * this is easier to reference from here than from all the materials.
  691. */
  692. /**
  693. * Texture used in all pbr material as the reflection texture.
  694. * As in the majority of the scene they are the same (exception for multi room and so on),
  695. * this is easier to set here than in all the materials.
  696. */
  697. environmentTexture: BaseTexture;
  698. /** @hidden */
  699. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  700. /**
  701. * Default image processing configuration used either in the rendering
  702. * Forward main pass or through the imageProcessingPostProcess if present.
  703. * As in the majority of the scene they are the same (exception for multi camera),
  704. * this is easier to reference from here than from all the materials and post process.
  705. *
  706. * No setter as we it is a shared configuration, you can set the values instead.
  707. */
  708. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  709. private _forceWireframe;
  710. /**
  711. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  712. */
  713. forceWireframe: boolean;
  714. private _forcePointsCloud;
  715. /**
  716. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  717. */
  718. forcePointsCloud: boolean;
  719. /**
  720. * Gets or sets the active clipplane
  721. */
  722. clipPlane: Nullable<Plane>;
  723. /**
  724. * Gets or sets a boolean indicating if animations are enabled
  725. */
  726. animationsEnabled: boolean;
  727. private _animationPropertiesOverride;
  728. /**
  729. * Gets or sets the animation properties override
  730. */
  731. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  732. /**
  733. * Gets or sets a boolean indicating if a constant deltatime has to be used
  734. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  735. */
  736. useConstantAnimationDeltaTime: boolean;
  737. /**
  738. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  739. * Please note that it requires to run a ray cast through the scene on every frame
  740. */
  741. constantlyUpdateMeshUnderPointer: boolean;
  742. /**
  743. * Defines the HTML cursor to use when hovering over interactive elements
  744. */
  745. hoverCursor: string;
  746. /**
  747. * Defines the HTML default cursor to use (empty by default)
  748. */
  749. defaultCursor: string;
  750. /**
  751. * This is used to call preventDefault() on pointer down
  752. * in order to block unwanted artifacts like system double clicks
  753. */
  754. preventDefaultOnPointerDown: boolean;
  755. /**
  756. * Gets or sets user defined metadata
  757. */
  758. metadata: any;
  759. /**
  760. * Gets the name of the plugin used to load this scene (null by default)
  761. */
  762. loadingPluginName: string;
  763. /**
  764. * Use this array to add regular expressions used to disable offline support for specific urls
  765. */
  766. disableOfflineSupportExceptionRules: RegExp[];
  767. private _spritePredicate;
  768. /**
  769. * An event triggered when the scene is disposed.
  770. */
  771. onDisposeObservable: Observable<Scene>;
  772. private _onDisposeObserver;
  773. /** Sets a function to be executed when this scene is disposed. */
  774. onDispose: () => void;
  775. /**
  776. * An event triggered before rendering the scene (right after animations and physics)
  777. */
  778. onBeforeRenderObservable: Observable<Scene>;
  779. private _onBeforeRenderObserver;
  780. /** Sets a function to be executed before rendering this scene */
  781. beforeRender: Nullable<() => void>;
  782. /**
  783. * An event triggered after rendering the scene
  784. */
  785. onAfterRenderObservable: Observable<Scene>;
  786. private _onAfterRenderObserver;
  787. /** Sets a function to be executed after rendering this scene */
  788. afterRender: Nullable<() => void>;
  789. /**
  790. * An event triggered before animating the scene
  791. */
  792. onBeforeAnimationsObservable: Observable<Scene>;
  793. /**
  794. * An event triggered after animations processing
  795. */
  796. onAfterAnimationsObservable: Observable<Scene>;
  797. /**
  798. * An event triggered before draw calls are ready to be sent
  799. */
  800. onBeforeDrawPhaseObservable: Observable<Scene>;
  801. /**
  802. * An event triggered after draw calls have been sent
  803. */
  804. onAfterDrawPhaseObservable: Observable<Scene>;
  805. /**
  806. * An event triggered when physic simulation is about to be run
  807. */
  808. onBeforePhysicsObservable: Observable<Scene>;
  809. /**
  810. * An event triggered when physic simulation has been done
  811. */
  812. onAfterPhysicsObservable: Observable<Scene>;
  813. /**
  814. * An event triggered when the scene is ready
  815. */
  816. onReadyObservable: Observable<Scene>;
  817. /**
  818. * An event triggered before rendering a camera
  819. */
  820. onBeforeCameraRenderObservable: Observable<Camera>;
  821. private _onBeforeCameraRenderObserver;
  822. /** Sets a function to be executed before rendering a camera*/
  823. beforeCameraRender: () => void;
  824. /**
  825. * An event triggered after rendering a camera
  826. */
  827. onAfterCameraRenderObservable: Observable<Camera>;
  828. private _onAfterCameraRenderObserver;
  829. /** Sets a function to be executed after rendering a camera*/
  830. afterCameraRender: () => void;
  831. /**
  832. * An event triggered when active meshes evaluation is about to start
  833. */
  834. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  835. /**
  836. * An event triggered when active meshes evaluation is done
  837. */
  838. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  839. /**
  840. * An event triggered when particles rendering is about to start
  841. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  842. */
  843. onBeforeParticlesRenderingObservable: Observable<Scene>;
  844. /**
  845. * An event triggered when particles rendering is done
  846. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  847. */
  848. onAfterParticlesRenderingObservable: Observable<Scene>;
  849. /**
  850. * An event triggered when sprites rendering is about to start
  851. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  852. */
  853. onBeforeSpritesRenderingObservable: Observable<Scene>;
  854. /**
  855. * An event triggered when sprites rendering is done
  856. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  857. */
  858. onAfterSpritesRenderingObservable: Observable<Scene>;
  859. /**
  860. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  861. */
  862. onDataLoadedObservable: Observable<Scene>;
  863. /**
  864. * An event triggered when a camera is created
  865. */
  866. onNewCameraAddedObservable: Observable<Camera>;
  867. /**
  868. * An event triggered when a camera is removed
  869. */
  870. onCameraRemovedObservable: Observable<Camera>;
  871. /**
  872. * An event triggered when a light is created
  873. */
  874. onNewLightAddedObservable: Observable<Light>;
  875. /**
  876. * An event triggered when a light is removed
  877. */
  878. onLightRemovedObservable: Observable<Light>;
  879. /**
  880. * An event triggered when a geometry is created
  881. */
  882. onNewGeometryAddedObservable: Observable<Geometry>;
  883. /**
  884. * An event triggered when a geometry is removed
  885. */
  886. onGeometryRemovedObservable: Observable<Geometry>;
  887. /**
  888. * An event triggered when a transform node is created
  889. */
  890. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  891. /**
  892. * An event triggered when a transform node is removed
  893. */
  894. onTransformNodeRemovedObservable: Observable<TransformNode>;
  895. /**
  896. * An event triggered when a mesh is created
  897. */
  898. onNewMeshAddedObservable: Observable<AbstractMesh>;
  899. /**
  900. * An event triggered when a mesh is removed
  901. */
  902. onMeshRemovedObservable: Observable<AbstractMesh>;
  903. /**
  904. * An event triggered when render targets are about to be rendered
  905. * Can happen multiple times per frame.
  906. */
  907. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  908. /**
  909. * An event triggered when render targets were rendered.
  910. * Can happen multiple times per frame.
  911. */
  912. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  913. /**
  914. * An event triggered before calculating deterministic simulation step
  915. */
  916. onBeforeStepObservable: Observable<Scene>;
  917. /**
  918. * An event triggered after calculating deterministic simulation step
  919. */
  920. onAfterStepObservable: Observable<Scene>;
  921. /**
  922. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  923. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  924. * 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)
  925. */
  926. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  927. /**
  928. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  929. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  930. * 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)
  931. */
  932. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  933. private _registeredForLateAnimationBindings;
  934. /**
  935. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  936. */
  937. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  938. /**
  939. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  940. */
  941. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  942. /**
  943. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  944. */
  945. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  946. private _onPointerMove;
  947. private _onPointerDown;
  948. private _onPointerUp;
  949. /** Deprecated. Use onPointerObservable instead */
  950. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  951. /** Deprecated. Use onPointerObservable instead */
  952. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  953. /** Deprecated. Use onPointerObservable instead */
  954. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  955. /** Deprecated. Use onPointerObservable instead */
  956. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  957. /**
  958. * 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).
  959. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  960. */
  961. onPrePointerObservable: Observable<PointerInfoPre>;
  962. /**
  963. * Observable event triggered each time an input event is received from the rendering canvas
  964. */
  965. onPointerObservable: Observable<PointerInfo>;
  966. /**
  967. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  968. */
  969. readonly unTranslatedPointer: Vector2;
  970. /** The distance in pixel that you have to move to prevent some events */
  971. static DragMovementThreshold: number;
  972. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  973. static LongPressDelay: number;
  974. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  975. static DoubleClickDelay: number;
  976. /** If you need to check double click without raising a single click at first click, enable this flag */
  977. static ExclusiveDoubleClickMode: boolean;
  978. private _initClickEvent;
  979. private _initActionManager;
  980. private _delayedSimpleClick;
  981. private _delayedSimpleClickTimeout;
  982. private _previousDelayedSimpleClickTimeout;
  983. private _meshPickProceed;
  984. private _previousButtonPressed;
  985. private _currentPickResult;
  986. private _previousPickResult;
  987. private _totalPointersPressed;
  988. private _doubleClickOccured;
  989. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  990. cameraToUseForPointers: Nullable<Camera>;
  991. private _pointerX;
  992. private _pointerY;
  993. private _unTranslatedPointerX;
  994. private _unTranslatedPointerY;
  995. private _startingPointerPosition;
  996. private _previousStartingPointerPosition;
  997. private _startingPointerTime;
  998. private _previousStartingPointerTime;
  999. private _pointerCaptures;
  1000. private _timeAccumulator;
  1001. private _currentStepId;
  1002. private _currentInternalStep;
  1003. /** @hidden */
  1004. _mirroredCameraPosition: Nullable<Vector3>;
  1005. /**
  1006. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1007. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1008. */
  1009. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1010. /**
  1011. * Observable event triggered each time an keyboard event is received from the hosting window
  1012. */
  1013. onKeyboardObservable: Observable<KeyboardInfo>;
  1014. private _onKeyDown;
  1015. private _onKeyUp;
  1016. private _onCanvasFocusObserver;
  1017. private _onCanvasBlurObserver;
  1018. private _useRightHandedSystem;
  1019. /**
  1020. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1021. */
  1022. useRightHandedSystem: boolean;
  1023. /**
  1024. * Sets the step Id used by deterministic lock step
  1025. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1026. * @param newStepId defines the step Id
  1027. */
  1028. setStepId(newStepId: number): void;
  1029. /**
  1030. * Gets the step Id used by deterministic lock step
  1031. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1032. * @returns the step Id
  1033. */
  1034. getStepId(): number;
  1035. /**
  1036. * Gets the internal step used by deterministic lock step
  1037. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1038. * @returns the internal step
  1039. */
  1040. getInternalStep(): number;
  1041. private _fogEnabled;
  1042. /**
  1043. * Gets or sets a boolean indicating if fog is enabled on this scene
  1044. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1045. */
  1046. fogEnabled: boolean;
  1047. private _fogMode;
  1048. /**
  1049. * Gets or sets the fog mode to use
  1050. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1051. */
  1052. fogMode: number;
  1053. /**
  1054. * Gets or sets the fog color to use
  1055. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1056. */
  1057. fogColor: Color3;
  1058. /**
  1059. * Gets or sets the fog density to use
  1060. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1061. */
  1062. fogDensity: number;
  1063. /**
  1064. * Gets or sets the fog start distance to use
  1065. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1066. */
  1067. fogStart: number;
  1068. /**
  1069. * Gets or sets the fog end distance to use
  1070. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1071. */
  1072. fogEnd: number;
  1073. private _shadowsEnabled;
  1074. /**
  1075. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1076. */
  1077. shadowsEnabled: boolean;
  1078. private _lightsEnabled;
  1079. /**
  1080. * Gets or sets a boolean indicating if lights are enabled on this scene
  1081. */
  1082. lightsEnabled: boolean;
  1083. /** All of the active cameras added to this scene. */
  1084. activeCameras: Camera[];
  1085. /** The current active camera */
  1086. activeCamera: Nullable<Camera>;
  1087. private _defaultMaterial;
  1088. /** The default material used on meshes when no material is affected */
  1089. /** The default material used on meshes when no material is affected */
  1090. defaultMaterial: Material;
  1091. private _texturesEnabled;
  1092. /**
  1093. * Gets or sets a boolean indicating if textures are enabled on this scene
  1094. */
  1095. texturesEnabled: boolean;
  1096. /**
  1097. * Gets or sets a boolean indicating if particles are enabled on this scene
  1098. */
  1099. particlesEnabled: boolean;
  1100. /**
  1101. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1102. */
  1103. spritesEnabled: boolean;
  1104. /**
  1105. * All of the sprite managers added to this scene
  1106. * @see http://doc.babylonjs.com/babylon101/sprites
  1107. */
  1108. spriteManagers: SpriteManager[];
  1109. private _skeletonsEnabled;
  1110. /**
  1111. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1112. */
  1113. skeletonsEnabled: boolean;
  1114. /**
  1115. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1116. */
  1117. lensFlaresEnabled: boolean;
  1118. /**
  1119. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1120. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1121. */
  1122. collisionsEnabled: boolean;
  1123. private _workerCollisions;
  1124. /** @hidden */
  1125. collisionCoordinator: ICollisionCoordinator;
  1126. /**
  1127. * Defines the gravity applied to this scene (used only for collisions)
  1128. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1129. */
  1130. gravity: Vector3;
  1131. /**
  1132. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1133. */
  1134. postProcessesEnabled: boolean;
  1135. /**
  1136. * The list of postprocesses added to the scene
  1137. */
  1138. postProcesses: PostProcess[];
  1139. /**
  1140. * Gets the current postprocess manager
  1141. */
  1142. postProcessManager: PostProcessManager;
  1143. private _postProcessRenderPipelineManager;
  1144. /**
  1145. * Gets the postprocess render pipeline manager
  1146. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  1147. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  1148. */
  1149. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1150. /**
  1151. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1152. */
  1153. renderTargetsEnabled: boolean;
  1154. /**
  1155. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1156. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1157. */
  1158. dumpNextRenderTargets: boolean;
  1159. /**
  1160. * The list of user defined render targets added to the scene
  1161. */
  1162. customRenderTargets: RenderTargetTexture[];
  1163. /**
  1164. * Defines if texture loading must be delayed
  1165. * If true, textures will only be loaded when they need to be rendered
  1166. */
  1167. useDelayedTextureLoading: boolean;
  1168. /**
  1169. * Gets the list of meshes imported to the scene through SceneLoader
  1170. */
  1171. importedMeshesFiles: String[];
  1172. /**
  1173. * Gets or sets a boolean indicating if probes are enabled on this scene
  1174. */
  1175. probesEnabled: boolean;
  1176. /**
  1177. * The list of reflection probes added to the scene
  1178. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1179. */
  1180. reflectionProbes: ReflectionProbe[];
  1181. /**
  1182. * @hidden
  1183. */
  1184. database: Database;
  1185. /**
  1186. * Gets or sets the action manager associated with the scene
  1187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1188. */
  1189. actionManager: ActionManager;
  1190. private _meshesForIntersections;
  1191. /**
  1192. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1193. */
  1194. proceduralTexturesEnabled: boolean;
  1195. /**
  1196. * The list of procedural textures added to the scene
  1197. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1198. */
  1199. proceduralTextures: ProceduralTexture[];
  1200. private _mainSoundTrack;
  1201. /**
  1202. * The list of sound tracks added to the scene
  1203. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1204. */
  1205. soundTracks: SoundTrack[];
  1206. private _audioEnabled;
  1207. private _headphone;
  1208. /**
  1209. * Gets the main soundtrack associated with the scene
  1210. */
  1211. readonly mainSoundTrack: SoundTrack;
  1212. /**
  1213. * Gets or sets the VRExperienceHelper attached to the scene
  1214. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1215. * @ignorenaming
  1216. */
  1217. VRHelper: VRExperienceHelper;
  1218. /**
  1219. * Gets or sets the simplification queue attached to the scene
  1220. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  1221. */
  1222. simplificationQueue: SimplificationQueue;
  1223. private _engine;
  1224. private _totalVertices;
  1225. /** @hidden */
  1226. _activeIndices: PerfCounter;
  1227. /** @hidden */
  1228. _activeParticles: PerfCounter;
  1229. /** @hidden */
  1230. _activeBones: PerfCounter;
  1231. private _animationRatio;
  1232. private _animationTimeLast;
  1233. private _animationTime;
  1234. /**
  1235. * Gets or sets a general scale for animation speed
  1236. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1237. */
  1238. animationTimeScale: number;
  1239. /** @hidden */
  1240. _cachedMaterial: Nullable<Material>;
  1241. /** @hidden */
  1242. _cachedEffect: Nullable<Effect>;
  1243. /** @hidden */
  1244. _cachedVisibility: Nullable<number>;
  1245. private _renderId;
  1246. private _executeWhenReadyTimeoutId;
  1247. private _intermediateRendering;
  1248. private _viewUpdateFlag;
  1249. private _projectionUpdateFlag;
  1250. private _alternateViewUpdateFlag;
  1251. private _alternateProjectionUpdateFlag;
  1252. /** @hidden */
  1253. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1254. private _activeRequests;
  1255. private _pendingData;
  1256. private _isDisposed;
  1257. /**
  1258. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1259. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1260. */
  1261. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1262. private _activeMeshes;
  1263. private _processedMaterials;
  1264. private _renderTargets;
  1265. /** @hidden */
  1266. _activeParticleSystems: SmartArray<IParticleSystem>;
  1267. private _activeSkeletons;
  1268. private _softwareSkinnedMeshes;
  1269. private _renderingManager;
  1270. private _physicsEngine;
  1271. /** @hidden */
  1272. _activeAnimatables: Animatable[];
  1273. private _transformMatrix;
  1274. private _sceneUbo;
  1275. private _alternateSceneUbo;
  1276. private _pickWithRayInverseMatrix;
  1277. private _outlineRenderer;
  1278. private _viewMatrix;
  1279. private _projectionMatrix;
  1280. private _alternateViewMatrix;
  1281. private _alternateProjectionMatrix;
  1282. private _alternateTransformMatrix;
  1283. private _useAlternateCameraConfiguration;
  1284. private _alternateRendering;
  1285. /** @hidden */
  1286. _forcedViewPosition: Nullable<Vector3>;
  1287. /** @hidden */
  1288. readonly _isAlternateRenderingEnabled: boolean;
  1289. private _frustumPlanes;
  1290. /**
  1291. * Gets the list of frustum planes (built from the active camera)
  1292. */
  1293. readonly frustumPlanes: Plane[];
  1294. /**
  1295. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1296. * This is useful if there are more lights that the maximum simulteanous authorized
  1297. */
  1298. requireLightSorting: boolean;
  1299. private _selectionOctree;
  1300. private _pointerOverMesh;
  1301. private _pointerOverSprite;
  1302. private _debugLayer;
  1303. private _depthRenderer;
  1304. private _geometryBufferRenderer;
  1305. /**
  1306. * Gets the current geometry buffer associated to the scene.
  1307. */
  1308. /**
  1309. * Sets the current geometry buffer for the scene.
  1310. */
  1311. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1312. private _pickedDownMesh;
  1313. private _pickedUpMesh;
  1314. private _pickedDownSprite;
  1315. private _externalData;
  1316. private _uid;
  1317. /**
  1318. * @hidden
  1319. * Backing store of defined scene components.
  1320. */
  1321. _components: ISceneComponent[];
  1322. /**
  1323. * @hidden
  1324. * Backing store of defined scene components.
  1325. */
  1326. _serializableComponents: ISceneSerializableComponent[];
  1327. /**
  1328. * List of components to register on the next registration step.
  1329. */
  1330. private _transientComponents;
  1331. /**
  1332. * Registers the transient components if needed.
  1333. */
  1334. private _registerTransientComponents;
  1335. /**
  1336. * @hidden
  1337. * Add a component to the scene.
  1338. * Note that the ccomponent could be registered on th next frame if this is called after
  1339. * the register component stage.
  1340. * @param component Defines the component to add to the scene
  1341. */
  1342. _addComponent(component: ISceneComponent): void;
  1343. /**
  1344. * @hidden
  1345. * Gets a component from the scene.
  1346. * @param name defines the name of the component to retrieve
  1347. * @returns the component or null if not present
  1348. */
  1349. _getComponent(name: string): Nullable<ISceneComponent>;
  1350. /**
  1351. * @hidden
  1352. * Defines the actions happening before camera updates.
  1353. */
  1354. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1355. /**
  1356. * @hidden
  1357. * Defines the actions happening during the per mesh ready checks.
  1358. */
  1359. _isReadyForMeshStage: Stage<MeshStageAction>;
  1360. /**
  1361. * @hidden
  1362. * Defines the actions happening before evaluate active mesh checks.
  1363. */
  1364. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1365. /**
  1366. * @hidden
  1367. * Defines the actions happening during the evaluate sub mesh checks.
  1368. */
  1369. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1370. /**
  1371. * @hidden
  1372. * Defines the actions happening during the active mesh stage.
  1373. */
  1374. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1375. /**
  1376. * @hidden
  1377. * Defines the actions happening during the per camera render target step.
  1378. */
  1379. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1380. /**
  1381. * @hidden
  1382. * Defines the actions happening just before the active camera is drawing.
  1383. */
  1384. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1385. /**
  1386. * Defines the actions happening just before a rendering group is drawing.
  1387. */
  1388. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1389. /**
  1390. * @hidden
  1391. * Defines the actions happening just after a rendering group has been drawn.
  1392. */
  1393. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1394. /**
  1395. * @hidden
  1396. * Defines the actions happening just after the active camera has been drawn.
  1397. */
  1398. _afterCameraDrawStage: Stage<CameraStageAction>;
  1399. /**
  1400. * Creates a new Scene
  1401. * @param engine defines the engine to use to render this scene
  1402. */
  1403. constructor(engine: Engine);
  1404. /**
  1405. * Gets the debug layer (aka Inspector) associated with the scene
  1406. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1407. */
  1408. readonly debugLayer: DebugLayer;
  1409. /**
  1410. * Gets a boolean indicating if collisions are processed on a web worker
  1411. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1412. */
  1413. workerCollisions: boolean;
  1414. /**
  1415. * Gets the octree used to boost mesh selection (picking)
  1416. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1417. */
  1418. readonly selectionOctree: Octree<AbstractMesh>;
  1419. /**
  1420. * Gets the mesh that is currently under the pointer
  1421. */
  1422. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1423. /**
  1424. * Gets the current on-screen X position of the pointer
  1425. */
  1426. readonly pointerX: number;
  1427. /**
  1428. * Gets the current on-screen Y position of the pointer
  1429. */
  1430. readonly pointerY: number;
  1431. /**
  1432. * Gets the cached material (ie. the latest rendered one)
  1433. * @returns the cached material
  1434. */
  1435. getCachedMaterial(): Nullable<Material>;
  1436. /**
  1437. * Gets the cached effect (ie. the latest rendered one)
  1438. * @returns the cached effect
  1439. */
  1440. getCachedEffect(): Nullable<Effect>;
  1441. /**
  1442. * Gets the cached visibility state (ie. the latest rendered one)
  1443. * @returns the cached visibility state
  1444. */
  1445. getCachedVisibility(): Nullable<number>;
  1446. /**
  1447. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1448. * @param material defines the current material
  1449. * @param effect defines the current effect
  1450. * @param visibility defines the current visibility state
  1451. * @returns true if one parameter is not cached
  1452. */
  1453. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1454. /**
  1455. * Gets the outline renderer associated with the scene
  1456. * @returns a OutlineRenderer
  1457. */
  1458. getOutlineRenderer(): OutlineRenderer;
  1459. /**
  1460. * Gets the engine associated with the scene
  1461. * @returns an Engine
  1462. */
  1463. getEngine(): Engine;
  1464. /**
  1465. * Gets the total number of vertices rendered per frame
  1466. * @returns the total number of vertices rendered per frame
  1467. */
  1468. getTotalVertices(): number;
  1469. /**
  1470. * Gets the performance counter for total vertices
  1471. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1472. */
  1473. readonly totalVerticesPerfCounter: PerfCounter;
  1474. /**
  1475. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1476. * @returns the total number of active indices rendered per frame
  1477. */
  1478. getActiveIndices(): number;
  1479. /**
  1480. * Gets the performance counter for active indices
  1481. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1482. */
  1483. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1484. /**
  1485. * Gets the total number of active particles rendered per frame
  1486. * @returns the total number of active particles rendered per frame
  1487. */
  1488. getActiveParticles(): number;
  1489. /**
  1490. * Gets the performance counter for active particles
  1491. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1492. */
  1493. readonly activeParticlesPerfCounter: PerfCounter;
  1494. /**
  1495. * Gets the total number of active bones rendered per frame
  1496. * @returns the total number of active bones rendered per frame
  1497. */
  1498. getActiveBones(): number;
  1499. /**
  1500. * Gets the performance counter for active bones
  1501. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1502. */
  1503. readonly activeBonesPerfCounter: PerfCounter;
  1504. /** @hidden */
  1505. getInterFramePerfCounter(): number;
  1506. /** @hidden */
  1507. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1508. /** @hidden */
  1509. getLastFrameDuration(): number;
  1510. /** @hidden */
  1511. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1512. /** @hidden */
  1513. getEvaluateActiveMeshesDuration(): number;
  1514. /** @hidden */
  1515. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1516. /**
  1517. * Gets the array of active meshes
  1518. * @returns an array of AbstractMesh
  1519. */
  1520. getActiveMeshes(): SmartArray<AbstractMesh>;
  1521. /** @hidden */
  1522. getRenderTargetsDuration(): number;
  1523. /** @hidden */
  1524. getRenderDuration(): number;
  1525. /** @hidden */
  1526. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1527. /** @hidden */
  1528. getParticlesDuration(): number;
  1529. /** @hidden */
  1530. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1531. /** @hidden */
  1532. getSpritesDuration(): number;
  1533. /** @hidden */
  1534. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1535. /**
  1536. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1537. * @returns a number
  1538. */
  1539. getAnimationRatio(): number;
  1540. /**
  1541. * Gets an unique Id for the current frame
  1542. * @returns a number
  1543. */
  1544. getRenderId(): number;
  1545. /** Call this function if you want to manually increment the render Id*/
  1546. incrementRenderId(): void;
  1547. private _updatePointerPosition;
  1548. private _createUbo;
  1549. private _createAlternateUbo;
  1550. private _pickSpriteButKeepRay;
  1551. private _setRayOnPointerInfo;
  1552. /**
  1553. * Use this method to simulate a pointer move on a mesh
  1554. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1555. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1556. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1557. * @returns the current scene
  1558. */
  1559. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1560. private _processPointerMove;
  1561. private _checkPrePointerObservable;
  1562. /**
  1563. * Use this method to simulate a pointer down on a mesh
  1564. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1565. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1566. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1567. * @returns the current scene
  1568. */
  1569. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1570. private _processPointerDown;
  1571. /**
  1572. * Use this method to simulate a pointer up on a mesh
  1573. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1574. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1575. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1576. * @returns the current scene
  1577. */
  1578. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1579. private _processPointerUp;
  1580. /**
  1581. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1582. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1583. * @returns true if the pointer was captured
  1584. */
  1585. isPointerCaptured(pointerId?: number): boolean;
  1586. /**
  1587. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1588. * @param attachUp defines if you want to attach events to pointerup
  1589. * @param attachDown defines if you want to attach events to pointerdown
  1590. * @param attachMove defines if you want to attach events to pointermove
  1591. */
  1592. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1593. /** Detaches all event handlers*/
  1594. detachControl(): void;
  1595. /**
  1596. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1597. * Delay loaded resources are not taking in account
  1598. * @return true if all required resources are ready
  1599. */
  1600. isReady(): boolean;
  1601. /** Resets all cached information relative to material (including effect and visibility) */
  1602. resetCachedMaterial(): void;
  1603. /**
  1604. * Registers a function to be called before every frame render
  1605. * @param func defines the function to register
  1606. */
  1607. registerBeforeRender(func: () => void): void;
  1608. /**
  1609. * Unregisters a function called before every frame render
  1610. * @param func defines the function to unregister
  1611. */
  1612. unregisterBeforeRender(func: () => void): void;
  1613. /**
  1614. * Registers a function to be called after every frame render
  1615. * @param func defines the function to register
  1616. */
  1617. registerAfterRender(func: () => void): void;
  1618. /**
  1619. * Unregisters a function called after every frame render
  1620. * @param func defines the function to unregister
  1621. */
  1622. unregisterAfterRender(func: () => void): void;
  1623. private _executeOnceBeforeRender;
  1624. /**
  1625. * The provided function will run before render once and will be disposed afterwards.
  1626. * A timeout delay can be provided so that the function will be executed in N ms.
  1627. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1628. * @param func The function to be executed.
  1629. * @param timeout optional delay in ms
  1630. */
  1631. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1632. /** @hidden */
  1633. _addPendingData(data: any): void;
  1634. /** @hidden */
  1635. _removePendingData(data: any): void;
  1636. /**
  1637. * Returns the number of items waiting to be loaded
  1638. * @returns the number of items waiting to be loaded
  1639. */
  1640. getWaitingItemsCount(): number;
  1641. /**
  1642. * Returns a boolean indicating if the scene is still loading data
  1643. */
  1644. readonly isLoading: boolean;
  1645. /**
  1646. * Registers a function to be executed when the scene is ready
  1647. * @param {Function} func - the function to be executed
  1648. */
  1649. executeWhenReady(func: () => void): void;
  1650. /**
  1651. * Returns a promise that resolves when the scene is ready
  1652. * @returns A promise that resolves when the scene is ready
  1653. */
  1654. whenReadyAsync(): Promise<void>;
  1655. /** @hidden */
  1656. _checkIsReady(): void;
  1657. /**
  1658. * Will start the animation sequence of a given target
  1659. * @param target defines the target
  1660. * @param from defines from which frame should animation start
  1661. * @param to defines until which frame should animation run.
  1662. * @param weight defines the weight to apply to the animation (1.0 by default)
  1663. * @param loop defines if the animation loops
  1664. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1665. * @param onAnimationEnd defines the function to be executed when the animation ends
  1666. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1667. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1668. * @returns the animatable object created for this animation
  1669. */
  1670. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1671. /**
  1672. * Will start the animation sequence of a given target
  1673. * @param target defines the target
  1674. * @param from defines from which frame should animation start
  1675. * @param to defines until which frame should animation run.
  1676. * @param loop defines if the animation loops
  1677. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1678. * @param onAnimationEnd defines the function to be executed when the animation ends
  1679. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1680. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1681. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1682. * @returns the animatable object created for this animation
  1683. */
  1684. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1685. /**
  1686. * Begin a new animation on a given node
  1687. * @param target defines the target where the animation will take place
  1688. * @param animations defines the list of animations to start
  1689. * @param from defines the initial value
  1690. * @param to defines the final value
  1691. * @param loop defines if you want animation to loop (off by default)
  1692. * @param speedRatio defines the speed ratio to apply to all animations
  1693. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1694. * @returns the list of created animatables
  1695. */
  1696. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1697. /**
  1698. * Begin a new animation on a given node and its hierarchy
  1699. * @param target defines the root node where the animation will take place
  1700. * @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.
  1701. * @param animations defines the list of animations to start
  1702. * @param from defines the initial value
  1703. * @param to defines the final value
  1704. * @param loop defines if you want animation to loop (off by default)
  1705. * @param speedRatio defines the speed ratio to apply to all animations
  1706. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1707. * @returns the list of animatables created for all nodes
  1708. */
  1709. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1710. /**
  1711. * Gets the animatable associated with a specific target
  1712. * @param target defines the target of the animatable
  1713. * @returns the required animatable if found
  1714. */
  1715. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1716. /**
  1717. * Gets all animatables associated with a given target
  1718. * @param target defines the target to look animatables for
  1719. * @returns an array of Animatables
  1720. */
  1721. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1722. /**
  1723. * Gets all animatable attached to the scene
  1724. */
  1725. readonly animatables: Animatable[];
  1726. /**
  1727. * Will stop the animation of the given target
  1728. * @param target - the target
  1729. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1730. * @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)
  1731. */
  1732. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1733. /**
  1734. * Stops and removes all animations that have been applied to the scene
  1735. */
  1736. stopAllAnimations(): void;
  1737. private _animate;
  1738. /** @hidden */
  1739. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1740. private _processLateAnimationBindingsForMatrices;
  1741. private _processLateAnimationBindingsForQuaternions;
  1742. private _processLateAnimationBindings;
  1743. /** @hidden */
  1744. _switchToAlternateCameraConfiguration(active: boolean): void;
  1745. /**
  1746. * Gets the current view matrix
  1747. * @returns a Matrix
  1748. */
  1749. getViewMatrix(): Matrix;
  1750. /**
  1751. * Gets the current projection matrix
  1752. * @returns a Matrix
  1753. */
  1754. getProjectionMatrix(): Matrix;
  1755. /**
  1756. * Gets the current transform matrix
  1757. * @returns a Matrix made of View * Projection
  1758. */
  1759. getTransformMatrix(): Matrix;
  1760. /**
  1761. * Sets the current transform matrix
  1762. * @param view defines the View matrix to use
  1763. * @param projection defines the Projection matrix to use
  1764. */
  1765. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1766. /** @hidden */
  1767. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1768. /**
  1769. * Gets the uniform buffer used to store scene data
  1770. * @returns a UniformBuffer
  1771. */
  1772. getSceneUniformBuffer(): UniformBuffer;
  1773. /**
  1774. * Gets an unique (relatively to the current scene) Id
  1775. * @returns an unique number for the scene
  1776. */
  1777. getUniqueId(): number;
  1778. /**
  1779. * Add a mesh to the list of scene's meshes
  1780. * @param newMesh defines the mesh to add
  1781. * @param recursive if all child meshes should also be added to the scene
  1782. */
  1783. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1784. /**
  1785. * Remove a mesh for the list of scene's meshes
  1786. * @param toRemove defines the mesh to remove
  1787. * @param recursive if all child meshes should also be removed from the scene
  1788. * @returns the index where the mesh was in the mesh list
  1789. */
  1790. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1791. /**
  1792. * Add a transform node to the list of scene's transform nodes
  1793. * @param newTransformNode defines the transform node to add
  1794. */
  1795. addTransformNode(newTransformNode: TransformNode): void;
  1796. /**
  1797. * Remove a transform node for the list of scene's transform nodes
  1798. * @param toRemove defines the transform node to remove
  1799. * @returns the index where the transform node was in the transform node list
  1800. */
  1801. removeTransformNode(toRemove: TransformNode): number;
  1802. /**
  1803. * Remove a skeleton for the list of scene's skeletons
  1804. * @param toRemove defines the skeleton to remove
  1805. * @returns the index where the skeleton was in the skeleton list
  1806. */
  1807. removeSkeleton(toRemove: Skeleton): number;
  1808. /**
  1809. * Remove a morph target for the list of scene's morph targets
  1810. * @param toRemove defines the morph target to remove
  1811. * @returns the index where the morph target was in the morph target list
  1812. */
  1813. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1814. /**
  1815. * Remove a light for the list of scene's lights
  1816. * @param toRemove defines the light to remove
  1817. * @returns the index where the light was in the light list
  1818. */
  1819. removeLight(toRemove: Light): number;
  1820. /**
  1821. * Remove a camera for the list of scene's cameras
  1822. * @param toRemove defines the camera to remove
  1823. * @returns the index where the camera was in the camera list
  1824. */
  1825. removeCamera(toRemove: Camera): number;
  1826. /**
  1827. * Remove a particle system for the list of scene's particle systems
  1828. * @param toRemove defines the particle system to remove
  1829. * @returns the index where the particle system was in the particle system list
  1830. */
  1831. removeParticleSystem(toRemove: IParticleSystem): number;
  1832. /**
  1833. * Remove a animation for the list of scene's animations
  1834. * @param toRemove defines the animation to remove
  1835. * @returns the index where the animation was in the animation list
  1836. */
  1837. removeAnimation(toRemove: Animation): number;
  1838. /**
  1839. * Removes the given animation group from this scene.
  1840. * @param toRemove The animation group to remove
  1841. * @returns The index of the removed animation group
  1842. */
  1843. removeAnimationGroup(toRemove: AnimationGroup): number;
  1844. /**
  1845. * Removes the given multi-material from this scene.
  1846. * @param toRemove The multi-material to remove
  1847. * @returns The index of the removed multi-material
  1848. */
  1849. removeMultiMaterial(toRemove: MultiMaterial): number;
  1850. /**
  1851. * Removes the given material from this scene.
  1852. * @param toRemove The material to remove
  1853. * @returns The index of the removed material
  1854. */
  1855. removeMaterial(toRemove: Material): number;
  1856. /**
  1857. * Removes the given action manager from this scene.
  1858. * @param toRemove The action manager to remove
  1859. * @returns The index of the removed action manager
  1860. */
  1861. removeActionManager(toRemove: ActionManager): number;
  1862. /**
  1863. * Removes the given texture from this scene.
  1864. * @param toRemove The texture to remove
  1865. * @returns The index of the removed texture
  1866. */
  1867. removeTexture(toRemove: BaseTexture): number;
  1868. /**
  1869. * Adds the given light to this scene
  1870. * @param newLight The light to add
  1871. */
  1872. addLight(newLight: Light): void;
  1873. /**
  1874. * Sorts the list list based on light priorities
  1875. */
  1876. sortLightsByPriority(): void;
  1877. /**
  1878. * Adds the given camera to this scene
  1879. * @param newCamera The camera to add
  1880. */
  1881. addCamera(newCamera: Camera): void;
  1882. /**
  1883. * Adds the given skeleton to this scene
  1884. * @param newSkeleton The skeleton to add
  1885. */
  1886. addSkeleton(newSkeleton: Skeleton): void;
  1887. /**
  1888. * Adds the given particle system to this scene
  1889. * @param newParticleSystem The particle system to add
  1890. */
  1891. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1892. /**
  1893. * Adds the given animation to this scene
  1894. * @param newAnimation The animation to add
  1895. */
  1896. addAnimation(newAnimation: Animation): void;
  1897. /**
  1898. * Adds the given animation group to this scene.
  1899. * @param newAnimationGroup The animation group to add
  1900. */
  1901. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1902. /**
  1903. * Adds the given multi-material to this scene
  1904. * @param newMultiMaterial The multi-material to add
  1905. */
  1906. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1907. /**
  1908. * Adds the given material to this scene
  1909. * @param newMaterial The material to add
  1910. */
  1911. addMaterial(newMaterial: Material): void;
  1912. /**
  1913. * Adds the given morph target to this scene
  1914. * @param newMorphTargetManager The morph target to add
  1915. */
  1916. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1917. /**
  1918. * Adds the given geometry to this scene
  1919. * @param newGeometry The geometry to add
  1920. */
  1921. addGeometry(newGeometry: Geometry): void;
  1922. /**
  1923. * Adds the given action manager to this scene
  1924. * @param newActionManager The action manager to add
  1925. */
  1926. addActionManager(newActionManager: ActionManager): void;
  1927. /**
  1928. * Adds the given texture to this scene.
  1929. * @param newTexture The texture to add
  1930. */
  1931. addTexture(newTexture: BaseTexture): void;
  1932. /**
  1933. * Switch active camera
  1934. * @param newCamera defines the new active camera
  1935. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1936. */
  1937. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1938. /**
  1939. * sets the active camera of the scene using its ID
  1940. * @param id defines the camera's ID
  1941. * @return the new active camera or null if none found.
  1942. */
  1943. setActiveCameraByID(id: string): Nullable<Camera>;
  1944. /**
  1945. * sets the active camera of the scene using its name
  1946. * @param name defines the camera's name
  1947. * @returns the new active camera or null if none found.
  1948. */
  1949. setActiveCameraByName(name: string): Nullable<Camera>;
  1950. /**
  1951. * get an animation group using its name
  1952. * @param name defines the material's name
  1953. * @return the animation group or null if none found.
  1954. */
  1955. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1956. /**
  1957. * get a material using its id
  1958. * @param id defines the material's ID
  1959. * @return the material or null if none found.
  1960. */
  1961. getMaterialByID(id: string): Nullable<Material>;
  1962. /**
  1963. * Gets a material using its name
  1964. * @param name defines the material's name
  1965. * @return the material or null if none found.
  1966. */
  1967. getMaterialByName(name: string): Nullable<Material>;
  1968. /**
  1969. * Gets a camera using its id
  1970. * @param id defines the id to look for
  1971. * @returns the camera or null if not found
  1972. */
  1973. getCameraByID(id: string): Nullable<Camera>;
  1974. /**
  1975. * Gets a camera using its unique id
  1976. * @param uniqueId defines the unique id to look for
  1977. * @returns the camera or null if not found
  1978. */
  1979. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1980. /**
  1981. * Gets a camera using its name
  1982. * @param name defines the camera's name
  1983. * @return the camera or null if none found.
  1984. */
  1985. getCameraByName(name: string): Nullable<Camera>;
  1986. /**
  1987. * Gets a bone using its id
  1988. * @param id defines the bone's id
  1989. * @return the bone or null if not found
  1990. */
  1991. getBoneByID(id: string): Nullable<Bone>;
  1992. /**
  1993. * Gets a bone using its id
  1994. * @param name defines the bone's name
  1995. * @return the bone or null if not found
  1996. */
  1997. getBoneByName(name: string): Nullable<Bone>;
  1998. /**
  1999. * Gets a light node using its name
  2000. * @param name defines the the light's name
  2001. * @return the light or null if none found.
  2002. */
  2003. getLightByName(name: string): Nullable<Light>;
  2004. /**
  2005. * Gets a light node using its id
  2006. * @param id defines the light's id
  2007. * @return the light or null if none found.
  2008. */
  2009. getLightByID(id: string): Nullable<Light>;
  2010. /**
  2011. * Gets a light node using its scene-generated unique ID
  2012. * @param uniqueId defines the light's unique id
  2013. * @return the light or null if none found.
  2014. */
  2015. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2016. /**
  2017. * Gets a particle system by id
  2018. * @param id defines the particle system id
  2019. * @return the corresponding system or null if none found
  2020. */
  2021. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2022. /**
  2023. * Gets a geometry using its ID
  2024. * @param id defines the geometry's id
  2025. * @return the geometry or null if none found.
  2026. */
  2027. getGeometryByID(id: string): Nullable<Geometry>;
  2028. /**
  2029. * Add a new geometry to this scene
  2030. * @param geometry defines the geometry to be added to the scene.
  2031. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2032. * @return a boolean defining if the geometry was added or not
  2033. */
  2034. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2035. /**
  2036. * Removes an existing geometry
  2037. * @param geometry defines the geometry to be removed from the scene
  2038. * @return a boolean defining if the geometry was removed or not
  2039. */
  2040. removeGeometry(geometry: Geometry): boolean;
  2041. /**
  2042. * Gets the list of geometries attached to the scene
  2043. * @returns an array of Geometry
  2044. */
  2045. getGeometries(): Geometry[];
  2046. /**
  2047. * Gets the first added mesh found of a given ID
  2048. * @param id defines the id to search for
  2049. * @return the mesh found or null if not found at all
  2050. */
  2051. getMeshByID(id: string): Nullable<AbstractMesh>;
  2052. /**
  2053. * Gets a list of meshes using their id
  2054. * @param id defines the id to search for
  2055. * @returns a list of meshes
  2056. */
  2057. getMeshesByID(id: string): Array<AbstractMesh>;
  2058. /**
  2059. * Gets the first added transform node found of a given ID
  2060. * @param id defines the id to search for
  2061. * @return the found transform node or null if not found at all.
  2062. */
  2063. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2064. /**
  2065. * Gets a list of transform nodes using their id
  2066. * @param id defines the id to search for
  2067. * @returns a list of transform nodes
  2068. */
  2069. getTransformNodesByID(id: string): Array<TransformNode>;
  2070. /**
  2071. * Gets a mesh with its auto-generated unique id
  2072. * @param uniqueId defines the unique id to search for
  2073. * @return the found mesh or null if not found at all.
  2074. */
  2075. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2076. /**
  2077. * Gets a the last added mesh using a given id
  2078. * @param id defines the id to search for
  2079. * @return the found mesh or null if not found at all.
  2080. */
  2081. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2082. /**
  2083. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2084. * @param id defines the id to search for
  2085. * @return the found node or null if not found at all
  2086. */
  2087. getLastEntryByID(id: string): Nullable<Node>;
  2088. /**
  2089. * Gets a node (Mesh, Camera, Light) using a given id
  2090. * @param id defines the id to search for
  2091. * @return the found node or null if not found at all
  2092. */
  2093. getNodeByID(id: string): Nullable<Node>;
  2094. /**
  2095. * Gets a node (Mesh, Camera, Light) using a given name
  2096. * @param name defines the name to search for
  2097. * @return the found node or null if not found at all.
  2098. */
  2099. getNodeByName(name: string): Nullable<Node>;
  2100. /**
  2101. * Gets a mesh using a given name
  2102. * @param name defines the name to search for
  2103. * @return the found mesh or null if not found at all.
  2104. */
  2105. getMeshByName(name: string): Nullable<AbstractMesh>;
  2106. /**
  2107. * Gets a transform node using a given name
  2108. * @param name defines the name to search for
  2109. * @return the found transform node or null if not found at all.
  2110. */
  2111. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2112. /**
  2113. * Gets a sound using a given name
  2114. * @param name defines the name to search for
  2115. * @return the found sound or null if not found at all.
  2116. */
  2117. getSoundByName(name: string): Nullable<Sound>;
  2118. /**
  2119. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2120. * @param id defines the id to search for
  2121. * @return the found skeleton or null if not found at all.
  2122. */
  2123. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2124. /**
  2125. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2126. * @param id defines the id to search for
  2127. * @return the found skeleton or null if not found at all.
  2128. */
  2129. getSkeletonById(id: string): Nullable<Skeleton>;
  2130. /**
  2131. * Gets a skeleton using a given name
  2132. * @param name defines the name to search for
  2133. * @return the found skeleton or null if not found at all.
  2134. */
  2135. getSkeletonByName(name: string): Nullable<Skeleton>;
  2136. /**
  2137. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2138. * @param id defines the id to search for
  2139. * @return the found morph target manager or null if not found at all.
  2140. */
  2141. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2142. /**
  2143. * Gets a boolean indicating if the given mesh is active
  2144. * @param mesh defines the mesh to look for
  2145. * @returns true if the mesh is in the active list
  2146. */
  2147. isActiveMesh(mesh: AbstractMesh): boolean;
  2148. /**
  2149. * Return a unique id as a string which can serve as an identifier for the scene
  2150. */
  2151. readonly uid: string;
  2152. /**
  2153. * Add an externaly attached data from its key.
  2154. * This method call will fail and return false, if such key already exists.
  2155. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2156. * @param key the unique key that identifies the data
  2157. * @param data the data object to associate to the key for this Engine instance
  2158. * @return true if no such key were already present and the data was added successfully, false otherwise
  2159. */
  2160. addExternalData<T>(key: string, data: T): boolean;
  2161. /**
  2162. * Get an externaly attached data from its key
  2163. * @param key the unique key that identifies the data
  2164. * @return the associated data, if present (can be null), or undefined if not present
  2165. */
  2166. getExternalData<T>(key: string): Nullable<T>;
  2167. /**
  2168. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2169. * @param key the unique key that identifies the data
  2170. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2171. * @return the associated data, can be null if the factory returned null.
  2172. */
  2173. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2174. /**
  2175. * Remove an externaly attached data from the Engine instance
  2176. * @param key the unique key that identifies the data
  2177. * @return true if the data was successfully removed, false if it doesn't exist
  2178. */
  2179. removeExternalData(key: string): boolean;
  2180. private _evaluateSubMesh;
  2181. /**
  2182. * Clear the processed materials smart array preventing retention point in material dispose.
  2183. */
  2184. freeProcessedMaterials(): void;
  2185. /**
  2186. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2187. */
  2188. freeActiveMeshes(): void;
  2189. /**
  2190. * Clear the info related to rendering groups preventing retention points during dispose.
  2191. */
  2192. freeRenderingGroups(): void;
  2193. /** @hidden */
  2194. _isInIntermediateRendering(): boolean;
  2195. private _activeMeshCandidateProvider;
  2196. /**
  2197. * Defines the current active mesh candidate provider
  2198. * @param provider defines the provider to use
  2199. */
  2200. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2201. /**
  2202. * Gets the current active mesh candidate provider
  2203. * @returns the current active mesh candidate provider
  2204. */
  2205. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2206. private _activeMeshesFrozen;
  2207. /**
  2208. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2209. * @returns the current scene
  2210. */
  2211. freezeActiveMeshes(): Scene;
  2212. /**
  2213. * Use this function to restart evaluating active meshes on every frame
  2214. * @returns the current scene
  2215. */
  2216. unfreezeActiveMeshes(): Scene;
  2217. private _evaluateActiveMeshes;
  2218. private _activeMesh;
  2219. /**
  2220. * Update the transform matrix to update from the current active camera
  2221. * @param force defines a boolean used to force the update even if cache is up to date
  2222. */
  2223. updateTransformMatrix(force?: boolean): void;
  2224. /**
  2225. * 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)
  2226. * @param alternateCamera defines the camera to use
  2227. */
  2228. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2229. /** @hidden */
  2230. _allowPostProcessClear: boolean;
  2231. private _renderForCamera;
  2232. private _processSubCameras;
  2233. private _checkIntersections;
  2234. /**
  2235. * Render the scene
  2236. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2237. */
  2238. render(updateCameras?: boolean): void;
  2239. private _updateAudioParameters;
  2240. /**
  2241. * Gets or sets if audio support is enabled
  2242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2243. */
  2244. audioEnabled: boolean;
  2245. private _disableAudio;
  2246. private _enableAudio;
  2247. /**
  2248. * Gets or sets if audio will be output to headphones
  2249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2250. */
  2251. headphone: boolean;
  2252. private _switchAudioModeForHeadphones;
  2253. private _switchAudioModeForNormalSpeakers;
  2254. /**
  2255. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  2256. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  2257. * @returns the created depth renderer
  2258. */
  2259. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  2260. /**
  2261. * Disables a depth renderer for a given camera
  2262. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  2263. */
  2264. disableDepthRenderer(camera?: Nullable<Camera>): void;
  2265. /**
  2266. * Enables a GeometryBufferRender and associates it with the scene
  2267. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  2268. * @returns the GeometryBufferRenderer
  2269. */
  2270. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  2271. /**
  2272. * Disables the GeometryBufferRender associated with the scene
  2273. */
  2274. disableGeometryBufferRenderer(): void;
  2275. /**
  2276. * Freeze all materials
  2277. * A frozen material will not be updatable but should be faster to render
  2278. */
  2279. freezeMaterials(): void;
  2280. /**
  2281. * Unfreeze all materials
  2282. * A frozen material will not be updatable but should be faster to render
  2283. */
  2284. unfreezeMaterials(): void;
  2285. /**
  2286. * Releases all held ressources
  2287. */
  2288. dispose(): void;
  2289. /**
  2290. * Gets if the scene is already disposed
  2291. */
  2292. readonly isDisposed: boolean;
  2293. /**
  2294. * Releases sounds & soundtracks
  2295. */
  2296. disposeSounds(): void;
  2297. /**
  2298. * Call this function to reduce memory footprint of the scene.
  2299. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2300. */
  2301. clearCachedVertexData(): void;
  2302. /**
  2303. * This function will remove the local cached buffer data from texture.
  2304. * It will save memory but will prevent the texture from being rebuilt
  2305. */
  2306. cleanCachedTextureBuffer(): void;
  2307. /**
  2308. * Get the world extend vectors with an optional filter
  2309. *
  2310. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2311. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2312. */
  2313. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2314. min: Vector3;
  2315. max: Vector3;
  2316. };
  2317. /**
  2318. * Creates or updates the octree used to boost selection (picking)
  2319. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2320. * @param maxCapacity defines the maximum capacity per leaf
  2321. * @param maxDepth defines the maximum depth of the octree
  2322. * @returns an octree of AbstractMesh
  2323. */
  2324. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2325. /**
  2326. * Creates a ray that can be used to pick in the scene
  2327. * @param x defines the x coordinate of the origin (on-screen)
  2328. * @param y defines the y coordinate of the origin (on-screen)
  2329. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2330. * @param camera defines the camera to use for the picking
  2331. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2332. * @returns a Ray
  2333. */
  2334. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2335. /**
  2336. * Creates a ray that can be used to pick in the scene
  2337. * @param x defines the x coordinate of the origin (on-screen)
  2338. * @param y defines the y coordinate of the origin (on-screen)
  2339. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2340. * @param result defines the ray where to store the picking ray
  2341. * @param camera defines the camera to use for the picking
  2342. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2343. * @returns the current scene
  2344. */
  2345. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2346. /**
  2347. * Creates a ray that can be used to pick in the scene
  2348. * @param x defines the x coordinate of the origin (on-screen)
  2349. * @param y defines the y coordinate of the origin (on-screen)
  2350. * @param camera defines the camera to use for the picking
  2351. * @returns a Ray
  2352. */
  2353. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2354. /**
  2355. * Creates a ray that can be used to pick in the scene
  2356. * @param x defines the x coordinate of the origin (on-screen)
  2357. * @param y defines the y coordinate of the origin (on-screen)
  2358. * @param result defines the ray where to store the picking ray
  2359. * @param camera defines the camera to use for the picking
  2360. * @returns the current scene
  2361. */
  2362. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2363. private _internalPick;
  2364. private _internalMultiPick;
  2365. private _internalPickSprites;
  2366. private _tempPickingRay;
  2367. /** Launch a ray to try to pick a mesh in the scene
  2368. * @param x position on screen
  2369. * @param y position on screen
  2370. * @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
  2371. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2372. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2373. * @returns a PickingInfo
  2374. */
  2375. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2376. /** Launch a ray to try to pick a sprite in the scene
  2377. * @param x position on screen
  2378. * @param y position on screen
  2379. * @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
  2380. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2381. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2382. * @returns a PickingInfo
  2383. */
  2384. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2385. private _cachedRayForTransform;
  2386. /** Use the given ray to pick a mesh in the scene
  2387. * @param ray The ray to use to pick meshes
  2388. * @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
  2389. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2390. * @returns a PickingInfo
  2391. */
  2392. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2393. /**
  2394. * Launch a ray to try to pick a mesh in the scene
  2395. * @param x X position on screen
  2396. * @param y Y position on screen
  2397. * @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
  2398. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2399. * @returns an array of PickingInfo
  2400. */
  2401. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2402. /**
  2403. * Launch a ray to try to pick a mesh in the scene
  2404. * @param ray Ray to use
  2405. * @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
  2406. * @returns an array of PickingInfo
  2407. */
  2408. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2409. /**
  2410. * Force the value of meshUnderPointer
  2411. * @param mesh defines the mesh to use
  2412. */
  2413. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2414. /**
  2415. * Gets the mesh under the pointer
  2416. * @returns a Mesh or null if no mesh is under the pointer
  2417. */
  2418. getPointerOverMesh(): Nullable<AbstractMesh>;
  2419. /**
  2420. * Force the sprite under the pointer
  2421. * @param sprite defines the sprite to use
  2422. */
  2423. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2424. /**
  2425. * Gets the sprite under the pointer
  2426. * @returns a Sprite or null if no sprite is under the pointer
  2427. */
  2428. getPointerOverSprite(): Nullable<Sprite>;
  2429. /**
  2430. * Gets the current physics engine
  2431. * @returns a PhysicsEngine or null if none attached
  2432. */
  2433. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2434. /**
  2435. * Enables physics to the current scene
  2436. * @param gravity defines the scene's gravity for the physics engine
  2437. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2438. * @return a boolean indicating if the physics engine was initialized
  2439. */
  2440. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2441. /**
  2442. * Disables and disposes the physics engine associated with the scene
  2443. */
  2444. disablePhysicsEngine(): void;
  2445. /**
  2446. * Gets a boolean indicating if there is an active physics engine
  2447. * @returns a boolean indicating if there is an active physics engine
  2448. */
  2449. isPhysicsEnabled(): boolean;
  2450. /**
  2451. * Deletes a physics compound impostor
  2452. * @param compound defines the compound to delete
  2453. */
  2454. deleteCompoundImpostor(compound: any): void;
  2455. /** @hidden */
  2456. _rebuildGeometries(): void;
  2457. /** @hidden */
  2458. _rebuildTextures(): void;
  2459. /**
  2460. * Creates a default light for the scene.
  2461. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  2462. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  2463. */
  2464. createDefaultLight(replace?: boolean): void;
  2465. /**
  2466. * Creates a default camera for the scene.
  2467. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  2468. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  2469. * @param replace has default false, when true replaces the active camera in the scene
  2470. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  2471. */
  2472. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2473. /**
  2474. * Creates a default camera and a default light.
  2475. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  2476. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  2477. * @param replace has the default false, when true replaces the active camera/light in the scene
  2478. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  2479. */
  2480. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2481. /**
  2482. * Creates a new sky box
  2483. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  2484. * @param environmentTexture defines the texture to use as environment texture
  2485. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  2486. * @param scale defines the overall scale of the skybox
  2487. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  2488. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  2489. * @returns a new mesh holding the sky box
  2490. */
  2491. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2492. /**
  2493. * Creates a new environment
  2494. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  2495. * @param options defines the options you can use to configure the environment
  2496. * @returns the new EnvironmentHelper
  2497. */
  2498. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2499. /**
  2500. * Creates a new VREXperienceHelper
  2501. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2502. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2503. * @returns a new VREXperienceHelper
  2504. */
  2505. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2506. private _getByTags;
  2507. /**
  2508. * Get a list of meshes by tags
  2509. * @param tagsQuery defines the tags query to use
  2510. * @param forEach defines a predicate used to filter results
  2511. * @returns an array of Mesh
  2512. */
  2513. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2514. /**
  2515. * Get a list of cameras by tags
  2516. * @param tagsQuery defines the tags query to use
  2517. * @param forEach defines a predicate used to filter results
  2518. * @returns an array of Camera
  2519. */
  2520. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2521. /**
  2522. * Get a list of lights by tags
  2523. * @param tagsQuery defines the tags query to use
  2524. * @param forEach defines a predicate used to filter results
  2525. * @returns an array of Light
  2526. */
  2527. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2528. /**
  2529. * Get a list of materials by tags
  2530. * @param tagsQuery defines the tags query to use
  2531. * @param forEach defines a predicate used to filter results
  2532. * @returns an array of Material
  2533. */
  2534. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2535. /**
  2536. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2537. * This allowed control for front to back rendering or reversly depending of the special needs.
  2538. *
  2539. * @param renderingGroupId The rendering group id corresponding to its index
  2540. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2541. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2542. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2543. */
  2544. 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;
  2545. /**
  2546. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2547. *
  2548. * @param renderingGroupId The rendering group id corresponding to its index
  2549. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2550. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2551. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2552. */
  2553. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2554. /**
  2555. * Gets the current auto clear configuration for one rendering group of the rendering
  2556. * manager.
  2557. * @param index the rendering group index to get the information for
  2558. * @returns The auto clear setup for the requested rendering group
  2559. */
  2560. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2561. /**
  2562. * Will flag all materials as dirty to trigger new shader compilation
  2563. * @param flag defines the flag used to specify which material part must be marked as dirty
  2564. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2565. */
  2566. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2567. /** @hidden */
  2568. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useDatabase?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  2569. /** @hidden */
  2570. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2571. }
  2572. }
  2573. declare module BABYLON {
  2574. /**
  2575. * Groups all the scene component constants in one place to ease maintenance.
  2576. * @hidden
  2577. */
  2578. class SceneComponentConstants {
  2579. static readonly NAME_EFFECTLAYER: string;
  2580. static readonly NAME_LAYER: string;
  2581. static readonly NAME_LENSFLARESYSTEM: string;
  2582. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2583. static readonly NAME_PARTICLESYSTEM: string;
  2584. static readonly NAME_GAMEPAD: string;
  2585. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2586. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2587. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2588. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2589. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2590. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2591. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2592. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2593. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2594. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2595. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2596. static readonly STEP_AFTERCAMERADRAW_BOUNDINGBOXRENDERER: number;
  2597. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2598. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2599. }
  2600. /**
  2601. * This represents a scene component.
  2602. *
  2603. * This is used to decouple the dependency the scene is having on the different workloads like
  2604. * layers, post processes...
  2605. */
  2606. interface ISceneComponent {
  2607. /**
  2608. * The name of the component. Each component must have a unique name.
  2609. */
  2610. name: string;
  2611. /**
  2612. * The scene the component belongs to.
  2613. */
  2614. scene: Scene;
  2615. /**
  2616. * Register the component to one instance of a scene.
  2617. */
  2618. register(): void;
  2619. /**
  2620. * Rebuilds the elements related to this component in case of
  2621. * context lost for instance.
  2622. */
  2623. rebuild(): void;
  2624. /**
  2625. * Disposes the component and the associated ressources.
  2626. */
  2627. dispose(): void;
  2628. }
  2629. /**
  2630. * This represents a SERIALIZABLE scene component.
  2631. *
  2632. * This extends Scene Component to add Serialization methods on top.
  2633. */
  2634. interface ISceneSerializableComponent extends ISceneComponent {
  2635. /**
  2636. * Adds all the element from the container to the scene
  2637. * @param container the container holding the elements
  2638. */
  2639. addFromContainer(container: AbstractScene): void;
  2640. /**
  2641. * Removes all the elements in the container from the scene
  2642. * @param container contains the elements to remove
  2643. */
  2644. removeFromContainer(container: AbstractScene): void;
  2645. /**
  2646. * Serializes the component data to the specified json object
  2647. * @param serializationObject The object to serialize to
  2648. */
  2649. serialize(serializationObject: any): void;
  2650. }
  2651. /**
  2652. * Strong typing of a Mesh related stage step action
  2653. */
  2654. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2655. /**
  2656. * Strong typing of a Evaluate Sub Mesh related stage step action
  2657. */
  2658. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2659. /**
  2660. * Strong typing of a Active Mesh related stage step action
  2661. */
  2662. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2663. /**
  2664. * Strong typing of a Camera related stage step action
  2665. */
  2666. type CameraStageAction = (camera: Camera) => void;
  2667. /**
  2668. * Strong typing of a RenderingGroup related stage step action
  2669. */
  2670. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2671. /**
  2672. * Strong typing of a simple stage step action
  2673. */
  2674. type SimpleStageAction = () => void;
  2675. /**
  2676. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2677. * @hidden
  2678. */
  2679. class Stage<T extends Function> extends Array<{
  2680. index: number;
  2681. component: ISceneComponent;
  2682. action: T;
  2683. }> {
  2684. /**
  2685. * Hide ctor from the rest of the world.
  2686. * @param items The items to add.
  2687. */
  2688. private constructor();
  2689. /**
  2690. * Creates a new Stage.
  2691. * @returns A new instance of a Stage
  2692. */
  2693. static Create<T extends Function>(): Stage<T>;
  2694. /**
  2695. * Registers a step in an ordered way in the targeted stage.
  2696. * @param index Defines the position to register the step in
  2697. * @param component Defines the component attached to the step
  2698. * @param action Defines the action to launch during the step
  2699. */
  2700. registerStep(index: number, component: ISceneComponent, action: T): void;
  2701. /**
  2702. * Clears all the steps from the stage.
  2703. */
  2704. clear(): void;
  2705. }
  2706. }
  2707. declare module BABYLON {
  2708. type Nullable<T> = T | null;
  2709. type float = number;
  2710. type double = number;
  2711. type int = number;
  2712. type FloatArray = number[] | Float32Array;
  2713. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2714. /**
  2715. * Alias for types that can be used by a Buffer or VertexBuffer.
  2716. */
  2717. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2718. }
  2719. declare module BABYLON {
  2720. /**
  2721. * The action to be carried out following a trigger
  2722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2723. */
  2724. class Action {
  2725. /** the trigger, with or without parameters, for the action */
  2726. triggerOptions: any;
  2727. /**
  2728. * Trigger for the action
  2729. */
  2730. trigger: number;
  2731. /**
  2732. * Internal only - manager for action
  2733. * @hidden
  2734. */
  2735. _actionManager: ActionManager;
  2736. private _nextActiveAction;
  2737. private _child;
  2738. private _condition?;
  2739. private _triggerParameter;
  2740. /**
  2741. * An event triggered prior to action being executed.
  2742. */
  2743. onBeforeExecuteObservable: Observable<Action>;
  2744. /**
  2745. * Creates a new Action
  2746. * @param triggerOptions the trigger, with or without parameters, for the action
  2747. * @param condition an optional determinant of action
  2748. */
  2749. constructor(
  2750. /** the trigger, with or without parameters, for the action */
  2751. triggerOptions: any, condition?: Condition);
  2752. /**
  2753. * Internal only
  2754. * @hidden
  2755. */
  2756. _prepare(): void;
  2757. /**
  2758. * Gets the trigger parameters
  2759. * @returns the trigger parameters
  2760. */
  2761. getTriggerParameter(): any;
  2762. /**
  2763. * Internal only - executes current action event
  2764. * @hidden
  2765. */
  2766. _executeCurrent(evt?: ActionEvent): void;
  2767. /**
  2768. * Execute placeholder for child classes
  2769. * @param evt optional action event
  2770. */
  2771. execute(evt?: ActionEvent): void;
  2772. /**
  2773. * Skips to next active action
  2774. */
  2775. skipToNextActiveAction(): void;
  2776. /**
  2777. * Adds action to chain of actions, may be a DoNothingAction
  2778. * @param action defines the next action to execute
  2779. * @returns The action passed in
  2780. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2781. */
  2782. then(action: Action): Action;
  2783. /**
  2784. * Internal only
  2785. * @hidden
  2786. */
  2787. _getProperty(propertyPath: string): string;
  2788. /**
  2789. * Internal only
  2790. * @hidden
  2791. */
  2792. _getEffectiveTarget(target: any, propertyPath: string): any;
  2793. /**
  2794. * Serialize placeholder for child classes
  2795. * @param parent of child
  2796. * @returns the serialized object
  2797. */
  2798. serialize(parent: any): any;
  2799. /**
  2800. * Internal only called by serialize
  2801. * @hidden
  2802. */
  2803. protected _serialize(serializedAction: any, parent?: any): any;
  2804. /**
  2805. * Internal only
  2806. * @hidden
  2807. */
  2808. static _SerializeValueAsString: (value: any) => string;
  2809. /**
  2810. * Internal only
  2811. * @hidden
  2812. */
  2813. static _GetTargetProperty: (target: Scene | Node) => {
  2814. name: string;
  2815. targetType: string;
  2816. value: string;
  2817. };
  2818. }
  2819. }
  2820. declare module BABYLON {
  2821. /**
  2822. * ActionEvent is the event being sent when an action is triggered.
  2823. */
  2824. class ActionEvent {
  2825. /** The mesh or sprite that triggered the action */
  2826. source: any;
  2827. /** The X mouse cursor position at the time of the event */
  2828. pointerX: number;
  2829. /** The Y mouse cursor position at the time of the event */
  2830. pointerY: number;
  2831. /** The mesh that is currently pointed at (can be null) */
  2832. meshUnderPointer: Nullable<AbstractMesh>;
  2833. /** the original (browser) event that triggered the ActionEvent */
  2834. sourceEvent?: any;
  2835. /** additional data for the event */
  2836. additionalData?: any;
  2837. /**
  2838. * Creates a new ActionEvent
  2839. * @param source The mesh or sprite that triggered the action
  2840. * @param pointerX The X mouse cursor position at the time of the event
  2841. * @param pointerY The Y mouse cursor position at the time of the event
  2842. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2843. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2844. * @param additionalData additional data for the event
  2845. */
  2846. constructor(
  2847. /** The mesh or sprite that triggered the action */
  2848. source: any,
  2849. /** The X mouse cursor position at the time of the event */
  2850. pointerX: number,
  2851. /** The Y mouse cursor position at the time of the event */
  2852. pointerY: number,
  2853. /** The mesh that is currently pointed at (can be null) */
  2854. meshUnderPointer: Nullable<AbstractMesh>,
  2855. /** the original (browser) event that triggered the ActionEvent */
  2856. sourceEvent?: any,
  2857. /** additional data for the event */
  2858. additionalData?: any);
  2859. /**
  2860. * Helper function to auto-create an ActionEvent from a source mesh.
  2861. * @param source The source mesh that triggered the event
  2862. * @param evt The original (browser) event
  2863. * @param additionalData additional data for the event
  2864. * @returns the new ActionEvent
  2865. */
  2866. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2867. /**
  2868. * Helper function to auto-create an ActionEvent from a source sprite
  2869. * @param source The source sprite that triggered the event
  2870. * @param scene Scene associated with the sprite
  2871. * @param evt The original (browser) event
  2872. * @param additionalData additional data for the event
  2873. * @returns the new ActionEvent
  2874. */
  2875. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2876. /**
  2877. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2878. * @param scene the scene where the event occurred
  2879. * @param evt The original (browser) event
  2880. * @returns the new ActionEvent
  2881. */
  2882. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2883. /**
  2884. * Helper function to auto-create an ActionEvent from a primitive
  2885. * @param prim defines the target primitive
  2886. * @param pointerPos defines the pointer position
  2887. * @param evt The original (browser) event
  2888. * @param additionalData additional data for the event
  2889. * @returns the new ActionEvent
  2890. */
  2891. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2892. }
  2893. /**
  2894. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2895. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2897. */
  2898. class ActionManager {
  2899. private static _NothingTrigger;
  2900. private static _OnPickTrigger;
  2901. private static _OnLeftPickTrigger;
  2902. private static _OnRightPickTrigger;
  2903. private static _OnCenterPickTrigger;
  2904. private static _OnPickDownTrigger;
  2905. private static _OnDoublePickTrigger;
  2906. private static _OnPickUpTrigger;
  2907. private static _OnLongPressTrigger;
  2908. private static _OnPointerOverTrigger;
  2909. private static _OnPointerOutTrigger;
  2910. private static _OnEveryFrameTrigger;
  2911. private static _OnIntersectionEnterTrigger;
  2912. private static _OnIntersectionExitTrigger;
  2913. private static _OnKeyDownTrigger;
  2914. private static _OnKeyUpTrigger;
  2915. private static _OnPickOutTrigger;
  2916. /**
  2917. * Nothing
  2918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2919. */
  2920. static readonly NothingTrigger: number;
  2921. /**
  2922. * On pick
  2923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2924. */
  2925. static readonly OnPickTrigger: number;
  2926. /**
  2927. * On left pick
  2928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2929. */
  2930. static readonly OnLeftPickTrigger: number;
  2931. /**
  2932. * On right pick
  2933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2934. */
  2935. static readonly OnRightPickTrigger: number;
  2936. /**
  2937. * On center pick
  2938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2939. */
  2940. static readonly OnCenterPickTrigger: number;
  2941. /**
  2942. * On pick down
  2943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2944. */
  2945. static readonly OnPickDownTrigger: number;
  2946. /**
  2947. * On double pick
  2948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2949. */
  2950. static readonly OnDoublePickTrigger: number;
  2951. /**
  2952. * On pick up
  2953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2954. */
  2955. static readonly OnPickUpTrigger: number;
  2956. /**
  2957. * On pick out.
  2958. * This trigger will only be raised if you also declared a OnPickDown
  2959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2960. */
  2961. static readonly OnPickOutTrigger: number;
  2962. /**
  2963. * On long press
  2964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2965. */
  2966. static readonly OnLongPressTrigger: number;
  2967. /**
  2968. * On pointer over
  2969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2970. */
  2971. static readonly OnPointerOverTrigger: number;
  2972. /**
  2973. * On pointer out
  2974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2975. */
  2976. static readonly OnPointerOutTrigger: number;
  2977. /**
  2978. * On every frame
  2979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2980. */
  2981. static readonly OnEveryFrameTrigger: number;
  2982. /**
  2983. * On intersection enter
  2984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2985. */
  2986. static readonly OnIntersectionEnterTrigger: number;
  2987. /**
  2988. * On intersection exit
  2989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2990. */
  2991. static readonly OnIntersectionExitTrigger: number;
  2992. /**
  2993. * On key down
  2994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2995. */
  2996. static readonly OnKeyDownTrigger: number;
  2997. /**
  2998. * On key up
  2999. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3000. */
  3001. static readonly OnKeyUpTrigger: number;
  3002. /** Gets the list of active triggers */
  3003. static Triggers: {
  3004. [key: string]: number;
  3005. };
  3006. /** Gets the list of actions */
  3007. actions: Action[];
  3008. /** Gets the cursor to use when hovering items */
  3009. hoverCursor: string;
  3010. private _scene;
  3011. /**
  3012. * Creates a new action manager
  3013. * @param scene defines the hosting scene
  3014. */
  3015. constructor(scene: Scene);
  3016. /**
  3017. * Releases all associated resources
  3018. */
  3019. dispose(): void;
  3020. /**
  3021. * Gets hosting scene
  3022. * @returns the hosting scene
  3023. */
  3024. getScene(): Scene;
  3025. /**
  3026. * Does this action manager handles actions of any of the given triggers
  3027. * @param triggers defines the triggers to be tested
  3028. * @return a boolean indicating whether one (or more) of the triggers is handled
  3029. */
  3030. hasSpecificTriggers(triggers: number[]): boolean;
  3031. /**
  3032. * Does this action manager handles actions of a given trigger
  3033. * @param trigger defines the trigger to be tested
  3034. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3035. * @return whether the trigger is handled
  3036. */
  3037. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3038. /**
  3039. * Does this action manager has pointer triggers
  3040. */
  3041. readonly hasPointerTriggers: boolean;
  3042. /**
  3043. * Does this action manager has pick triggers
  3044. */
  3045. readonly hasPickTriggers: boolean;
  3046. /**
  3047. * Does exist one action manager with at least one trigger
  3048. **/
  3049. static readonly HasTriggers: boolean;
  3050. /**
  3051. * Does exist one action manager with at least one pick trigger
  3052. **/
  3053. static readonly HasPickTriggers: boolean;
  3054. /**
  3055. * Does exist one action manager that handles actions of a given trigger
  3056. * @param trigger defines the trigger to be tested
  3057. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3058. **/
  3059. static HasSpecificTrigger(trigger: number): boolean;
  3060. /**
  3061. * Registers an action to this action manager
  3062. * @param action defines the action to be registered
  3063. * @return the action amended (prepared) after registration
  3064. */
  3065. registerAction(action: Action): Nullable<Action>;
  3066. /**
  3067. * Unregisters an action to this action manager
  3068. * @param action defines the action to be unregistered
  3069. * @return a boolean indicating whether the action has been unregistered
  3070. */
  3071. unregisterAction(action: Action): Boolean;
  3072. /**
  3073. * Process a specific trigger
  3074. * @param trigger defines the trigger to process
  3075. * @param evt defines the event details to be processed
  3076. */
  3077. processTrigger(trigger: number, evt?: ActionEvent): void;
  3078. /** @hidden */
  3079. _getEffectiveTarget(target: any, propertyPath: string): any;
  3080. /** @hidden */
  3081. _getProperty(propertyPath: string): string;
  3082. /**
  3083. * Serialize this manager to a JSON object
  3084. * @param name defines the property name to store this manager
  3085. * @returns a JSON representation of this manager
  3086. */
  3087. serialize(name: string): any;
  3088. /**
  3089. * Creates a new ActionManager from a JSON data
  3090. * @param parsedActions defines the JSON data to read from
  3091. * @param object defines the hosting mesh
  3092. * @param scene defines the hosting scene
  3093. */
  3094. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3095. /**
  3096. * Get a trigger name by index
  3097. * @param trigger defines the trigger index
  3098. * @returns a trigger name
  3099. */
  3100. static GetTriggerName(trigger: number): string;
  3101. }
  3102. }
  3103. declare module BABYLON {
  3104. /**
  3105. * A Condition applied to an Action
  3106. */
  3107. class Condition {
  3108. /**
  3109. * Internal only - manager for action
  3110. * @hidden
  3111. */
  3112. _actionManager: ActionManager;
  3113. /**
  3114. * Internal only
  3115. * @hidden
  3116. */
  3117. _evaluationId: number;
  3118. /**
  3119. * Internal only
  3120. * @hidden
  3121. */
  3122. _currentResult: boolean;
  3123. /**
  3124. * Creates a new Condition
  3125. * @param actionManager the manager of the action the condition is applied to
  3126. */
  3127. constructor(actionManager: ActionManager);
  3128. /**
  3129. * Check if the current condition is valid
  3130. * @returns a boolean
  3131. */
  3132. isValid(): boolean;
  3133. /**
  3134. * Internal only
  3135. * @hidden
  3136. */
  3137. _getProperty(propertyPath: string): string;
  3138. /**
  3139. * Internal only
  3140. * @hidden
  3141. */
  3142. _getEffectiveTarget(target: any, propertyPath: string): any;
  3143. /**
  3144. * Serialize placeholder for child classes
  3145. * @returns the serialized object
  3146. */
  3147. serialize(): any;
  3148. /**
  3149. * Internal only
  3150. * @hidden
  3151. */
  3152. protected _serialize(serializedCondition: any): any;
  3153. }
  3154. /**
  3155. * Defines specific conditional operators as extensions of Condition
  3156. */
  3157. class ValueCondition extends Condition {
  3158. /** path to specify the property of the target the conditional operator uses */
  3159. propertyPath: string;
  3160. /** the value compared by the conditional operator against the current value of the property */
  3161. value: any;
  3162. /** the conditional operator, default ValueCondition.IsEqual */
  3163. operator: number;
  3164. /**
  3165. * Internal only
  3166. * @hidden
  3167. */
  3168. private static _IsEqual;
  3169. /**
  3170. * Internal only
  3171. * @hidden
  3172. */
  3173. private static _IsDifferent;
  3174. /**
  3175. * Internal only
  3176. * @hidden
  3177. */
  3178. private static _IsGreater;
  3179. /**
  3180. * Internal only
  3181. * @hidden
  3182. */
  3183. private static _IsLesser;
  3184. /**
  3185. * returns the number for IsEqual
  3186. */
  3187. static readonly IsEqual: number;
  3188. /**
  3189. * Returns the number for IsDifferent
  3190. */
  3191. static readonly IsDifferent: number;
  3192. /**
  3193. * Returns the number for IsGreater
  3194. */
  3195. static readonly IsGreater: number;
  3196. /**
  3197. * Returns the number for IsLesser
  3198. */
  3199. static readonly IsLesser: number;
  3200. /**
  3201. * Internal only The action manager for the condition
  3202. * @hidden
  3203. */
  3204. _actionManager: ActionManager;
  3205. /**
  3206. * Internal only
  3207. * @hidden
  3208. */
  3209. private _target;
  3210. /**
  3211. * Internal only
  3212. * @hidden
  3213. */
  3214. private _effectiveTarget;
  3215. /**
  3216. * Internal only
  3217. * @hidden
  3218. */
  3219. private _property;
  3220. /**
  3221. * Creates a new ValueCondition
  3222. * @param actionManager manager for the action the condition applies to
  3223. * @param target for the action
  3224. * @param propertyPath path to specify the property of the target the conditional operator uses
  3225. * @param value the value compared by the conditional operator against the current value of the property
  3226. * @param operator the conditional operator, default ValueCondition.IsEqual
  3227. */
  3228. constructor(actionManager: ActionManager, target: any,
  3229. /** path to specify the property of the target the conditional operator uses */
  3230. propertyPath: string,
  3231. /** the value compared by the conditional operator against the current value of the property */
  3232. value: any,
  3233. /** the conditional operator, default ValueCondition.IsEqual */
  3234. operator?: number);
  3235. /**
  3236. * Compares the given value with the property value for the specified conditional operator
  3237. * @returns the result of the comparison
  3238. */
  3239. isValid(): boolean;
  3240. /**
  3241. * Serialize the ValueCondition into a JSON compatible object
  3242. * @returns serialization object
  3243. */
  3244. serialize(): any;
  3245. /**
  3246. * Gets the name of the conditional operator for the ValueCondition
  3247. * @param operator the conditional operator
  3248. * @returns the name
  3249. */
  3250. static GetOperatorName(operator: number): string;
  3251. }
  3252. /**
  3253. * Defines a predicate condition as an extension of Condition
  3254. */
  3255. class PredicateCondition extends Condition {
  3256. /** defines the predicate function used to validate the condition */
  3257. predicate: () => boolean;
  3258. /**
  3259. * Internal only - manager for action
  3260. * @hidden
  3261. */
  3262. _actionManager: ActionManager;
  3263. /**
  3264. * Creates a new PredicateCondition
  3265. * @param actionManager manager for the action the condition applies to
  3266. * @param predicate defines the predicate function used to validate the condition
  3267. */
  3268. constructor(actionManager: ActionManager,
  3269. /** defines the predicate function used to validate the condition */
  3270. predicate: () => boolean);
  3271. /**
  3272. * @returns the validity of the predicate condition
  3273. */
  3274. isValid(): boolean;
  3275. }
  3276. /**
  3277. * Defines a state condition as an extension of Condition
  3278. */
  3279. class StateCondition extends Condition {
  3280. value: string;
  3281. /**
  3282. * Internal only - manager for action
  3283. * @hidden
  3284. */
  3285. _actionManager: ActionManager;
  3286. /**
  3287. * Internal only
  3288. * @hidden
  3289. */
  3290. private _target;
  3291. /**
  3292. * Creates a new StateCondition
  3293. * @param actionManager manager for the action the condition applies to
  3294. * @param target of the condition
  3295. * @param value to compare with target state
  3296. */
  3297. constructor(actionManager: ActionManager, target: any, value: string);
  3298. /**
  3299. * @returns the validity of the state
  3300. */
  3301. isValid(): boolean;
  3302. /**
  3303. * Serialize the StateCondition into a JSON compatible object
  3304. * @returns serialization object
  3305. */
  3306. serialize(): any;
  3307. }
  3308. }
  3309. declare module BABYLON {
  3310. class SwitchBooleanAction extends Action {
  3311. propertyPath: string;
  3312. private _target;
  3313. private _effectiveTarget;
  3314. private _property;
  3315. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3316. /** @hidden */
  3317. _prepare(): void;
  3318. execute(): void;
  3319. serialize(parent: any): any;
  3320. }
  3321. class SetStateAction extends Action {
  3322. value: string;
  3323. private _target;
  3324. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3325. execute(): void;
  3326. serialize(parent: any): any;
  3327. }
  3328. class SetValueAction extends Action {
  3329. propertyPath: string;
  3330. value: any;
  3331. private _target;
  3332. private _effectiveTarget;
  3333. private _property;
  3334. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3335. /** @hidden */
  3336. _prepare(): void;
  3337. execute(): void;
  3338. serialize(parent: any): any;
  3339. }
  3340. class IncrementValueAction extends Action {
  3341. propertyPath: string;
  3342. value: any;
  3343. private _target;
  3344. private _effectiveTarget;
  3345. private _property;
  3346. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3347. /** @hidden */
  3348. _prepare(): void;
  3349. execute(): void;
  3350. serialize(parent: any): any;
  3351. }
  3352. class PlayAnimationAction extends Action {
  3353. from: number;
  3354. to: number;
  3355. loop?: boolean | undefined;
  3356. private _target;
  3357. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3358. /** @hidden */
  3359. _prepare(): void;
  3360. execute(): void;
  3361. serialize(parent: any): any;
  3362. }
  3363. class StopAnimationAction extends Action {
  3364. private _target;
  3365. constructor(triggerOptions: any, target: any, condition?: Condition);
  3366. /** @hidden */
  3367. _prepare(): void;
  3368. execute(): void;
  3369. serialize(parent: any): any;
  3370. }
  3371. class DoNothingAction extends Action {
  3372. constructor(triggerOptions?: any, condition?: Condition);
  3373. execute(): void;
  3374. serialize(parent: any): any;
  3375. }
  3376. class CombineAction extends Action {
  3377. children: Action[];
  3378. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3379. /** @hidden */
  3380. _prepare(): void;
  3381. execute(evt: ActionEvent): void;
  3382. serialize(parent: any): any;
  3383. }
  3384. class ExecuteCodeAction extends Action {
  3385. func: (evt: ActionEvent) => void;
  3386. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3387. execute(evt: ActionEvent): void;
  3388. }
  3389. class SetParentAction extends Action {
  3390. private _parent;
  3391. private _target;
  3392. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3393. /** @hidden */
  3394. _prepare(): void;
  3395. execute(): void;
  3396. serialize(parent: any): any;
  3397. }
  3398. class PlaySoundAction extends Action {
  3399. private _sound;
  3400. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3401. /** @hidden */
  3402. _prepare(): void;
  3403. execute(): void;
  3404. serialize(parent: any): any;
  3405. }
  3406. class StopSoundAction extends Action {
  3407. private _sound;
  3408. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3409. /** @hidden */
  3410. _prepare(): void;
  3411. execute(): void;
  3412. serialize(parent: any): any;
  3413. }
  3414. }
  3415. declare module BABYLON {
  3416. class InterpolateValueAction extends Action {
  3417. propertyPath: string;
  3418. value: any;
  3419. duration: number;
  3420. stopOtherAnimations?: boolean | undefined;
  3421. onInterpolationDone?: (() => void) | undefined;
  3422. private _target;
  3423. private _effectiveTarget;
  3424. private _property;
  3425. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3426. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3427. /** @hidden */
  3428. _prepare(): void;
  3429. execute(): void;
  3430. serialize(parent: any): any;
  3431. }
  3432. }
  3433. declare module BABYLON {
  3434. /**
  3435. * Class used to store an actual running animation
  3436. */
  3437. class Animatable {
  3438. /** defines the target object */
  3439. target: any;
  3440. /** defines the starting frame number (default is 0) */
  3441. fromFrame: number;
  3442. /** defines the ending frame number (default is 100) */
  3443. toFrame: number;
  3444. /** defines if the animation must loop (default is false) */
  3445. loopAnimation: boolean;
  3446. /** defines a callback to call when animation ends if it is not looping */
  3447. onAnimationEnd?: (() => void) | null | undefined;
  3448. private _localDelayOffset;
  3449. private _pausedDelay;
  3450. private _runtimeAnimations;
  3451. private _paused;
  3452. private _scene;
  3453. private _speedRatio;
  3454. private _weight;
  3455. private _syncRoot;
  3456. /**
  3457. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3458. * This will only apply for non looping animation (default is true)
  3459. */
  3460. disposeOnEnd: boolean;
  3461. /**
  3462. * Gets a boolean indicating if the animation has started
  3463. */
  3464. animationStarted: boolean;
  3465. /**
  3466. * Observer raised when the animation ends
  3467. */
  3468. onAnimationEndObservable: Observable<Animatable>;
  3469. /**
  3470. * Gets the root Animatable used to synchronize and normalize animations
  3471. */
  3472. readonly syncRoot: Animatable;
  3473. /**
  3474. * Gets the current frame of the first RuntimeAnimation
  3475. * Used to synchronize Animatables
  3476. */
  3477. readonly masterFrame: number;
  3478. /**
  3479. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3480. */
  3481. weight: number;
  3482. /**
  3483. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3484. */
  3485. speedRatio: number;
  3486. /**
  3487. * Creates a new Animatable
  3488. * @param scene defines the hosting scene
  3489. * @param target defines the target object
  3490. * @param fromFrame defines the starting frame number (default is 0)
  3491. * @param toFrame defines the ending frame number (default is 100)
  3492. * @param loopAnimation defines if the animation must loop (default is false)
  3493. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3494. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3495. * @param animations defines a group of animation to add to the new Animatable
  3496. */
  3497. constructor(scene: Scene,
  3498. /** defines the target object */
  3499. target: any,
  3500. /** defines the starting frame number (default is 0) */
  3501. fromFrame?: number,
  3502. /** defines the ending frame number (default is 100) */
  3503. toFrame?: number,
  3504. /** defines if the animation must loop (default is false) */
  3505. loopAnimation?: boolean, speedRatio?: number,
  3506. /** defines a callback to call when animation ends if it is not looping */
  3507. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3508. /**
  3509. * Synchronize and normalize current Animatable with a source Animatable
  3510. * This is useful when using animation weights and when animations are not of the same length
  3511. * @param root defines the root Animatable to synchronize with
  3512. * @returns the current Animatable
  3513. */
  3514. syncWith(root: Animatable): Animatable;
  3515. /**
  3516. * Gets the list of runtime animations
  3517. * @returns an array of RuntimeAnimation
  3518. */
  3519. getAnimations(): RuntimeAnimation[];
  3520. /**
  3521. * Adds more animations to the current animatable
  3522. * @param target defines the target of the animations
  3523. * @param animations defines the new animations to add
  3524. */
  3525. appendAnimations(target: any, animations: Animation[]): void;
  3526. /**
  3527. * Gets the source animation for a specific property
  3528. * @param property defines the propertyu to look for
  3529. * @returns null or the source animation for the given property
  3530. */
  3531. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3532. /**
  3533. * Gets the runtime animation for a specific property
  3534. * @param property defines the propertyu to look for
  3535. * @returns null or the runtime animation for the given property
  3536. */
  3537. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3538. /**
  3539. * Resets the animatable to its original state
  3540. */
  3541. reset(): void;
  3542. /**
  3543. * Allows the animatable to blend with current running animations
  3544. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3545. * @param blendingSpeed defines the blending speed to use
  3546. */
  3547. enableBlending(blendingSpeed: number): void;
  3548. /**
  3549. * Disable animation blending
  3550. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3551. */
  3552. disableBlending(): void;
  3553. /**
  3554. * Jump directly to a given frame
  3555. * @param frame defines the frame to jump to
  3556. */
  3557. goToFrame(frame: number): void;
  3558. /**
  3559. * Pause the animation
  3560. */
  3561. pause(): void;
  3562. /**
  3563. * Restart the animation
  3564. */
  3565. restart(): void;
  3566. private _raiseOnAnimationEnd;
  3567. /**
  3568. * Stop and delete the current animation
  3569. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3570. * @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)
  3571. */
  3572. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3573. /**
  3574. * Wait asynchronously for the animation to end
  3575. * @returns a promise which will be fullfilled when the animation ends
  3576. */
  3577. waitAsync(): Promise<Animatable>;
  3578. /** @hidden */
  3579. _animate(delay: number): boolean;
  3580. }
  3581. }
  3582. declare module BABYLON {
  3583. /**
  3584. * Represents the range of an animation
  3585. */
  3586. class AnimationRange {
  3587. /**The name of the animation range**/
  3588. name: string;
  3589. /**The starting frame of the animation */
  3590. from: number;
  3591. /**The ending frame of the animation*/
  3592. to: number;
  3593. /**
  3594. * Initializes the range of an animation
  3595. * @param name The name of the animation range
  3596. * @param from The starting frame of the animation
  3597. * @param to The ending frame of the animation
  3598. */
  3599. constructor(
  3600. /**The name of the animation range**/
  3601. name: string,
  3602. /**The starting frame of the animation */
  3603. from: number,
  3604. /**The ending frame of the animation*/
  3605. to: number);
  3606. /**
  3607. * Makes a copy of the animation range
  3608. * @returns A copy of the animation range
  3609. */
  3610. clone(): AnimationRange;
  3611. }
  3612. /**
  3613. * Composed of a frame, and an action function
  3614. */
  3615. class AnimationEvent {
  3616. /** The frame for which the event is triggered **/
  3617. frame: number;
  3618. /** The event to perform when triggered **/
  3619. action: (currentFrame: number) => void;
  3620. /** Specifies if the event should be triggered only once**/
  3621. onlyOnce?: boolean | undefined;
  3622. /**
  3623. * Specifies if the animation event is done
  3624. */
  3625. isDone: boolean;
  3626. /**
  3627. * Initializes the animation event
  3628. * @param frame The frame for which the event is triggered
  3629. * @param action The event to perform when triggered
  3630. * @param onlyOnce Specifies if the event should be triggered only once
  3631. */
  3632. constructor(
  3633. /** The frame for which the event is triggered **/
  3634. frame: number,
  3635. /** The event to perform when triggered **/
  3636. action: (currentFrame: number) => void,
  3637. /** Specifies if the event should be triggered only once**/
  3638. onlyOnce?: boolean | undefined);
  3639. /** @hidden */
  3640. _clone(): AnimationEvent;
  3641. }
  3642. /**
  3643. * A cursor which tracks a point on a path
  3644. */
  3645. class PathCursor {
  3646. private path;
  3647. /**
  3648. * Stores path cursor callbacks for when an onchange event is triggered
  3649. */
  3650. private _onchange;
  3651. /**
  3652. * The value of the path cursor
  3653. */
  3654. value: number;
  3655. /**
  3656. * The animation array of the path cursor
  3657. */
  3658. animations: Animation[];
  3659. /**
  3660. * Initializes the path cursor
  3661. * @param path The path to track
  3662. */
  3663. constructor(path: Path2);
  3664. /**
  3665. * Gets the cursor point on the path
  3666. * @returns A point on the path cursor at the cursor location
  3667. */
  3668. getPoint(): Vector3;
  3669. /**
  3670. * Moves the cursor ahead by the step amount
  3671. * @param step The amount to move the cursor forward
  3672. * @returns This path cursor
  3673. */
  3674. moveAhead(step?: number): PathCursor;
  3675. /**
  3676. * Moves the cursor behind by the step amount
  3677. * @param step The amount to move the cursor back
  3678. * @returns This path cursor
  3679. */
  3680. moveBack(step?: number): PathCursor;
  3681. /**
  3682. * Moves the cursor by the step amount
  3683. * If the step amount is greater than one, an exception is thrown
  3684. * @param step The amount to move the cursor
  3685. * @returns This path cursor
  3686. */
  3687. move(step: number): PathCursor;
  3688. /**
  3689. * Ensures that the value is limited between zero and one
  3690. * @returns This path cursor
  3691. */
  3692. private ensureLimits;
  3693. /**
  3694. * Runs onchange callbacks on change (used by the animation engine)
  3695. * @returns This path cursor
  3696. */
  3697. private raiseOnChange;
  3698. /**
  3699. * Executes a function on change
  3700. * @param f A path cursor onchange callback
  3701. * @returns This path cursor
  3702. */
  3703. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3704. }
  3705. /**
  3706. * Defines an interface which represents an animation key frame
  3707. */
  3708. interface IAnimationKey {
  3709. /**
  3710. * Frame of the key frame
  3711. */
  3712. frame: number;
  3713. /**
  3714. * Value at the specifies key frame
  3715. */
  3716. value: any;
  3717. /**
  3718. * The input tangent for the cubic hermite spline
  3719. */
  3720. inTangent?: any;
  3721. /**
  3722. * The output tangent for the cubic hermite spline
  3723. */
  3724. outTangent?: any;
  3725. /**
  3726. * The animation interpolation type
  3727. */
  3728. interpolation?: AnimationKeyInterpolation;
  3729. }
  3730. /**
  3731. * Enum for the animation key frame interpolation type
  3732. */
  3733. enum AnimationKeyInterpolation {
  3734. /**
  3735. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3736. */
  3737. STEP = 1
  3738. }
  3739. /**
  3740. * Class used to store any kind of animation
  3741. */
  3742. class Animation {
  3743. /**Name of the animation */
  3744. name: string;
  3745. /**Property to animate */
  3746. targetProperty: string;
  3747. /**The frames per second of the animation */
  3748. framePerSecond: number;
  3749. /**The data type of the animation */
  3750. dataType: number;
  3751. /**The loop mode of the animation */
  3752. loopMode?: number | undefined;
  3753. /**Specifies if blending should be enabled */
  3754. enableBlending?: boolean | undefined;
  3755. /**
  3756. * Use matrix interpolation instead of using direct key value when animating matrices
  3757. */
  3758. static AllowMatricesInterpolation: boolean;
  3759. /**
  3760. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3761. */
  3762. static AllowMatrixDecomposeForInterpolation: boolean;
  3763. /**
  3764. * Stores the key frames of the animation
  3765. */
  3766. private _keys;
  3767. /**
  3768. * Stores the easing function of the animation
  3769. */
  3770. private _easingFunction;
  3771. /**
  3772. * @hidden Internal use only
  3773. */
  3774. _runtimeAnimations: RuntimeAnimation[];
  3775. /**
  3776. * The set of event that will be linked to this animation
  3777. */
  3778. private _events;
  3779. /**
  3780. * Stores an array of target property paths
  3781. */
  3782. targetPropertyPath: string[];
  3783. /**
  3784. * Stores the blending speed of the animation
  3785. */
  3786. blendingSpeed: number;
  3787. /**
  3788. * Stores the animation ranges for the animation
  3789. */
  3790. private _ranges;
  3791. /**
  3792. * @hidden Internal use
  3793. */
  3794. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3795. /**
  3796. * Sets up an animation
  3797. * @param property The property to animate
  3798. * @param animationType The animation type to apply
  3799. * @param framePerSecond The frames per second of the animation
  3800. * @param easingFunction The easing function used in the animation
  3801. * @returns The created animation
  3802. */
  3803. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3804. /**
  3805. * Create and start an animation on a node
  3806. * @param name defines the name of the global animation that will be run on all nodes
  3807. * @param node defines the root node where the animation will take place
  3808. * @param targetProperty defines property to animate
  3809. * @param framePerSecond defines the number of frame per second yo use
  3810. * @param totalFrame defines the number of frames in total
  3811. * @param from defines the initial value
  3812. * @param to defines the final value
  3813. * @param loopMode defines which loop mode you want to use (off by default)
  3814. * @param easingFunction defines the easing function to use (linear by default)
  3815. * @param onAnimationEnd defines the callback to call when animation end
  3816. * @returns the animatable created for this animation
  3817. */
  3818. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3819. /**
  3820. * Create and start an animation on a node and its descendants
  3821. * @param name defines the name of the global animation that will be run on all nodes
  3822. * @param node defines the root node where the animation will take place
  3823. * @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
  3824. * @param targetProperty defines property to animate
  3825. * @param framePerSecond defines the number of frame per second to use
  3826. * @param totalFrame defines the number of frames in total
  3827. * @param from defines the initial value
  3828. * @param to defines the final value
  3829. * @param loopMode defines which loop mode you want to use (off by default)
  3830. * @param easingFunction defines the easing function to use (linear by default)
  3831. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3832. * @returns the list of animatables created for all nodes
  3833. * @example https://www.babylonjs-playground.com/#MH0VLI
  3834. */
  3835. 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[]>;
  3836. /**
  3837. * Creates a new animation, merges it with the existing animations and starts it
  3838. * @param name Name of the animation
  3839. * @param node Node which contains the scene that begins the animations
  3840. * @param targetProperty Specifies which property to animate
  3841. * @param framePerSecond The frames per second of the animation
  3842. * @param totalFrame The total number of frames
  3843. * @param from The frame at the beginning of the animation
  3844. * @param to The frame at the end of the animation
  3845. * @param loopMode Specifies the loop mode of the animation
  3846. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3847. * @param onAnimationEnd Callback to run once the animation is complete
  3848. * @returns Nullable animation
  3849. */
  3850. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3851. /**
  3852. * Transition property of an host to the target Value
  3853. * @param property The property to transition
  3854. * @param targetValue The target Value of the property
  3855. * @param host The object where the property to animate belongs
  3856. * @param scene Scene used to run the animation
  3857. * @param frameRate Framerate (in frame/s) to use
  3858. * @param transition The transition type we want to use
  3859. * @param duration The duration of the animation, in milliseconds
  3860. * @param onAnimationEnd Callback trigger at the end of the animation
  3861. * @returns Nullable animation
  3862. */
  3863. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3864. /**
  3865. * Return the array of runtime animations currently using this animation
  3866. */
  3867. readonly runtimeAnimations: RuntimeAnimation[];
  3868. /**
  3869. * Specifies if any of the runtime animations are currently running
  3870. */
  3871. readonly hasRunningRuntimeAnimations: boolean;
  3872. /**
  3873. * Initializes the animation
  3874. * @param name Name of the animation
  3875. * @param targetProperty Property to animate
  3876. * @param framePerSecond The frames per second of the animation
  3877. * @param dataType The data type of the animation
  3878. * @param loopMode The loop mode of the animation
  3879. * @param enableBlendings Specifies if blending should be enabled
  3880. */
  3881. constructor(
  3882. /**Name of the animation */
  3883. name: string,
  3884. /**Property to animate */
  3885. targetProperty: string,
  3886. /**The frames per second of the animation */
  3887. framePerSecond: number,
  3888. /**The data type of the animation */
  3889. dataType: number,
  3890. /**The loop mode of the animation */
  3891. loopMode?: number | undefined,
  3892. /**Specifies if blending should be enabled */
  3893. enableBlending?: boolean | undefined);
  3894. /**
  3895. * Converts the animation to a string
  3896. * @param fullDetails support for multiple levels of logging within scene loading
  3897. * @returns String form of the animation
  3898. */
  3899. toString(fullDetails?: boolean): string;
  3900. /**
  3901. * Add an event to this animation
  3902. * @param event Event to add
  3903. */
  3904. addEvent(event: AnimationEvent): void;
  3905. /**
  3906. * Remove all events found at the given frame
  3907. * @param frame The frame to remove events from
  3908. */
  3909. removeEvents(frame: number): void;
  3910. /**
  3911. * Retrieves all the events from the animation
  3912. * @returns Events from the animation
  3913. */
  3914. getEvents(): AnimationEvent[];
  3915. /**
  3916. * Creates an animation range
  3917. * @param name Name of the animation range
  3918. * @param from Starting frame of the animation range
  3919. * @param to Ending frame of the animation
  3920. */
  3921. createRange(name: string, from: number, to: number): void;
  3922. /**
  3923. * Deletes an animation range by name
  3924. * @param name Name of the animation range to delete
  3925. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3926. */
  3927. deleteRange(name: string, deleteFrames?: boolean): void;
  3928. /**
  3929. * Gets the animation range by name, or null if not defined
  3930. * @param name Name of the animation range
  3931. * @returns Nullable animation range
  3932. */
  3933. getRange(name: string): Nullable<AnimationRange>;
  3934. /**
  3935. * Gets the key frames from the animation
  3936. * @returns The key frames of the animation
  3937. */
  3938. getKeys(): Array<IAnimationKey>;
  3939. /**
  3940. * Gets the highest frame rate of the animation
  3941. * @returns Highest frame rate of the animation
  3942. */
  3943. getHighestFrame(): number;
  3944. /**
  3945. * Gets the easing function of the animation
  3946. * @returns Easing function of the animation
  3947. */
  3948. getEasingFunction(): IEasingFunction;
  3949. /**
  3950. * Sets the easing function of the animation
  3951. * @param easingFunction A custom mathematical formula for animation
  3952. */
  3953. setEasingFunction(easingFunction: EasingFunction): void;
  3954. /**
  3955. * Interpolates a scalar linearly
  3956. * @param startValue Start value of the animation curve
  3957. * @param endValue End value of the animation curve
  3958. * @param gradient Scalar amount to interpolate
  3959. * @returns Interpolated scalar value
  3960. */
  3961. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3962. /**
  3963. * Interpolates a scalar cubically
  3964. * @param startValue Start value of the animation curve
  3965. * @param outTangent End tangent of the animation
  3966. * @param endValue End value of the animation curve
  3967. * @param inTangent Start tangent of the animation curve
  3968. * @param gradient Scalar amount to interpolate
  3969. * @returns Interpolated scalar value
  3970. */
  3971. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3972. /**
  3973. * Interpolates a quaternion using a spherical linear interpolation
  3974. * @param startValue Start value of the animation curve
  3975. * @param endValue End value of the animation curve
  3976. * @param gradient Scalar amount to interpolate
  3977. * @returns Interpolated quaternion value
  3978. */
  3979. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3980. /**
  3981. * Interpolates a quaternion cubically
  3982. * @param startValue Start value of the animation curve
  3983. * @param outTangent End tangent of the animation curve
  3984. * @param endValue End value of the animation curve
  3985. * @param inTangent Start tangent of the animation curve
  3986. * @param gradient Scalar amount to interpolate
  3987. * @returns Interpolated quaternion value
  3988. */
  3989. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3990. /**
  3991. * Interpolates a Vector3 linearl
  3992. * @param startValue Start value of the animation curve
  3993. * @param endValue End value of the animation curve
  3994. * @param gradient Scalar amount to interpolate
  3995. * @returns Interpolated scalar value
  3996. */
  3997. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3998. /**
  3999. * Interpolates a Vector3 cubically
  4000. * @param startValue Start value of the animation curve
  4001. * @param outTangent End tangent of the animation
  4002. * @param endValue End value of the animation curve
  4003. * @param inTangent Start tangent of the animation curve
  4004. * @param gradient Scalar amount to interpolate
  4005. * @returns InterpolatedVector3 value
  4006. */
  4007. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4008. /**
  4009. * Interpolates a Vector2 linearly
  4010. * @param startValue Start value of the animation curve
  4011. * @param endValue End value of the animation curve
  4012. * @param gradient Scalar amount to interpolate
  4013. * @returns Interpolated Vector2 value
  4014. */
  4015. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4016. /**
  4017. * Interpolates a Vector2 cubically
  4018. * @param startValue Start value of the animation curve
  4019. * @param outTangent End tangent of the animation
  4020. * @param endValue End value of the animation curve
  4021. * @param inTangent Start tangent of the animation curve
  4022. * @param gradient Scalar amount to interpolate
  4023. * @returns Interpolated Vector2 value
  4024. */
  4025. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4026. /**
  4027. * Interpolates a size linearly
  4028. * @param startValue Start value of the animation curve
  4029. * @param endValue End value of the animation curve
  4030. * @param gradient Scalar amount to interpolate
  4031. * @returns Interpolated Size value
  4032. */
  4033. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4034. /**
  4035. * Interpolates a Color3 linearly
  4036. * @param startValue Start value of the animation curve
  4037. * @param endValue End value of the animation curve
  4038. * @param gradient Scalar amount to interpolate
  4039. * @returns Interpolated Color3 value
  4040. */
  4041. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4042. /**
  4043. * @hidden Internal use only
  4044. */
  4045. _getKeyValue(value: any): any;
  4046. /**
  4047. * @hidden Internal use only
  4048. */
  4049. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4050. /**
  4051. * Defines the function to use to interpolate matrices
  4052. * @param startValue defines the start matrix
  4053. * @param endValue defines the end matrix
  4054. * @param gradient defines the gradient between both matrices
  4055. * @param result defines an optional target matrix where to store the interpolation
  4056. * @returns the interpolated matrix
  4057. */
  4058. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4059. /**
  4060. * Makes a copy of the animation
  4061. * @returns Cloned animation
  4062. */
  4063. clone(): Animation;
  4064. /**
  4065. * Sets the key frames of the animation
  4066. * @param values The animation key frames to set
  4067. */
  4068. setKeys(values: Array<IAnimationKey>): void;
  4069. /**
  4070. * Serializes the animation to an object
  4071. * @returns Serialized object
  4072. */
  4073. serialize(): any;
  4074. /**
  4075. * Float animation type
  4076. */
  4077. private static _ANIMATIONTYPE_FLOAT;
  4078. /**
  4079. * Vector3 animation type
  4080. */
  4081. private static _ANIMATIONTYPE_VECTOR3;
  4082. /**
  4083. * Quaternion animation type
  4084. */
  4085. private static _ANIMATIONTYPE_QUATERNION;
  4086. /**
  4087. * Matrix animation type
  4088. */
  4089. private static _ANIMATIONTYPE_MATRIX;
  4090. /**
  4091. * Color3 animation type
  4092. */
  4093. private static _ANIMATIONTYPE_COLOR3;
  4094. /**
  4095. * Vector2 animation type
  4096. */
  4097. private static _ANIMATIONTYPE_VECTOR2;
  4098. /**
  4099. * Size animation type
  4100. */
  4101. private static _ANIMATIONTYPE_SIZE;
  4102. /**
  4103. * Relative Loop Mode
  4104. */
  4105. private static _ANIMATIONLOOPMODE_RELATIVE;
  4106. /**
  4107. * Cycle Loop Mode
  4108. */
  4109. private static _ANIMATIONLOOPMODE_CYCLE;
  4110. /**
  4111. * Constant Loop Mode
  4112. */
  4113. private static _ANIMATIONLOOPMODE_CONSTANT;
  4114. /**
  4115. * Get the float animation type
  4116. */
  4117. static readonly ANIMATIONTYPE_FLOAT: number;
  4118. /**
  4119. * Get the Vector3 animation type
  4120. */
  4121. static readonly ANIMATIONTYPE_VECTOR3: number;
  4122. /**
  4123. * Get the Vector2 animation type
  4124. */
  4125. static readonly ANIMATIONTYPE_VECTOR2: number;
  4126. /**
  4127. * Get the Size animation type
  4128. */
  4129. static readonly ANIMATIONTYPE_SIZE: number;
  4130. /**
  4131. * Get the Quaternion animation type
  4132. */
  4133. static readonly ANIMATIONTYPE_QUATERNION: number;
  4134. /**
  4135. * Get the Matrix animation type
  4136. */
  4137. static readonly ANIMATIONTYPE_MATRIX: number;
  4138. /**
  4139. * Get the Color3 animation type
  4140. */
  4141. static readonly ANIMATIONTYPE_COLOR3: number;
  4142. /**
  4143. * Get the Relative Loop Mode
  4144. */
  4145. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4146. /**
  4147. * Get the Cycle Loop Mode
  4148. */
  4149. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4150. /**
  4151. * Get the Constant Loop Mode
  4152. */
  4153. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4154. /** @hidden */
  4155. static _UniversalLerp(left: any, right: any, amount: number): any;
  4156. /**
  4157. * Parses an animation object and creates an animation
  4158. * @param parsedAnimation Parsed animation object
  4159. * @returns Animation object
  4160. */
  4161. static Parse(parsedAnimation: any): Animation;
  4162. /**
  4163. * Appends the serialized animations from the source animations
  4164. * @param source Source containing the animations
  4165. * @param destination Target to store the animations
  4166. */
  4167. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4168. }
  4169. }
  4170. declare module BABYLON {
  4171. /**
  4172. * This class defines the direct association between an animation and a target
  4173. */
  4174. class TargetedAnimation {
  4175. animation: Animation;
  4176. target: any;
  4177. }
  4178. /**
  4179. * Use this class to create coordinated animations on multiple targets
  4180. */
  4181. class AnimationGroup implements IDisposable {
  4182. name: string;
  4183. private _scene;
  4184. private _targetedAnimations;
  4185. private _animatables;
  4186. private _from;
  4187. private _to;
  4188. private _isStarted;
  4189. private _speedRatio;
  4190. onAnimationEndObservable: Observable<TargetedAnimation>;
  4191. /**
  4192. * This observable will notify when all animations have ended.
  4193. */
  4194. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4195. /**
  4196. * This observable will notify when all animations have paused.
  4197. */
  4198. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4199. /**
  4200. * Gets the first frame
  4201. */
  4202. readonly from: number;
  4203. /**
  4204. * Gets the last frame
  4205. */
  4206. readonly to: number;
  4207. /**
  4208. * Define if the animations are started
  4209. */
  4210. readonly isStarted: boolean;
  4211. /**
  4212. * Gets or sets the speed ratio to use for all animations
  4213. */
  4214. /**
  4215. * Gets or sets the speed ratio to use for all animations
  4216. */
  4217. speedRatio: number;
  4218. /**
  4219. * Gets the targeted animations for this animation group
  4220. */
  4221. readonly targetedAnimations: Array<TargetedAnimation>;
  4222. /**
  4223. * returning the list of animatables controlled by this animation group.
  4224. */
  4225. readonly animatables: Array<Animatable>;
  4226. constructor(name: string, scene?: Nullable<Scene>);
  4227. /**
  4228. * Add an animation (with its target) in the group
  4229. * @param animation defines the animation we want to add
  4230. * @param target defines the target of the animation
  4231. * @returns the {BABYLON.TargetedAnimation} object
  4232. */
  4233. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4234. /**
  4235. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4236. * It can add constant keys at begin or end
  4237. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4238. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4239. */
  4240. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4241. /**
  4242. * Start all animations on given targets
  4243. * @param loop defines if animations must loop
  4244. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4245. * @param from defines the from key (optional)
  4246. * @param to defines the to key (optional)
  4247. * @returns the current animation group
  4248. */
  4249. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4250. /**
  4251. * Pause all animations
  4252. */
  4253. pause(): AnimationGroup;
  4254. /**
  4255. * Play all animations to initial state
  4256. * This function will start() the animations if they were not started or will restart() them if they were paused
  4257. * @param loop defines if animations must loop
  4258. */
  4259. play(loop?: boolean): AnimationGroup;
  4260. /**
  4261. * Reset all animations to initial state
  4262. */
  4263. reset(): AnimationGroup;
  4264. /**
  4265. * Restart animations from key 0
  4266. */
  4267. restart(): AnimationGroup;
  4268. /**
  4269. * Stop all animations
  4270. */
  4271. stop(): AnimationGroup;
  4272. /**
  4273. * Set animation weight for all animatables
  4274. * @param weight defines the weight to use
  4275. * @return the animationGroup
  4276. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4277. */
  4278. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4279. /**
  4280. * Synchronize and normalize all animatables with a source animatable
  4281. * @param root defines the root animatable to synchronize with
  4282. * @return the animationGroup
  4283. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4284. */
  4285. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4286. /**
  4287. * Goes to a specific frame in this animation group
  4288. * @param frame the frame number to go to
  4289. * @return the animationGroup
  4290. */
  4291. goToFrame(frame: number): AnimationGroup;
  4292. /**
  4293. * Dispose all associated resources
  4294. */
  4295. dispose(): void;
  4296. private _checkAnimationGroupEnded;
  4297. }
  4298. }
  4299. declare module BABYLON {
  4300. /**
  4301. * Class used to override all child animations of a given target
  4302. */
  4303. class AnimationPropertiesOverride {
  4304. /**
  4305. * Gets or sets a value indicating if animation blending must be used
  4306. */
  4307. enableBlending: boolean;
  4308. /**
  4309. * Gets or sets the blending speed to use when enableBlending is true
  4310. */
  4311. blendingSpeed: number;
  4312. /**
  4313. * Gets or sets the default loop mode to use
  4314. */
  4315. loopMode: number;
  4316. }
  4317. }
  4318. declare module BABYLON {
  4319. interface IEasingFunction {
  4320. ease(gradient: number): number;
  4321. }
  4322. class EasingFunction implements IEasingFunction {
  4323. private static _EASINGMODE_EASEIN;
  4324. private static _EASINGMODE_EASEOUT;
  4325. private static _EASINGMODE_EASEINOUT;
  4326. static readonly EASINGMODE_EASEIN: number;
  4327. static readonly EASINGMODE_EASEOUT: number;
  4328. static readonly EASINGMODE_EASEINOUT: number;
  4329. private _easingMode;
  4330. setEasingMode(easingMode: number): void;
  4331. getEasingMode(): number;
  4332. easeInCore(gradient: number): number;
  4333. ease(gradient: number): number;
  4334. }
  4335. class CircleEase extends EasingFunction implements IEasingFunction {
  4336. easeInCore(gradient: number): number;
  4337. }
  4338. class BackEase extends EasingFunction implements IEasingFunction {
  4339. amplitude: number;
  4340. constructor(amplitude?: number);
  4341. easeInCore(gradient: number): number;
  4342. }
  4343. class BounceEase extends EasingFunction implements IEasingFunction {
  4344. bounces: number;
  4345. bounciness: number;
  4346. constructor(bounces?: number, bounciness?: number);
  4347. easeInCore(gradient: number): number;
  4348. }
  4349. class CubicEase extends EasingFunction implements IEasingFunction {
  4350. easeInCore(gradient: number): number;
  4351. }
  4352. class ElasticEase extends EasingFunction implements IEasingFunction {
  4353. oscillations: number;
  4354. springiness: number;
  4355. constructor(oscillations?: number, springiness?: number);
  4356. easeInCore(gradient: number): number;
  4357. }
  4358. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4359. exponent: number;
  4360. constructor(exponent?: number);
  4361. easeInCore(gradient: number): number;
  4362. }
  4363. class PowerEase extends EasingFunction implements IEasingFunction {
  4364. power: number;
  4365. constructor(power?: number);
  4366. easeInCore(gradient: number): number;
  4367. }
  4368. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4369. easeInCore(gradient: number): number;
  4370. }
  4371. class QuarticEase extends EasingFunction implements IEasingFunction {
  4372. easeInCore(gradient: number): number;
  4373. }
  4374. class QuinticEase extends EasingFunction implements IEasingFunction {
  4375. easeInCore(gradient: number): number;
  4376. }
  4377. class SineEase extends EasingFunction implements IEasingFunction {
  4378. easeInCore(gradient: number): number;
  4379. }
  4380. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4381. x1: number;
  4382. y1: number;
  4383. x2: number;
  4384. y2: number;
  4385. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4386. easeInCore(gradient: number): number;
  4387. }
  4388. }
  4389. declare module BABYLON {
  4390. /**
  4391. * Defines a runtime animation
  4392. */
  4393. class RuntimeAnimation {
  4394. private _events;
  4395. /**
  4396. * The current frame of the runtime animation
  4397. */
  4398. private _currentFrame;
  4399. /**
  4400. * The animation used by the runtime animation
  4401. */
  4402. private _animation;
  4403. /**
  4404. * The target of the runtime animation
  4405. */
  4406. private _target;
  4407. /**
  4408. * The initiating animatable
  4409. */
  4410. private _host;
  4411. /**
  4412. * The original value of the runtime animation
  4413. */
  4414. private _originalValue;
  4415. /**
  4416. * The original blend value of the runtime animation
  4417. */
  4418. private _originalBlendValue;
  4419. /**
  4420. * The offsets cache of the runtime animation
  4421. */
  4422. private _offsetsCache;
  4423. /**
  4424. * The high limits cache of the runtime animation
  4425. */
  4426. private _highLimitsCache;
  4427. /**
  4428. * Specifies if the runtime animation has been stopped
  4429. */
  4430. private _stopped;
  4431. /**
  4432. * The blending factor of the runtime animation
  4433. */
  4434. private _blendingFactor;
  4435. /**
  4436. * The BabylonJS scene
  4437. */
  4438. private _scene;
  4439. /**
  4440. * The current value of the runtime animation
  4441. */
  4442. private _currentValue;
  4443. /** @hidden */
  4444. _workValue: any;
  4445. /**
  4446. * The active target of the runtime animation
  4447. */
  4448. private _activeTarget;
  4449. /**
  4450. * The target path of the runtime animation
  4451. */
  4452. private _targetPath;
  4453. /**
  4454. * The weight of the runtime animation
  4455. */
  4456. private _weight;
  4457. /**
  4458. * The ratio offset of the runtime animation
  4459. */
  4460. private _ratioOffset;
  4461. /**
  4462. * The previous delay of the runtime animation
  4463. */
  4464. private _previousDelay;
  4465. /**
  4466. * The previous ratio of the runtime animation
  4467. */
  4468. private _previousRatio;
  4469. /**
  4470. * Gets the current frame of the runtime animation
  4471. */
  4472. readonly currentFrame: number;
  4473. /**
  4474. * Gets the weight of the runtime animation
  4475. */
  4476. readonly weight: number;
  4477. /**
  4478. * Gets the current value of the runtime animation
  4479. */
  4480. readonly currentValue: any;
  4481. /**
  4482. * Gets the target path of the runtime animation
  4483. */
  4484. readonly targetPath: string;
  4485. /**
  4486. * Gets the actual target of the runtime animation
  4487. */
  4488. readonly target: any;
  4489. /**
  4490. * Create a new RuntimeAnimation object
  4491. * @param target defines the target of the animation
  4492. * @param animation defines the source animation object
  4493. * @param scene defines the hosting scene
  4494. * @param host defines the initiating Animatable
  4495. */
  4496. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4497. /**
  4498. * Gets the animation from the runtime animation
  4499. */
  4500. readonly animation: Animation;
  4501. /**
  4502. * Resets the runtime animation to the beginning
  4503. * @param restoreOriginal defines whether to restore the target property to the original value
  4504. */
  4505. reset(restoreOriginal?: boolean): void;
  4506. /**
  4507. * Specifies if the runtime animation is stopped
  4508. * @returns Boolean specifying if the runtime animation is stopped
  4509. */
  4510. isStopped(): boolean;
  4511. /**
  4512. * Disposes of the runtime animation
  4513. */
  4514. dispose(): void;
  4515. /**
  4516. * Interpolates the animation from the current frame
  4517. * @param currentFrame The frame to interpolate the animation to
  4518. * @param repeatCount The number of times that the animation should loop
  4519. * @param loopMode The type of looping mode to use
  4520. * @param offsetValue Animation offset value
  4521. * @param highLimitValue The high limit value
  4522. * @returns The interpolated value
  4523. */
  4524. private _interpolate;
  4525. /**
  4526. * Apply the interpolated value to the target
  4527. * @param currentValue defines the value computed by the animation
  4528. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4529. */
  4530. setValue(currentValue: any, weight?: number): void;
  4531. private _setValue;
  4532. /**
  4533. * Gets the loop pmode of the runtime animation
  4534. * @returns Loop Mode
  4535. */
  4536. private _getCorrectLoopMode;
  4537. /**
  4538. * Move the current animation to a given frame
  4539. * @param frame defines the frame to move to
  4540. */
  4541. goToFrame(frame: number): void;
  4542. /**
  4543. * @hidden Internal use only
  4544. */
  4545. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4546. /**
  4547. * Execute the current animation
  4548. * @param delay defines the delay to add to the current frame
  4549. * @param from defines the lower bound of the animation range
  4550. * @param to defines the upper bound of the animation range
  4551. * @param loop defines if the current animation must loop
  4552. * @param speedRatio defines the current speed ratio
  4553. * @param weight defines the weight of the animation (default is -1 so no weight)
  4554. * @returns a boolean indicating if the animation is running
  4555. */
  4556. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4557. }
  4558. }
  4559. declare module BABYLON {
  4560. /**
  4561. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4562. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4563. */
  4564. class Analyser {
  4565. /**
  4566. * Gets or sets the smoothing
  4567. * @ignorenaming
  4568. */
  4569. SMOOTHING: number;
  4570. /**
  4571. * Gets or sets the FFT table size
  4572. * @ignorenaming
  4573. */
  4574. FFT_SIZE: number;
  4575. /**
  4576. * Gets or sets the bar graph amplitude
  4577. * @ignorenaming
  4578. */
  4579. BARGRAPHAMPLITUDE: number;
  4580. /**
  4581. * Gets or sets the position of the debug canvas
  4582. * @ignorenaming
  4583. */
  4584. DEBUGCANVASPOS: {
  4585. x: number;
  4586. y: number;
  4587. };
  4588. /**
  4589. * Gets or sets the debug canvas size
  4590. * @ignorenaming
  4591. */
  4592. DEBUGCANVASSIZE: {
  4593. width: number;
  4594. height: number;
  4595. };
  4596. private _byteFreqs;
  4597. private _byteTime;
  4598. private _floatFreqs;
  4599. private _webAudioAnalyser;
  4600. private _debugCanvas;
  4601. private _debugCanvasContext;
  4602. private _scene;
  4603. private _registerFunc;
  4604. private _audioEngine;
  4605. /**
  4606. * Creates a new analyser
  4607. * @param scene defines hosting scene
  4608. */
  4609. constructor(scene: Scene);
  4610. /**
  4611. * Get the number of data values you will have to play with for the visualization
  4612. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4613. * @returns a number
  4614. */
  4615. getFrequencyBinCount(): number;
  4616. /**
  4617. * Gets the current frequency data as a byte array
  4618. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4619. * @returns a Uint8Array
  4620. */
  4621. getByteFrequencyData(): Uint8Array;
  4622. /**
  4623. * Gets the current waveform as a byte array
  4624. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4625. * @returns a Uint8Array
  4626. */
  4627. getByteTimeDomainData(): Uint8Array;
  4628. /**
  4629. * Gets the current frequency data as a float array
  4630. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4631. * @returns a Float32Array
  4632. */
  4633. getFloatFrequencyData(): Float32Array;
  4634. /**
  4635. * Renders the debug canvas
  4636. */
  4637. drawDebugCanvas(): void;
  4638. /**
  4639. * Stops rendering the debug canvas and removes it
  4640. */
  4641. stopDebugCanvas(): void;
  4642. /**
  4643. * Connects two audio nodes
  4644. * @param inputAudioNode defines first node to connect
  4645. * @param outputAudioNode defines second node to connect
  4646. */
  4647. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4648. /**
  4649. * Releases all associated resources
  4650. */
  4651. dispose(): void;
  4652. }
  4653. }
  4654. declare module BABYLON {
  4655. class AudioEngine {
  4656. private _audioContext;
  4657. private _audioContextInitialized;
  4658. canUseWebAudio: boolean;
  4659. masterGain: GainNode;
  4660. private _connectedAnalyser;
  4661. WarnedWebAudioUnsupported: boolean;
  4662. unlocked: boolean;
  4663. onAudioUnlocked: () => any;
  4664. isMP3supported: boolean;
  4665. isOGGsupported: boolean;
  4666. readonly audioContext: Nullable<AudioContext>;
  4667. constructor();
  4668. private _unlockiOSaudio;
  4669. private _initializeAudioContext;
  4670. dispose(): void;
  4671. getGlobalVolume(): number;
  4672. setGlobalVolume(newVolume: number): void;
  4673. connectToAnalyser(analyser: Analyser): void;
  4674. }
  4675. }
  4676. declare module BABYLON {
  4677. class Sound {
  4678. name: string;
  4679. autoplay: boolean;
  4680. loop: boolean;
  4681. useCustomAttenuation: boolean;
  4682. soundTrackId: number;
  4683. spatialSound: boolean;
  4684. refDistance: number;
  4685. rolloffFactor: number;
  4686. maxDistance: number;
  4687. distanceModel: string;
  4688. private _panningModel;
  4689. onended: () => any;
  4690. /**
  4691. * Observable event when the current playing sound finishes.
  4692. */
  4693. onEndedObservable: Observable<Sound>;
  4694. private _playbackRate;
  4695. private _streaming;
  4696. private _startTime;
  4697. private _startOffset;
  4698. private _position;
  4699. /** @hidden */
  4700. _positionInEmitterSpace: boolean;
  4701. private _localDirection;
  4702. private _volume;
  4703. private _isReadyToPlay;
  4704. isPlaying: boolean;
  4705. isPaused: boolean;
  4706. private _isDirectional;
  4707. private _readyToPlayCallback;
  4708. private _audioBuffer;
  4709. private _soundSource;
  4710. private _streamingSource;
  4711. private _soundPanner;
  4712. private _soundGain;
  4713. private _inputAudioNode;
  4714. private _outputAudioNode;
  4715. private _coneInnerAngle;
  4716. private _coneOuterAngle;
  4717. private _coneOuterGain;
  4718. private _scene;
  4719. private _connectedMesh;
  4720. private _customAttenuationFunction;
  4721. private _registerFunc;
  4722. private _isOutputConnected;
  4723. private _htmlAudioElement;
  4724. private _urlType;
  4725. /**
  4726. * Create a sound and attach it to a scene
  4727. * @param name Name of your sound
  4728. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  4729. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4730. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4731. */
  4732. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4733. dispose(): void;
  4734. isReady(): boolean;
  4735. private _soundLoaded;
  4736. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4737. updateOptions(options: any): void;
  4738. private _createSpatialParameters;
  4739. private _updateSpatialParameters;
  4740. switchPanningModelToHRTF(): void;
  4741. switchPanningModelToEqualPower(): void;
  4742. private _switchPanningModel;
  4743. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4744. /**
  4745. * Transform this sound into a directional source
  4746. * @param coneInnerAngle Size of the inner cone in degree
  4747. * @param coneOuterAngle Size of the outer cone in degree
  4748. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4749. */
  4750. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4751. /**
  4752. * Gets or sets the inner angle for the directional cone.
  4753. */
  4754. /**
  4755. * Gets or sets the inner angle for the directional cone.
  4756. */
  4757. directionalConeInnerAngle: number;
  4758. /**
  4759. * Gets or sets the outer angle for the directional cone.
  4760. */
  4761. /**
  4762. * Gets or sets the outer angle for the directional cone.
  4763. */
  4764. directionalConeOuterAngle: number;
  4765. setPosition(newPosition: Vector3): void;
  4766. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4767. private _updateDirection;
  4768. updateDistanceFromListener(): void;
  4769. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4770. /**
  4771. * Play the sound
  4772. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4773. * @param offset (optional) Start the sound setting it at a specific time
  4774. */
  4775. play(time?: number, offset?: number): void;
  4776. private _onended;
  4777. /**
  4778. * Stop the sound
  4779. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4780. */
  4781. stop(time?: number): void;
  4782. pause(): void;
  4783. setVolume(newVolume: number, time?: number): void;
  4784. setPlaybackRate(newPlaybackRate: number): void;
  4785. getVolume(): number;
  4786. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4787. detachFromMesh(): void;
  4788. private _onRegisterAfterWorldMatrixUpdate;
  4789. clone(): Nullable<Sound>;
  4790. getAudioBuffer(): AudioBuffer | null;
  4791. serialize(): any;
  4792. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4793. }
  4794. }
  4795. declare module BABYLON {
  4796. class SoundTrack {
  4797. private _outputAudioNode;
  4798. private _scene;
  4799. id: number;
  4800. soundCollection: Array<Sound>;
  4801. private _isMainTrack;
  4802. private _connectedAnalyser;
  4803. private _options;
  4804. private _isInitialized;
  4805. constructor(scene: Scene, options?: any);
  4806. private _initializeSoundTrackAudioGraph;
  4807. dispose(): void;
  4808. AddSound(sound: Sound): void;
  4809. RemoveSound(sound: Sound): void;
  4810. setVolume(newVolume: number): void;
  4811. switchPanningModelToHRTF(): void;
  4812. switchPanningModelToEqualPower(): void;
  4813. connectToAnalyser(analyser: Analyser): void;
  4814. }
  4815. }
  4816. declare module BABYLON {
  4817. /**
  4818. * Wraps one or more Sound objects and selects one with random weight for playback.
  4819. */
  4820. class WeightedSound {
  4821. /** When true a Sound will be selected and played when the current playing Sound completes. */
  4822. loop: boolean;
  4823. private _coneInnerAngle;
  4824. private _coneOuterAngle;
  4825. private _volume;
  4826. /** A Sound is currently playing. */
  4827. isPlaying: boolean;
  4828. /** A Sound is currently paused. */
  4829. isPaused: boolean;
  4830. private _sounds;
  4831. private _weights;
  4832. private _currentIndex?;
  4833. /**
  4834. * Creates a new WeightedSound from the list of sounds given.
  4835. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  4836. * @param sounds Array of Sounds that will be selected from.
  4837. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  4838. */
  4839. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  4840. /**
  4841. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  4842. */
  4843. /**
  4844. * The size of cone in degress for a directional sound in which there will be no attenuation.
  4845. */
  4846. directionalConeInnerAngle: number;
  4847. /**
  4848. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4849. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4850. */
  4851. /**
  4852. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4853. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4854. */
  4855. directionalConeOuterAngle: number;
  4856. /**
  4857. * Playback volume.
  4858. */
  4859. /**
  4860. * Playback volume.
  4861. */
  4862. volume: number;
  4863. private _onended;
  4864. /**
  4865. * Suspend playback
  4866. */
  4867. pause(): void;
  4868. /**
  4869. * Stop playback
  4870. */
  4871. stop(): void;
  4872. /**
  4873. * Start playback.
  4874. * @param startOffset Position the clip head at a specific time in seconds.
  4875. */
  4876. play(startOffset?: number): void;
  4877. }
  4878. }
  4879. declare module BABYLON {
  4880. /**
  4881. * Interface used to define a behavior
  4882. */
  4883. interface Behavior<T> {
  4884. /** gets or sets behavior's name */
  4885. name: string;
  4886. /**
  4887. * Function called when the behavior needs to be initialized (after attaching it to a target)
  4888. */
  4889. init(): void;
  4890. /**
  4891. * Called when the behavior is attached to a target
  4892. * @param target defines the target where the behavior is attached to
  4893. */
  4894. attach(target: T): void;
  4895. /**
  4896. * Called when the behavior is detached from its target
  4897. */
  4898. detach(): void;
  4899. }
  4900. /**
  4901. * Interface implemented by classes supporting behaviors
  4902. */
  4903. interface IBehaviorAware<T> {
  4904. /**
  4905. * Attach a behavior
  4906. * @param behavior defines the behavior to attach
  4907. * @returns the current host
  4908. */
  4909. addBehavior(behavior: Behavior<T>): T;
  4910. /**
  4911. * Remove a behavior from the current object
  4912. * @param behavior defines the behavior to detach
  4913. * @returns the current host
  4914. */
  4915. removeBehavior(behavior: Behavior<T>): T;
  4916. /**
  4917. * Gets a behavior using its name to search
  4918. * @param name defines the name to search
  4919. * @returns the behavior or null if not found
  4920. */
  4921. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  4922. }
  4923. }
  4924. declare module BABYLON {
  4925. /**
  4926. * Class used to store bone information
  4927. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4928. */
  4929. class Bone extends Node {
  4930. /**
  4931. * defines the bone name
  4932. */
  4933. name: string;
  4934. private static _tmpVecs;
  4935. private static _tmpQuat;
  4936. private static _tmpMats;
  4937. /**
  4938. * Gets the list of child bones
  4939. */
  4940. children: Bone[];
  4941. /** Gets the animations associated with this bone */
  4942. animations: Animation[];
  4943. /**
  4944. * Gets or sets bone length
  4945. */
  4946. length: number;
  4947. /**
  4948. * @hidden Internal only
  4949. * Set this value to map this bone to a different index in the transform matrices
  4950. * Set this value to -1 to exclude the bone from the transform matrices
  4951. */
  4952. _index: Nullable<number>;
  4953. private _skeleton;
  4954. private _localMatrix;
  4955. private _restPose;
  4956. private _baseMatrix;
  4957. private _absoluteTransform;
  4958. private _invertedAbsoluteTransform;
  4959. private _parent;
  4960. private _scalingDeterminant;
  4961. private _worldTransform;
  4962. private _localScaling;
  4963. private _localRotation;
  4964. private _localPosition;
  4965. private _needToDecompose;
  4966. private _needToCompose;
  4967. /** @hidden */
  4968. /** @hidden */
  4969. _matrix: Matrix;
  4970. /**
  4971. * Create a new bone
  4972. * @param name defines the bone name
  4973. * @param skeleton defines the parent skeleton
  4974. * @param parentBone defines the parent (can be null if the bone is the root)
  4975. * @param localMatrix defines the local matrix
  4976. * @param restPose defines the rest pose matrix
  4977. * @param baseMatrix defines the base matrix
  4978. * @param index defines index of the bone in the hiearchy
  4979. */
  4980. constructor(
  4981. /**
  4982. * defines the bone name
  4983. */
  4984. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4985. /**
  4986. * Gets the parent skeleton
  4987. * @returns a skeleton
  4988. */
  4989. getSkeleton(): Skeleton;
  4990. /**
  4991. * Gets parent bone
  4992. * @returns a bone or null if the bone is the root of the bone hierarchy
  4993. */
  4994. getParent(): Nullable<Bone>;
  4995. /**
  4996. * Sets the parent bone
  4997. * @param parent defines the parent (can be null if the bone is the root)
  4998. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4999. */
  5000. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  5001. /**
  5002. * Gets the local matrix
  5003. * @returns a matrix
  5004. */
  5005. getLocalMatrix(): Matrix;
  5006. /**
  5007. * Gets the base matrix (initial matrix which remains unchanged)
  5008. * @returns a matrix
  5009. */
  5010. getBaseMatrix(): Matrix;
  5011. /**
  5012. * Gets the rest pose matrix
  5013. * @returns a matrix
  5014. */
  5015. getRestPose(): Matrix;
  5016. /**
  5017. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  5018. */
  5019. getWorldMatrix(): Matrix;
  5020. /**
  5021. * Sets the local matrix to rest pose matrix
  5022. */
  5023. returnToRest(): void;
  5024. /**
  5025. * Gets the inverse of the absolute transform matrix.
  5026. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  5027. * @returns a matrix
  5028. */
  5029. getInvertedAbsoluteTransform(): Matrix;
  5030. /**
  5031. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  5032. * @returns a matrix
  5033. */
  5034. getAbsoluteTransform(): Matrix;
  5035. /** Gets or sets current position (in local space) */
  5036. position: Vector3;
  5037. /** Gets or sets current rotation (in local space) */
  5038. rotation: Vector3;
  5039. /** Gets or sets current rotation quaternion (in local space) */
  5040. rotationQuaternion: Quaternion;
  5041. /** Gets or sets current scaling (in local space) */
  5042. scaling: Vector3;
  5043. /**
  5044. * Gets the animation properties override
  5045. */
  5046. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5047. private _decompose;
  5048. private _compose;
  5049. /**
  5050. * Update the base and local matrices
  5051. * @param matrix defines the new base or local matrix
  5052. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5053. * @param updateLocalMatrix defines if the local matrix should be updated
  5054. */
  5055. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  5056. /** @hidden */
  5057. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  5058. /**
  5059. * Flag the bone as dirty (Forcing it to update everything)
  5060. */
  5061. markAsDirty(): void;
  5062. private _markAsDirtyAndCompose;
  5063. private _markAsDirtyAndDecompose;
  5064. /**
  5065. * Copy an animation range from another bone
  5066. * @param source defines the source bone
  5067. * @param rangeName defines the range name to copy
  5068. * @param frameOffset defines the frame offset
  5069. * @param rescaleAsRequired defines if rescaling must be applied if required
  5070. * @param skelDimensionsRatio defines the scaling ratio
  5071. * @returns true if operation was successful
  5072. */
  5073. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  5074. /**
  5075. * Translate the bone in local or world space
  5076. * @param vec The amount to translate the bone
  5077. * @param space The space that the translation is in
  5078. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5079. */
  5080. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5081. /**
  5082. * Set the postion of the bone in local or world space
  5083. * @param position The position to set the bone
  5084. * @param space The space that the position is in
  5085. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5086. */
  5087. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5088. /**
  5089. * Set the absolute position of the bone (world space)
  5090. * @param position The position to set the bone
  5091. * @param mesh The mesh that this bone is attached to
  5092. */
  5093. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  5094. /**
  5095. * Scale the bone on the x, y and z axes (in local space)
  5096. * @param x The amount to scale the bone on the x axis
  5097. * @param y The amount to scale the bone on the y axis
  5098. * @param z The amount to scale the bone on the z axis
  5099. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  5100. */
  5101. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  5102. /**
  5103. * Set the bone scaling in local space
  5104. * @param scale defines the scaling vector
  5105. */
  5106. setScale(scale: Vector3): void;
  5107. /**
  5108. * Gets the current scaling in local space
  5109. * @returns the current scaling vector
  5110. */
  5111. getScale(): Vector3;
  5112. /**
  5113. * Gets the current scaling in local space and stores it in a target vector
  5114. * @param result defines the target vector
  5115. */
  5116. getScaleToRef(result: Vector3): void;
  5117. /**
  5118. * Set the yaw, pitch, and roll of the bone in local or world space
  5119. * @param yaw The rotation of the bone on the y axis
  5120. * @param pitch The rotation of the bone on the x axis
  5121. * @param roll The rotation of the bone on the z axis
  5122. * @param space The space that the axes of rotation are in
  5123. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5124. */
  5125. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  5126. /**
  5127. * Add a rotation to the bone on an axis in local or world space
  5128. * @param axis The axis to rotate the bone on
  5129. * @param amount The amount to rotate the bone
  5130. * @param space The space that the axis is in
  5131. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5132. */
  5133. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  5134. /**
  5135. * Set the rotation of the bone to a particular axis angle in local or world space
  5136. * @param axis The axis to rotate the bone on
  5137. * @param angle The angle that the bone should be rotated to
  5138. * @param space The space that the axis is in
  5139. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5140. */
  5141. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  5142. /**
  5143. * Set the euler rotation of the bone in local of world space
  5144. * @param rotation The euler rotation that the bone should be set to
  5145. * @param space The space that the rotation is in
  5146. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5147. */
  5148. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5149. /**
  5150. * Set the quaternion rotation of the bone in local of world space
  5151. * @param quat The quaternion rotation that the bone should be set to
  5152. * @param space The space that the rotation is in
  5153. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5154. */
  5155. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  5156. /**
  5157. * Set the rotation matrix of the bone in local of world space
  5158. * @param rotMat The rotation matrix that the bone should be set to
  5159. * @param space The space that the rotation is in
  5160. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5161. */
  5162. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  5163. private _rotateWithMatrix;
  5164. private _getNegativeRotationToRef;
  5165. /**
  5166. * Get the position of the bone in local or world space
  5167. * @param space The space that the returned position is in
  5168. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5169. * @returns The position of the bone
  5170. */
  5171. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5172. /**
  5173. * Copy the position of the bone to a vector3 in local or world space
  5174. * @param space The space that the returned position is in
  5175. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5176. * @param result The vector3 to copy the position to
  5177. */
  5178. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  5179. /**
  5180. * Get the absolute position of the bone (world space)
  5181. * @param mesh The mesh that this bone is attached to
  5182. * @returns The absolute position of the bone
  5183. */
  5184. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  5185. /**
  5186. * Copy the absolute position of the bone (world space) to the result param
  5187. * @param mesh The mesh that this bone is attached to
  5188. * @param result The vector3 to copy the absolute position to
  5189. */
  5190. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  5191. /**
  5192. * Compute the absolute transforms of this bone and its children
  5193. */
  5194. computeAbsoluteTransforms(): void;
  5195. /**
  5196. * Get the world direction from an axis that is in the local space of the bone
  5197. * @param localAxis The local direction that is used to compute the world direction
  5198. * @param mesh The mesh that this bone is attached to
  5199. * @returns The world direction
  5200. */
  5201. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5202. /**
  5203. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  5204. * @param localAxis The local direction that is used to compute the world direction
  5205. * @param mesh The mesh that this bone is attached to
  5206. * @param result The vector3 that the world direction will be copied to
  5207. */
  5208. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5209. /**
  5210. * Get the euler rotation of the bone in local or world space
  5211. * @param space The space that the rotation should be in
  5212. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5213. * @returns The euler rotation
  5214. */
  5215. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5216. /**
  5217. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  5218. * @param space The space that the rotation should be in
  5219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5220. * @param result The vector3 that the rotation should be copied to
  5221. */
  5222. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5223. /**
  5224. * Get the quaternion rotation of the bone in either local or world space
  5225. * @param space The space that the rotation should be in
  5226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5227. * @returns The quaternion rotation
  5228. */
  5229. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  5230. /**
  5231. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  5232. * @param space The space that the rotation should be in
  5233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5234. * @param result The quaternion that the rotation should be copied to
  5235. */
  5236. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  5237. /**
  5238. * Get the rotation matrix of the bone in local or world space
  5239. * @param space The space that the rotation should be in
  5240. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5241. * @returns The rotation matrix
  5242. */
  5243. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  5244. /**
  5245. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  5246. * @param space The space that the rotation should be in
  5247. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5248. * @param result The quaternion that the rotation should be copied to
  5249. */
  5250. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  5251. /**
  5252. * Get the world position of a point that is in the local space of the bone
  5253. * @param position The local position
  5254. * @param mesh The mesh that this bone is attached to
  5255. * @returns The world position
  5256. */
  5257. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5258. /**
  5259. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  5260. * @param position The local position
  5261. * @param mesh The mesh that this bone is attached to
  5262. * @param result The vector3 that the world position should be copied to
  5263. */
  5264. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5265. /**
  5266. * Get the local position of a point that is in world space
  5267. * @param position The world position
  5268. * @param mesh The mesh that this bone is attached to
  5269. * @returns The local position
  5270. */
  5271. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5272. /**
  5273. * Get the local position of a point that is in world space and copy it to the result param
  5274. * @param position The world position
  5275. * @param mesh The mesh that this bone is attached to
  5276. * @param result The vector3 that the local position should be copied to
  5277. */
  5278. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5279. }
  5280. }
  5281. declare module BABYLON {
  5282. /**
  5283. * Class used to apply inverse kinematics to bones
  5284. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  5285. */
  5286. class BoneIKController {
  5287. private static _tmpVecs;
  5288. private static _tmpQuat;
  5289. private static _tmpMats;
  5290. /**
  5291. * Gets or sets the target mesh
  5292. */
  5293. targetMesh: AbstractMesh;
  5294. /** Gets or sets the mesh used as pole */
  5295. poleTargetMesh: AbstractMesh;
  5296. /**
  5297. * Gets or sets the bone used as pole
  5298. */
  5299. poleTargetBone: Nullable<Bone>;
  5300. /**
  5301. * Gets or sets the target position
  5302. */
  5303. targetPosition: Vector3;
  5304. /**
  5305. * Gets or sets the pole target position
  5306. */
  5307. poleTargetPosition: Vector3;
  5308. /**
  5309. * Gets or sets the pole target local offset
  5310. */
  5311. poleTargetLocalOffset: Vector3;
  5312. /**
  5313. * Gets or sets the pole angle
  5314. */
  5315. poleAngle: number;
  5316. /**
  5317. * Gets or sets the mesh associated with the controller
  5318. */
  5319. mesh: AbstractMesh;
  5320. /**
  5321. * 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)
  5322. */
  5323. slerpAmount: number;
  5324. private _bone1Quat;
  5325. private _bone1Mat;
  5326. private _bone2Ang;
  5327. private _bone1;
  5328. private _bone2;
  5329. private _bone1Length;
  5330. private _bone2Length;
  5331. private _maxAngle;
  5332. private _maxReach;
  5333. private _rightHandedSystem;
  5334. private _bendAxis;
  5335. private _slerping;
  5336. private _adjustRoll;
  5337. /**
  5338. * Gets or sets maximum allowed angle
  5339. */
  5340. maxAngle: number;
  5341. /**
  5342. * Creates a new BoneIKController
  5343. * @param mesh defines the mesh to control
  5344. * @param bone defines the bone to control
  5345. * @param options defines options to set up the controller
  5346. */
  5347. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5348. targetMesh?: AbstractMesh;
  5349. poleTargetMesh?: AbstractMesh;
  5350. poleTargetBone?: Bone;
  5351. poleTargetLocalOffset?: Vector3;
  5352. poleAngle?: number;
  5353. bendAxis?: Vector3;
  5354. maxAngle?: number;
  5355. slerpAmount?: number;
  5356. });
  5357. private _setMaxAngle;
  5358. /**
  5359. * Force the controller to update the bones
  5360. */
  5361. update(): void;
  5362. }
  5363. }
  5364. declare module BABYLON {
  5365. /**
  5366. * Class used to make a bone look toward a point in space
  5367. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5368. */
  5369. class BoneLookController {
  5370. private static _tmpVecs;
  5371. private static _tmpQuat;
  5372. private static _tmpMats;
  5373. /**
  5374. * The target Vector3 that the bone will look at
  5375. */
  5376. target: Vector3;
  5377. /**
  5378. * The mesh that the bone is attached to
  5379. */
  5380. mesh: AbstractMesh;
  5381. /**
  5382. * The bone that will be looking to the target
  5383. */
  5384. bone: Bone;
  5385. /**
  5386. * The up axis of the coordinate system that is used when the bone is rotated
  5387. */
  5388. upAxis: Vector3;
  5389. /**
  5390. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5391. */
  5392. upAxisSpace: Space;
  5393. /**
  5394. * Used to make an adjustment to the yaw of the bone
  5395. */
  5396. adjustYaw: number;
  5397. /**
  5398. * Used to make an adjustment to the pitch of the bone
  5399. */
  5400. adjustPitch: number;
  5401. /**
  5402. * Used to make an adjustment to the roll of the bone
  5403. */
  5404. adjustRoll: number;
  5405. /**
  5406. * 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)
  5407. */
  5408. slerpAmount: number;
  5409. private _minYaw;
  5410. private _maxYaw;
  5411. private _minPitch;
  5412. private _maxPitch;
  5413. private _minYawSin;
  5414. private _minYawCos;
  5415. private _maxYawSin;
  5416. private _maxYawCos;
  5417. private _midYawConstraint;
  5418. private _minPitchTan;
  5419. private _maxPitchTan;
  5420. private _boneQuat;
  5421. private _slerping;
  5422. private _transformYawPitch;
  5423. private _transformYawPitchInv;
  5424. private _firstFrameSkipped;
  5425. private _yawRange;
  5426. private _fowardAxis;
  5427. /**
  5428. * Gets or sets the minimum yaw angle that the bone can look to
  5429. */
  5430. minYaw: number;
  5431. /**
  5432. * Gets or sets the maximum yaw angle that the bone can look to
  5433. */
  5434. maxYaw: number;
  5435. /**
  5436. * Gets or sets the minimum pitch angle that the bone can look to
  5437. */
  5438. minPitch: number;
  5439. /**
  5440. * Gets or sets the maximum pitch angle that the bone can look to
  5441. */
  5442. maxPitch: number;
  5443. /**
  5444. * Create a BoneLookController
  5445. * @param mesh the mesh that the bone belongs to
  5446. * @param bone the bone that will be looking to the target
  5447. * @param target the target Vector3 to look at
  5448. * @param settings optional settings:
  5449. * * maxYaw: the maximum angle the bone will yaw to
  5450. * * minYaw: the minimum angle the bone will yaw to
  5451. * * maxPitch: the maximum angle the bone will pitch to
  5452. * * minPitch: the minimum angle the bone will yaw to
  5453. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5454. * * upAxis: the up axis of the coordinate system
  5455. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5456. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5457. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5458. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5459. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5460. * * adjustRoll: used to make an adjustment to the roll of the bone
  5461. **/
  5462. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5463. maxYaw?: number;
  5464. minYaw?: number;
  5465. maxPitch?: number;
  5466. minPitch?: number;
  5467. slerpAmount?: number;
  5468. upAxis?: Vector3;
  5469. upAxisSpace?: Space;
  5470. yawAxis?: Vector3;
  5471. pitchAxis?: Vector3;
  5472. adjustYaw?: number;
  5473. adjustPitch?: number;
  5474. adjustRoll?: number;
  5475. });
  5476. /**
  5477. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5478. */
  5479. update(): void;
  5480. private _getAngleDiff;
  5481. private _getAngleBetween;
  5482. private _isAngleBetween;
  5483. }
  5484. }
  5485. declare module BABYLON {
  5486. /**
  5487. * Class used to handle skinning animations
  5488. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5489. */
  5490. class Skeleton implements IAnimatable {
  5491. /** defines the skeleton name */
  5492. name: string;
  5493. /** defines the skeleton Id */
  5494. id: string;
  5495. /**
  5496. * Gets the list of child bones
  5497. */
  5498. bones: Bone[];
  5499. /**
  5500. * Gets an estimate of the dimension of the skeleton at rest
  5501. */
  5502. dimensionsAtRest: Vector3;
  5503. /**
  5504. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5505. */
  5506. needInitialSkinMatrix: boolean;
  5507. /**
  5508. * Gets the list of animations attached to this skeleton
  5509. */
  5510. animations: Array<Animation>;
  5511. private _scene;
  5512. private _isDirty;
  5513. private _transformMatrices;
  5514. private _meshesWithPoseMatrix;
  5515. private _animatables;
  5516. private _identity;
  5517. private _synchronizedWithMesh;
  5518. private _ranges;
  5519. private _lastAbsoluteTransformsUpdateId;
  5520. /**
  5521. * Specifies if the skeleton should be serialized
  5522. */
  5523. doNotSerialize: boolean;
  5524. private _animationPropertiesOverride;
  5525. /**
  5526. * Gets or sets the animation properties override
  5527. */
  5528. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5529. /**
  5530. * An observable triggered before computing the skeleton's matrices
  5531. */
  5532. onBeforeComputeObservable: Observable<Skeleton>;
  5533. /**
  5534. * Creates a new skeleton
  5535. * @param name defines the skeleton name
  5536. * @param id defines the skeleton Id
  5537. * @param scene defines the hosting scene
  5538. */
  5539. constructor(
  5540. /** defines the skeleton name */
  5541. name: string,
  5542. /** defines the skeleton Id */
  5543. id: string, scene: Scene);
  5544. /**
  5545. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5546. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5547. * @returns a Float32Array containing matrices data
  5548. */
  5549. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5550. /**
  5551. * Gets the current hosting scene
  5552. * @returns a scene object
  5553. */
  5554. getScene(): Scene;
  5555. /**
  5556. * Gets a string representing the current skeleton data
  5557. * @param fullDetails defines a boolean indicating if we want a verbose version
  5558. * @returns a string representing the current skeleton data
  5559. */
  5560. toString(fullDetails?: boolean): string;
  5561. /**
  5562. * Get bone's index searching by name
  5563. * @param name defines bone's name to search for
  5564. * @return the indice of the bone. Returns -1 if not found
  5565. */
  5566. getBoneIndexByName(name: string): number;
  5567. /**
  5568. * Creater a new animation range
  5569. * @param name defines the name of the range
  5570. * @param from defines the start key
  5571. * @param to defines the end key
  5572. */
  5573. createAnimationRange(name: string, from: number, to: number): void;
  5574. /**
  5575. * Delete a specific animation range
  5576. * @param name defines the name of the range
  5577. * @param deleteFrames defines if frames must be removed as well
  5578. */
  5579. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5580. /**
  5581. * Gets a specific animation range
  5582. * @param name defines the name of the range to look for
  5583. * @returns the requested animation range or null if not found
  5584. */
  5585. getAnimationRange(name: string): Nullable<AnimationRange>;
  5586. /**
  5587. * Gets the list of all animation ranges defined on this skeleton
  5588. * @returns an array
  5589. */
  5590. getAnimationRanges(): Nullable<AnimationRange>[];
  5591. /**
  5592. * Copy animation range from a source skeleton.
  5593. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5594. * @param source defines the source skeleton
  5595. * @param name defines the name of the range to copy
  5596. * @param rescaleAsRequired defines if rescaling must be applied if required
  5597. * @returns true if operation was successful
  5598. */
  5599. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5600. /**
  5601. * Forces the skeleton to go to rest pose
  5602. */
  5603. returnToRest(): void;
  5604. private _getHighestAnimationFrame;
  5605. /**
  5606. * Begin a specific animation range
  5607. * @param name defines the name of the range to start
  5608. * @param loop defines if looping must be turned on (false by default)
  5609. * @param speedRatio defines the speed ratio to apply (1 by default)
  5610. * @param onAnimationEnd defines a callback which will be called when animation will end
  5611. * @returns a new animatable
  5612. */
  5613. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5614. /** @hidden */
  5615. _markAsDirty(): void;
  5616. /** @hidden */
  5617. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5618. /** @hidden */
  5619. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5620. /** @hidden */
  5621. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5622. /**
  5623. * Build all resources required to render a skeleton
  5624. */
  5625. prepare(): void;
  5626. /**
  5627. * Gets the list of animatables currently running for this skeleton
  5628. * @returns an array of animatables
  5629. */
  5630. getAnimatables(): IAnimatable[];
  5631. /**
  5632. * Clone the current skeleton
  5633. * @param name defines the name of the new skeleton
  5634. * @param id defines the id of the enw skeleton
  5635. * @returns the new skeleton
  5636. */
  5637. clone(name: string, id: string): Skeleton;
  5638. /**
  5639. * Enable animation blending for this skeleton
  5640. * @param blendingSpeed defines the blending speed to apply
  5641. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5642. */
  5643. enableBlending(blendingSpeed?: number): void;
  5644. /**
  5645. * Releases all resources associated with the current skeleton
  5646. */
  5647. dispose(): void;
  5648. /**
  5649. * Serialize the skeleton in a JSON object
  5650. * @returns a JSON object
  5651. */
  5652. serialize(): any;
  5653. /**
  5654. * Creates a new skeleton from serialized data
  5655. * @param parsedSkeleton defines the serialized data
  5656. * @param scene defines the hosting scene
  5657. * @returns a new skeleton
  5658. */
  5659. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5660. /**
  5661. * Compute all node absolute transforms
  5662. * @param forceUpdate defines if computation must be done even if cache is up to date
  5663. */
  5664. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5665. /**
  5666. * Gets the root pose matrix
  5667. * @returns a matrix
  5668. */
  5669. getPoseMatrix(): Nullable<Matrix>;
  5670. /**
  5671. * Sorts bones per internal index
  5672. */
  5673. sortBones(): void;
  5674. private _sortBones;
  5675. }
  5676. }
  5677. declare module BABYLON {
  5678. class ArcRotateCamera extends TargetCamera {
  5679. alpha: number;
  5680. beta: number;
  5681. radius: number;
  5682. protected _target: Vector3;
  5683. protected _targetHost: Nullable<AbstractMesh>;
  5684. target: Vector3;
  5685. inertialAlphaOffset: number;
  5686. inertialBetaOffset: number;
  5687. inertialRadiusOffset: number;
  5688. lowerAlphaLimit: Nullable<number>;
  5689. upperAlphaLimit: Nullable<number>;
  5690. lowerBetaLimit: number;
  5691. upperBetaLimit: number;
  5692. lowerRadiusLimit: Nullable<number>;
  5693. upperRadiusLimit: Nullable<number>;
  5694. inertialPanningX: number;
  5695. inertialPanningY: number;
  5696. pinchToPanMaxDistance: number;
  5697. panningDistanceLimit: Nullable<number>;
  5698. panningOriginTarget: Vector3;
  5699. panningInertia: number;
  5700. angularSensibilityX: number;
  5701. angularSensibilityY: number;
  5702. pinchPrecision: number;
  5703. pinchDeltaPercentage: number;
  5704. panningSensibility: number;
  5705. keysUp: number[];
  5706. keysDown: number[];
  5707. keysLeft: number[];
  5708. keysRight: number[];
  5709. wheelPrecision: number;
  5710. wheelDeltaPercentage: number;
  5711. zoomOnFactor: number;
  5712. targetScreenOffset: Vector2;
  5713. allowUpsideDown: boolean;
  5714. /** @hidden */
  5715. _viewMatrix: Matrix;
  5716. /** @hidden */
  5717. _useCtrlForPanning: boolean;
  5718. /** @hidden */
  5719. _panningMouseButton: number;
  5720. inputs: ArcRotateCameraInputsManager;
  5721. /** @hidden */
  5722. _reset: () => void;
  5723. panningAxis: Vector3;
  5724. protected _localDirection: Vector3;
  5725. protected _transformedDirection: Vector3;
  5726. private _bouncingBehavior;
  5727. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  5728. useBouncingBehavior: boolean;
  5729. private _framingBehavior;
  5730. readonly framingBehavior: Nullable<FramingBehavior>;
  5731. useFramingBehavior: boolean;
  5732. private _autoRotationBehavior;
  5733. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  5734. useAutoRotationBehavior: boolean;
  5735. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  5736. onCollide: (collidedMesh: AbstractMesh) => void;
  5737. checkCollisions: boolean;
  5738. collisionRadius: Vector3;
  5739. protected _collider: Collider;
  5740. protected _previousPosition: Vector3;
  5741. protected _collisionVelocity: Vector3;
  5742. protected _newPosition: Vector3;
  5743. protected _previousAlpha: number;
  5744. protected _previousBeta: number;
  5745. protected _previousRadius: number;
  5746. protected _collisionTriggered: boolean;
  5747. protected _targetBoundingCenter: Nullable<Vector3>;
  5748. private _computationVector;
  5749. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5750. /** @hidden */
  5751. _initCache(): void;
  5752. /** @hidden */
  5753. _updateCache(ignoreParentClass?: boolean): void;
  5754. protected _getTargetPosition(): Vector3;
  5755. /**
  5756. * Store current camera state (fov, position, etc..)
  5757. */
  5758. private _storedAlpha;
  5759. private _storedBeta;
  5760. private _storedRadius;
  5761. private _storedTarget;
  5762. storeState(): Camera;
  5763. /**
  5764. * @hidden
  5765. * Restored camera state. You must call storeState() first
  5766. */
  5767. _restoreStateValues(): boolean;
  5768. /** @hidden */
  5769. _isSynchronizedViewMatrix(): boolean;
  5770. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  5771. detachControl(element: HTMLElement): void;
  5772. /** @hidden */
  5773. _checkInputs(): void;
  5774. protected _checkLimits(): void;
  5775. rebuildAnglesAndRadius(): void;
  5776. setPosition(position: Vector3): void;
  5777. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  5778. /** @hidden */
  5779. _getViewMatrix(): Matrix;
  5780. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  5781. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  5782. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  5783. min: Vector3;
  5784. max: Vector3;
  5785. distance: number;
  5786. }, doNotUpdateMaxZ?: boolean): void;
  5787. /**
  5788. * @override
  5789. * Override Camera.createRigCamera
  5790. */
  5791. createRigCamera(name: string, cameraIndex: number): Camera;
  5792. /**
  5793. * @hidden
  5794. * @override
  5795. * Override Camera._updateRigCameras
  5796. */
  5797. _updateRigCameras(): void;
  5798. dispose(): void;
  5799. getClassName(): string;
  5800. }
  5801. }
  5802. declare module BABYLON {
  5803. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  5804. constructor(camera: ArcRotateCamera);
  5805. addMouseWheel(): ArcRotateCameraInputsManager;
  5806. addPointers(): ArcRotateCameraInputsManager;
  5807. addKeyboard(): ArcRotateCameraInputsManager;
  5808. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  5809. }
  5810. }
  5811. declare module BABYLON {
  5812. class Camera extends Node {
  5813. inputs: CameraInputsManager<Camera>;
  5814. private static _PERSPECTIVE_CAMERA;
  5815. private static _ORTHOGRAPHIC_CAMERA;
  5816. private static _FOVMODE_VERTICAL_FIXED;
  5817. private static _FOVMODE_HORIZONTAL_FIXED;
  5818. private static _RIG_MODE_NONE;
  5819. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  5820. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  5821. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  5822. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  5823. private static _RIG_MODE_VR;
  5824. private static _RIG_MODE_WEBVR;
  5825. static readonly PERSPECTIVE_CAMERA: number;
  5826. static readonly ORTHOGRAPHIC_CAMERA: number;
  5827. /**
  5828. * This is the default FOV mode for perspective cameras.
  5829. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  5830. *
  5831. */
  5832. static readonly FOVMODE_VERTICAL_FIXED: number;
  5833. /**
  5834. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  5835. *
  5836. */
  5837. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  5838. static readonly RIG_MODE_NONE: number;
  5839. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  5840. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  5841. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  5842. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  5843. static readonly RIG_MODE_VR: number;
  5844. static readonly RIG_MODE_WEBVR: number;
  5845. static ForceAttachControlToAlwaysPreventDefault: boolean;
  5846. static UseAlternateWebVRRendering: boolean;
  5847. position: Vector3;
  5848. /**
  5849. * The vector the camera should consider as up.
  5850. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  5851. */
  5852. upVector: Vector3;
  5853. orthoLeft: Nullable<number>;
  5854. orthoRight: Nullable<number>;
  5855. orthoBottom: Nullable<number>;
  5856. orthoTop: Nullable<number>;
  5857. /**
  5858. * FOV is set in Radians. (default is 0.8)
  5859. */
  5860. fov: number;
  5861. minZ: number;
  5862. maxZ: number;
  5863. inertia: number;
  5864. mode: number;
  5865. isIntermediate: boolean;
  5866. viewport: Viewport;
  5867. /**
  5868. * Restricts the camera to viewing objects with the same layerMask.
  5869. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  5870. */
  5871. layerMask: number;
  5872. /**
  5873. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  5874. */
  5875. fovMode: number;
  5876. cameraRigMode: number;
  5877. interaxialDistance: number;
  5878. isStereoscopicSideBySide: boolean;
  5879. /** @hidden */
  5880. _cameraRigParams: any;
  5881. /** @hidden */
  5882. _rigCameras: Camera[];
  5883. /** @hidden */
  5884. _rigPostProcess: Nullable<PostProcess>;
  5885. protected _webvrViewMatrix: Matrix;
  5886. /** @hidden */
  5887. _skipRendering: boolean;
  5888. /** @hidden */
  5889. _alternateCamera: Camera;
  5890. customRenderTargets: RenderTargetTexture[];
  5891. onViewMatrixChangedObservable: Observable<Camera>;
  5892. onProjectionMatrixChangedObservable: Observable<Camera>;
  5893. onAfterCheckInputsObservable: Observable<Camera>;
  5894. onRestoreStateObservable: Observable<Camera>;
  5895. private _computedViewMatrix;
  5896. _projectionMatrix: Matrix;
  5897. private _doNotComputeProjectionMatrix;
  5898. private _worldMatrix;
  5899. _postProcesses: Nullable<PostProcess>[];
  5900. private _transformMatrix;
  5901. _activeMeshes: SmartArray<AbstractMesh>;
  5902. protected _globalPosition: Vector3;
  5903. private _frustumPlanes;
  5904. private _refreshFrustumPlanes;
  5905. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5906. private _storedFov;
  5907. private _stateStored;
  5908. /**
  5909. * Store current camera state (fov, position, etc..)
  5910. */
  5911. storeState(): Camera;
  5912. /**
  5913. * Restores the camera state values if it has been stored. You must call storeState() first
  5914. */
  5915. protected _restoreStateValues(): boolean;
  5916. /**
  5917. * Restored camera state. You must call storeState() first
  5918. */
  5919. restoreState(): boolean;
  5920. getClassName(): string;
  5921. /**
  5922. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  5923. */
  5924. toString(fullDetails?: boolean): string;
  5925. readonly globalPosition: Vector3;
  5926. getActiveMeshes(): SmartArray<AbstractMesh>;
  5927. isActiveMesh(mesh: Mesh): boolean;
  5928. /**
  5929. * Is this camera ready to be used/rendered
  5930. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  5931. * @return true if the camera is ready
  5932. */
  5933. isReady(completeCheck?: boolean): boolean;
  5934. /** @hidden */
  5935. _initCache(): void;
  5936. /** @hidden */
  5937. _updateCache(ignoreParentClass?: boolean): void;
  5938. /** @hidden */
  5939. _isSynchronized(): boolean;
  5940. /** @hidden */
  5941. _isSynchronizedViewMatrix(): boolean;
  5942. /** @hidden */
  5943. _isSynchronizedProjectionMatrix(): boolean;
  5944. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5945. detachControl(element: HTMLElement): void;
  5946. update(): void;
  5947. /** @hidden */
  5948. _checkInputs(): void;
  5949. readonly rigCameras: Camera[];
  5950. readonly rigPostProcess: Nullable<PostProcess>;
  5951. /**
  5952. * Internal, gets the first post proces.
  5953. * @returns the first post process to be run on this camera.
  5954. */
  5955. _getFirstPostProcess(): Nullable<PostProcess>;
  5956. private _cascadePostProcessesToRigCams;
  5957. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  5958. detachPostProcess(postProcess: PostProcess): void;
  5959. getWorldMatrix(): Matrix;
  5960. /** @hidden */
  5961. _getViewMatrix(): Matrix;
  5962. getViewMatrix(force?: boolean): Matrix;
  5963. freezeProjectionMatrix(projection?: Matrix): void;
  5964. unfreezeProjectionMatrix(): void;
  5965. getProjectionMatrix(force?: boolean): Matrix;
  5966. /**
  5967. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  5968. * @returns a Matrix
  5969. */
  5970. getTransformationMatrix(): Matrix;
  5971. private updateFrustumPlanes;
  5972. isInFrustum(target: ICullable): boolean;
  5973. isCompletelyInFrustum(target: ICullable): boolean;
  5974. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  5975. /**
  5976. * Releases resources associated with this node.
  5977. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  5978. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  5979. */
  5980. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  5981. readonly leftCamera: Nullable<FreeCamera>;
  5982. readonly rightCamera: Nullable<FreeCamera>;
  5983. getLeftTarget(): Nullable<Vector3>;
  5984. getRightTarget(): Nullable<Vector3>;
  5985. setCameraRigMode(mode: number, rigParams: any): void;
  5986. private _getVRProjectionMatrix;
  5987. protected _updateCameraRotationMatrix(): void;
  5988. protected _updateWebVRCameraRotationMatrix(): void;
  5989. /**
  5990. * This function MUST be overwritten by the different WebVR cameras available.
  5991. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5992. */
  5993. protected _getWebVRProjectionMatrix(): Matrix;
  5994. /**
  5995. * This function MUST be overwritten by the different WebVR cameras available.
  5996. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5997. */
  5998. protected _getWebVRViewMatrix(): Matrix;
  5999. setCameraRigParameter(name: string, value: any): void;
  6000. /**
  6001. * needs to be overridden by children so sub has required properties to be copied
  6002. */
  6003. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6004. /**
  6005. * May need to be overridden by children
  6006. * @hidden
  6007. */
  6008. _updateRigCameras(): void;
  6009. /** @hidden */
  6010. _setupInputs(): void;
  6011. serialize(): any;
  6012. clone(name: string): Camera;
  6013. getDirection(localAxis: Vector3): Vector3;
  6014. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  6015. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  6016. computeWorldMatrix(): Matrix;
  6017. static Parse(parsedCamera: any, scene: Scene): Camera;
  6018. }
  6019. }
  6020. declare module BABYLON {
  6021. var CameraInputTypes: {};
  6022. interface ICameraInput<TCamera extends Camera> {
  6023. camera: Nullable<TCamera>;
  6024. getClassName(): string;
  6025. getSimpleName(): string;
  6026. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  6027. detachControl: (element: Nullable<HTMLElement>) => void;
  6028. checkInputs?: () => void;
  6029. }
  6030. interface CameraInputsMap<TCamera extends Camera> {
  6031. [name: string]: ICameraInput<TCamera>;
  6032. [idx: number]: ICameraInput<TCamera>;
  6033. }
  6034. class CameraInputsManager<TCamera extends Camera> {
  6035. attached: CameraInputsMap<TCamera>;
  6036. attachedElement: Nullable<HTMLElement>;
  6037. noPreventDefault: boolean;
  6038. camera: TCamera;
  6039. checkInputs: () => void;
  6040. constructor(camera: TCamera);
  6041. /**
  6042. * Add an input method to a camera
  6043. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6044. * @param input camera input method
  6045. */
  6046. add(input: ICameraInput<TCamera>): void;
  6047. /**
  6048. * Remove a specific input method from a camera
  6049. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6050. * @param inputToRemove camera input method
  6051. */
  6052. remove(inputToRemove: ICameraInput<TCamera>): void;
  6053. removeByType(inputType: string): void;
  6054. private _addCheckInputs;
  6055. attachInput(input: ICameraInput<TCamera>): void;
  6056. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6057. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6058. rebuildInputCheck(): void;
  6059. /**
  6060. * Remove all attached input methods from a camera
  6061. */
  6062. clear(): void;
  6063. serialize(serializedCamera: any): void;
  6064. parse(parsedCamera: any): void;
  6065. }
  6066. }
  6067. declare module BABYLON {
  6068. /**
  6069. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  6070. * being tilted forward or back and left or right.
  6071. */
  6072. class DeviceOrientationCamera extends FreeCamera {
  6073. private _initialQuaternion;
  6074. private _quaternionCache;
  6075. /**
  6076. * Creates a new device orientation camera
  6077. * @param name The name of the camera
  6078. * @param position The start position camera
  6079. * @param scene The scene the camera belongs to
  6080. */
  6081. constructor(name: string, position: Vector3, scene: Scene);
  6082. /**
  6083. * Gets the current instance class name ("DeviceOrientationCamera").
  6084. * This helps avoiding instanceof at run time.
  6085. * @returns the class name
  6086. */
  6087. getClassName(): string;
  6088. /**
  6089. * @hidden
  6090. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  6091. */
  6092. _checkInputs(): void;
  6093. /**
  6094. * Reset the camera to its default orientation on the specified axis only.
  6095. * @param axis The axis to reset
  6096. */
  6097. resetToCurrentRotation(axis?: Axis): void;
  6098. }
  6099. }
  6100. declare module BABYLON {
  6101. class FollowCamera extends TargetCamera {
  6102. radius: number;
  6103. rotationOffset: number;
  6104. heightOffset: number;
  6105. cameraAcceleration: number;
  6106. maxCameraSpeed: number;
  6107. lockedTarget: Nullable<AbstractMesh>;
  6108. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  6109. private getRadians;
  6110. private follow;
  6111. /** @hidden */
  6112. _checkInputs(): void;
  6113. getClassName(): string;
  6114. }
  6115. class ArcFollowCamera extends TargetCamera {
  6116. alpha: number;
  6117. beta: number;
  6118. radius: number;
  6119. target: Nullable<AbstractMesh>;
  6120. private _cartesianCoordinates;
  6121. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  6122. private follow;
  6123. /** @hidden */
  6124. _checkInputs(): void;
  6125. getClassName(): string;
  6126. }
  6127. }
  6128. declare module BABYLON {
  6129. class FreeCamera extends TargetCamera {
  6130. ellipsoid: Vector3;
  6131. ellipsoidOffset: Vector3;
  6132. checkCollisions: boolean;
  6133. applyGravity: boolean;
  6134. inputs: FreeCameraInputsManager;
  6135. /**
  6136. * Gets the input sensibility for a mouse input. (default is 2000.0)
  6137. * Higher values reduce sensitivity.
  6138. */
  6139. /**
  6140. * Sets the input sensibility for a mouse input. (default is 2000.0)
  6141. * Higher values reduce sensitivity.
  6142. */
  6143. angularSensibility: number;
  6144. keysUp: number[];
  6145. keysDown: number[];
  6146. keysLeft: number[];
  6147. keysRight: number[];
  6148. onCollide: (collidedMesh: AbstractMesh) => void;
  6149. private _collider;
  6150. private _needMoveForGravity;
  6151. private _oldPosition;
  6152. private _diffPosition;
  6153. private _newPosition;
  6154. /** @hidden */
  6155. _localDirection: Vector3;
  6156. /** @hidden */
  6157. _transformedDirection: Vector3;
  6158. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6159. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6160. detachControl(element: HTMLElement): void;
  6161. private _collisionMask;
  6162. collisionMask: number;
  6163. /** @hidden */
  6164. _collideWithWorld(displacement: Vector3): void;
  6165. private _onCollisionPositionChange;
  6166. /** @hidden */
  6167. _checkInputs(): void;
  6168. /** @hidden */
  6169. _decideIfNeedsToMove(): boolean;
  6170. /** @hidden */
  6171. _updatePosition(): void;
  6172. dispose(): void;
  6173. getClassName(): string;
  6174. }
  6175. }
  6176. declare module BABYLON {
  6177. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  6178. constructor(camera: FreeCamera);
  6179. addKeyboard(): FreeCameraInputsManager;
  6180. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  6181. addDeviceOrientation(): FreeCameraInputsManager;
  6182. addTouch(): FreeCameraInputsManager;
  6183. addVirtualJoystick(): FreeCameraInputsManager;
  6184. }
  6185. }
  6186. declare module BABYLON {
  6187. class GamepadCamera extends UniversalCamera {
  6188. gamepadAngularSensibility: number;
  6189. gamepadMoveSensibility: number;
  6190. constructor(name: string, position: Vector3, scene: Scene);
  6191. getClassName(): string;
  6192. }
  6193. }
  6194. declare module BABYLON {
  6195. class TargetCamera extends Camera {
  6196. cameraDirection: Vector3;
  6197. cameraRotation: Vector2;
  6198. rotation: Vector3;
  6199. rotationQuaternion: Quaternion;
  6200. speed: number;
  6201. noRotationConstraint: boolean;
  6202. lockedTarget: any;
  6203. /** @hidden */
  6204. _currentTarget: Vector3;
  6205. /** @hidden */
  6206. _viewMatrix: Matrix;
  6207. /** @hidden */
  6208. _camMatrix: Matrix;
  6209. /** @hidden */
  6210. _cameraTransformMatrix: Matrix;
  6211. /** @hidden */
  6212. _cameraRotationMatrix: Matrix;
  6213. private _rigCamTransformMatrix;
  6214. /** @hidden */
  6215. _referencePoint: Vector3;
  6216. private _currentUpVector;
  6217. /** @hidden */
  6218. _transformedReferencePoint: Vector3;
  6219. protected _globalCurrentTarget: Vector3;
  6220. protected _globalCurrentUpVector: Vector3;
  6221. /** @hidden */
  6222. _reset: () => void;
  6223. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6224. getFrontPosition(distance: number): Vector3;
  6225. /** @hidden */
  6226. _getLockedTargetPosition(): Nullable<Vector3>;
  6227. /**
  6228. * Store current camera state (fov, position, etc..)
  6229. */
  6230. private _storedPosition;
  6231. private _storedRotation;
  6232. private _storedRotationQuaternion;
  6233. storeState(): Camera;
  6234. /**
  6235. * Restored camera state. You must call storeState() first
  6236. * @returns whether it was successful or not
  6237. * @hidden
  6238. */
  6239. _restoreStateValues(): boolean;
  6240. /** @hidden */
  6241. _initCache(): void;
  6242. /** @hidden */
  6243. _updateCache(ignoreParentClass?: boolean): void;
  6244. /** @hidden */
  6245. _isSynchronizedViewMatrix(): boolean;
  6246. /** @hidden */
  6247. _computeLocalCameraSpeed(): number;
  6248. /** @hidden */
  6249. setTarget(target: Vector3): void;
  6250. /**
  6251. * Return the current target position of the camera. This value is expressed in local space.
  6252. */
  6253. getTarget(): Vector3;
  6254. /** @hidden */
  6255. _decideIfNeedsToMove(): boolean;
  6256. /** @hidden */
  6257. _updatePosition(): void;
  6258. /** @hidden */
  6259. _checkInputs(): void;
  6260. protected _updateCameraRotationMatrix(): void;
  6261. /** @hidden */
  6262. _getViewMatrix(): Matrix;
  6263. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6264. /**
  6265. * @override
  6266. * Override Camera.createRigCamera
  6267. */
  6268. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6269. /**
  6270. * @hidden
  6271. * @override
  6272. * Override Camera._updateRigCameras
  6273. */
  6274. _updateRigCameras(): void;
  6275. private _getRigCamPosition;
  6276. getClassName(): string;
  6277. }
  6278. }
  6279. declare module BABYLON {
  6280. class TouchCamera extends FreeCamera {
  6281. touchAngularSensibility: number;
  6282. touchMoveSensibility: number;
  6283. constructor(name: string, position: Vector3, scene: Scene);
  6284. getClassName(): string;
  6285. /** @hidden */
  6286. _setupInputs(): void;
  6287. }
  6288. }
  6289. declare module BABYLON {
  6290. class UniversalCamera extends TouchCamera {
  6291. gamepadAngularSensibility: number;
  6292. gamepadMoveSensibility: number;
  6293. constructor(name: string, position: Vector3, scene: Scene);
  6294. getClassName(): string;
  6295. }
  6296. }
  6297. declare module BABYLON {
  6298. class VirtualJoysticksCamera extends FreeCamera {
  6299. constructor(name: string, position: Vector3, scene: Scene);
  6300. getClassName(): string;
  6301. }
  6302. }
  6303. interface VRDisplay extends EventTarget {
  6304. /**
  6305. * Dictionary of capabilities describing the VRDisplay.
  6306. */
  6307. readonly capabilities: VRDisplayCapabilities;
  6308. /**
  6309. * z-depth defining the far plane of the eye view frustum
  6310. * enables mapping of values in the render target depth
  6311. * attachment to scene coordinates. Initially set to 10000.0.
  6312. */
  6313. depthFar: number;
  6314. /**
  6315. * z-depth defining the near plane of the eye view frustum
  6316. * enables mapping of values in the render target depth
  6317. * attachment to scene coordinates. Initially set to 0.01.
  6318. */
  6319. depthNear: number;
  6320. /**
  6321. * An identifier for this distinct VRDisplay. Used as an
  6322. * association point in the Gamepad API.
  6323. */
  6324. readonly displayId: number;
  6325. /**
  6326. * A display name, a user-readable name identifying it.
  6327. */
  6328. readonly displayName: string;
  6329. readonly isConnected: boolean;
  6330. readonly isPresenting: boolean;
  6331. /**
  6332. * If this VRDisplay supports room-scale experiences, the optional
  6333. * stage attribute contains details on the room-scale parameters.
  6334. */
  6335. readonly stageParameters: VRStageParameters | null;
  6336. /**
  6337. * Passing the value returned by `requestAnimationFrame` to
  6338. * `cancelAnimationFrame` will unregister the callback.
  6339. */
  6340. cancelAnimationFrame(handle: number): void;
  6341. /**
  6342. * Stops presenting to the VRDisplay.
  6343. */
  6344. exitPresent(): Promise<void>;
  6345. getEyeParameters(whichEye: string): VREyeParameters;
  6346. /**
  6347. * Populates the passed VRFrameData with the information required to render
  6348. * the current frame.
  6349. */
  6350. getFrameData(frameData: VRFrameData): boolean;
  6351. /**
  6352. * Get the layers currently being presented.
  6353. */
  6354. getLayers(): VRLayer[];
  6355. /**
  6356. * Return a VRPose containing the future predicted pose of the VRDisplay
  6357. * when the current frame will be presented. The value returned will not
  6358. * change until JavaScript has returned control to the browser.
  6359. *
  6360. * The VRPose will contain the position, orientation, velocity,
  6361. * and acceleration of each of these properties.
  6362. */
  6363. getPose(): VRPose;
  6364. /**
  6365. * Return the current instantaneous pose of the VRDisplay, with no
  6366. * prediction applied.
  6367. */
  6368. getImmediatePose(): VRPose;
  6369. /**
  6370. * The callback passed to `requestAnimationFrame` will be called
  6371. * any time a new frame should be rendered. When the VRDisplay is
  6372. * presenting the callback will be called at the native refresh
  6373. * rate of the HMD. When not presenting this function acts
  6374. * identically to how window.requestAnimationFrame acts. Content should
  6375. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6376. * asynchronously from other displays and at differing refresh rates.
  6377. */
  6378. requestAnimationFrame(callback: FrameRequestCallback): number;
  6379. /**
  6380. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6381. * Repeat calls while already presenting will update the VRLayers being displayed.
  6382. */
  6383. requestPresent(layers: VRLayer[]): Promise<void>;
  6384. /**
  6385. * Reset the pose for this display, treating its current position and
  6386. * orientation as the "origin/zero" values. VRPose.position,
  6387. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6388. * updated when calling resetPose(). This should be called in only
  6389. * sitting-space experiences.
  6390. */
  6391. resetPose(): void;
  6392. /**
  6393. * The VRLayer provided to the VRDisplay will be captured and presented
  6394. * in the HMD. Calling this function has the same effect on the source
  6395. * canvas as any other operation that uses its source image, and canvases
  6396. * created without preserveDrawingBuffer set to true will be cleared.
  6397. */
  6398. submitFrame(pose?: VRPose): void;
  6399. }
  6400. declare var VRDisplay: {
  6401. prototype: VRDisplay;
  6402. new (): VRDisplay;
  6403. };
  6404. interface VRLayer {
  6405. leftBounds?: number[] | null;
  6406. rightBounds?: number[] | null;
  6407. source?: HTMLCanvasElement | null;
  6408. }
  6409. interface VRDisplayCapabilities {
  6410. readonly canPresent: boolean;
  6411. readonly hasExternalDisplay: boolean;
  6412. readonly hasOrientation: boolean;
  6413. readonly hasPosition: boolean;
  6414. readonly maxLayers: number;
  6415. }
  6416. interface VREyeParameters {
  6417. /** @deprecated */
  6418. readonly fieldOfView: VRFieldOfView;
  6419. readonly offset: Float32Array;
  6420. readonly renderHeight: number;
  6421. readonly renderWidth: number;
  6422. }
  6423. interface VRFieldOfView {
  6424. readonly downDegrees: number;
  6425. readonly leftDegrees: number;
  6426. readonly rightDegrees: number;
  6427. readonly upDegrees: number;
  6428. }
  6429. interface VRFrameData {
  6430. readonly leftProjectionMatrix: Float32Array;
  6431. readonly leftViewMatrix: Float32Array;
  6432. readonly pose: VRPose;
  6433. readonly rightProjectionMatrix: Float32Array;
  6434. readonly rightViewMatrix: Float32Array;
  6435. readonly timestamp: number;
  6436. }
  6437. interface VRPose {
  6438. readonly angularAcceleration: Float32Array | null;
  6439. readonly angularVelocity: Float32Array | null;
  6440. readonly linearAcceleration: Float32Array | null;
  6441. readonly linearVelocity: Float32Array | null;
  6442. readonly orientation: Float32Array | null;
  6443. readonly position: Float32Array | null;
  6444. readonly timestamp: number;
  6445. }
  6446. interface VRStageParameters {
  6447. sittingToStandingTransform?: Float32Array;
  6448. sizeX?: number;
  6449. sizeY?: number;
  6450. }
  6451. interface Navigator {
  6452. getVRDisplays(): Promise<VRDisplay[]>;
  6453. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6454. }
  6455. interface Window {
  6456. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6457. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6458. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6459. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6460. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6461. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6462. }
  6463. interface Gamepad {
  6464. readonly displayId: number;
  6465. }
  6466. declare module BABYLON {
  6467. class Collider {
  6468. /** Define if a collision was found */
  6469. collisionFound: boolean;
  6470. /**
  6471. * Define last intersection point in local space
  6472. */
  6473. intersectionPoint: Vector3;
  6474. /**
  6475. * Define last collided mesh
  6476. */
  6477. collidedMesh: Nullable<AbstractMesh>;
  6478. private _collisionPoint;
  6479. private _planeIntersectionPoint;
  6480. private _tempVector;
  6481. private _tempVector2;
  6482. private _tempVector3;
  6483. private _tempVector4;
  6484. private _edge;
  6485. private _baseToVertex;
  6486. private _destinationPoint;
  6487. private _slidePlaneNormal;
  6488. private _displacementVector;
  6489. /** @hidden */
  6490. _radius: Vector3;
  6491. /** @hidden */
  6492. _retry: number;
  6493. private _velocity;
  6494. private _basePoint;
  6495. private _epsilon;
  6496. /** @hidden */
  6497. _velocityWorldLength: number;
  6498. /** @hidden */
  6499. _basePointWorld: Vector3;
  6500. private _velocityWorld;
  6501. private _normalizedVelocity;
  6502. /** @hidden */
  6503. _initialVelocity: Vector3;
  6504. /** @hidden */
  6505. _initialPosition: Vector3;
  6506. private _nearestDistance;
  6507. private _collisionMask;
  6508. collisionMask: number;
  6509. /**
  6510. * Gets the plane normal used to compute the sliding response (in local space)
  6511. */
  6512. readonly slidePlaneNormal: Vector3;
  6513. /** @hidden */
  6514. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6515. /** @hidden */
  6516. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6517. /** @hidden */
  6518. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6519. /** @hidden */
  6520. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6521. /** @hidden */
  6522. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6523. /** @hidden */
  6524. _getResponse(pos: Vector3, vel: Vector3): void;
  6525. }
  6526. }
  6527. declare module BABYLON {
  6528. var CollisionWorker: string;
  6529. interface ICollisionCoordinator {
  6530. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6531. init(scene: Scene): void;
  6532. destroy(): void;
  6533. onMeshAdded(mesh: AbstractMesh): void;
  6534. onMeshUpdated(mesh: AbstractMesh): void;
  6535. onMeshRemoved(mesh: AbstractMesh): void;
  6536. onGeometryAdded(geometry: Geometry): void;
  6537. onGeometryUpdated(geometry: Geometry): void;
  6538. onGeometryDeleted(geometry: Geometry): void;
  6539. }
  6540. interface SerializedMesh {
  6541. id: string;
  6542. name: string;
  6543. uniqueId: number;
  6544. geometryId: Nullable<string>;
  6545. sphereCenter: Array<number>;
  6546. sphereRadius: number;
  6547. boxMinimum: Array<number>;
  6548. boxMaximum: Array<number>;
  6549. worldMatrixFromCache: any;
  6550. subMeshes: Array<SerializedSubMesh>;
  6551. checkCollisions: boolean;
  6552. }
  6553. interface SerializedSubMesh {
  6554. position: number;
  6555. verticesStart: number;
  6556. verticesCount: number;
  6557. indexStart: number;
  6558. indexCount: number;
  6559. hasMaterial: boolean;
  6560. sphereCenter: Array<number>;
  6561. sphereRadius: number;
  6562. boxMinimum: Array<number>;
  6563. boxMaximum: Array<number>;
  6564. }
  6565. /**
  6566. * Interface describing the value associated with a geometry
  6567. */
  6568. interface SerializedGeometry {
  6569. /**
  6570. * Defines the unique ID of the geometry
  6571. */
  6572. id: string;
  6573. /**
  6574. * Defines the array containing the positions
  6575. */
  6576. positions: Float32Array;
  6577. /**
  6578. * Defines the array containing the indices
  6579. */
  6580. indices: Uint32Array;
  6581. /**
  6582. * Defines the array containing the normals
  6583. */
  6584. normals: Float32Array;
  6585. }
  6586. interface BabylonMessage {
  6587. taskType: WorkerTaskType;
  6588. payload: InitPayload | CollidePayload | UpdatePayload;
  6589. }
  6590. interface SerializedColliderToWorker {
  6591. position: Array<number>;
  6592. velocity: Array<number>;
  6593. radius: Array<number>;
  6594. }
  6595. /** Defines supported task for worker process */
  6596. enum WorkerTaskType {
  6597. /** Initialization */
  6598. INIT = 0,
  6599. /** Update of geometry */
  6600. UPDATE = 1,
  6601. /** Evaluate collision */
  6602. COLLIDE = 2
  6603. }
  6604. interface WorkerReply {
  6605. error: WorkerReplyType;
  6606. taskType: WorkerTaskType;
  6607. payload?: any;
  6608. }
  6609. interface CollisionReplyPayload {
  6610. newPosition: Array<number>;
  6611. collisionId: number;
  6612. collidedMeshUniqueId: number;
  6613. }
  6614. interface InitPayload {
  6615. }
  6616. interface CollidePayload {
  6617. collisionId: number;
  6618. collider: SerializedColliderToWorker;
  6619. maximumRetry: number;
  6620. excludedMeshUniqueId: Nullable<number>;
  6621. }
  6622. interface UpdatePayload {
  6623. updatedMeshes: {
  6624. [n: number]: SerializedMesh;
  6625. };
  6626. updatedGeometries: {
  6627. [s: string]: SerializedGeometry;
  6628. };
  6629. removedMeshes: Array<number>;
  6630. removedGeometries: Array<string>;
  6631. }
  6632. /** Defines kind of replies returned by worker */
  6633. enum WorkerReplyType {
  6634. /** Success */
  6635. SUCCESS = 0,
  6636. /** Unkown error */
  6637. UNKNOWN_ERROR = 1
  6638. }
  6639. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6640. private _scene;
  6641. private _scaledPosition;
  6642. private _scaledVelocity;
  6643. private _collisionsCallbackArray;
  6644. private _init;
  6645. private _runningUpdated;
  6646. private _worker;
  6647. private _addUpdateMeshesList;
  6648. private _addUpdateGeometriesList;
  6649. private _toRemoveMeshesArray;
  6650. private _toRemoveGeometryArray;
  6651. constructor();
  6652. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  6653. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  6654. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6655. init(scene: Scene): void;
  6656. destroy(): void;
  6657. onMeshAdded(mesh: AbstractMesh): void;
  6658. onMeshUpdated: (transformNode: TransformNode) => void;
  6659. onMeshRemoved(mesh: AbstractMesh): void;
  6660. onGeometryAdded(geometry: Geometry): void;
  6661. onGeometryUpdated: (geometry: Geometry) => void;
  6662. onGeometryDeleted(geometry: Geometry): void;
  6663. private _afterRender;
  6664. private _onMessageFromWorker;
  6665. }
  6666. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  6667. private _scene;
  6668. private _scaledPosition;
  6669. private _scaledVelocity;
  6670. private _finalPosition;
  6671. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6672. init(scene: Scene): void;
  6673. destroy(): void;
  6674. onMeshAdded(mesh: AbstractMesh): void;
  6675. onMeshUpdated(mesh: AbstractMesh): void;
  6676. onMeshRemoved(mesh: AbstractMesh): void;
  6677. onGeometryAdded(geometry: Geometry): void;
  6678. onGeometryUpdated(geometry: Geometry): void;
  6679. onGeometryDeleted(geometry: Geometry): void;
  6680. private _collideWithWorld;
  6681. }
  6682. }
  6683. declare function importScripts(...urls: string[]): void;
  6684. declare const safePostMessage: any;
  6685. declare module BABYLON {
  6686. var WorkerIncluded: boolean;
  6687. class CollisionCache {
  6688. private _meshes;
  6689. private _geometries;
  6690. getMeshes(): {
  6691. [n: number]: SerializedMesh;
  6692. };
  6693. getGeometries(): {
  6694. [s: number]: SerializedGeometry;
  6695. };
  6696. getMesh(id: any): SerializedMesh;
  6697. addMesh(mesh: SerializedMesh): void;
  6698. removeMesh(uniqueId: number): void;
  6699. getGeometry(id: string): SerializedGeometry;
  6700. addGeometry(geometry: SerializedGeometry): void;
  6701. removeGeometry(id: string): void;
  6702. }
  6703. class CollideWorker {
  6704. collider: Collider;
  6705. private _collisionCache;
  6706. private finalPosition;
  6707. private collisionsScalingMatrix;
  6708. private collisionTranformationMatrix;
  6709. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  6710. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  6711. private checkCollision;
  6712. private processCollisionsForSubMeshes;
  6713. private collideForSubMesh;
  6714. private checkSubmeshCollision;
  6715. }
  6716. interface ICollisionDetector {
  6717. onInit(payload: InitPayload): void;
  6718. onUpdate(payload: UpdatePayload): void;
  6719. onCollision(payload: CollidePayload): void;
  6720. }
  6721. class CollisionDetectorTransferable implements ICollisionDetector {
  6722. private _collisionCache;
  6723. onInit(payload: InitPayload): void;
  6724. onUpdate(payload: UpdatePayload): void;
  6725. onCollision(payload: CollidePayload): void;
  6726. }
  6727. }
  6728. declare module BABYLON {
  6729. class IntersectionInfo {
  6730. bu: Nullable<number>;
  6731. bv: Nullable<number>;
  6732. distance: number;
  6733. faceId: number;
  6734. subMeshId: number;
  6735. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6736. }
  6737. /**
  6738. * Information about the result of picking within a scene
  6739. * See https://doc.babylonjs.com/babylon101/picking_collisions
  6740. */
  6741. class PickingInfo {
  6742. /**
  6743. * If the pick collided with an object
  6744. */
  6745. hit: boolean;
  6746. /**
  6747. * Distance away where the pick collided
  6748. */
  6749. distance: number;
  6750. /**
  6751. * The location of pick collision
  6752. */
  6753. pickedPoint: Nullable<Vector3>;
  6754. /**
  6755. * The mesh corresponding the the pick collision
  6756. */
  6757. pickedMesh: Nullable<AbstractMesh>;
  6758. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  6759. bu: number;
  6760. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  6761. bv: number;
  6762. /** The id of the face on the mesh that was picked */
  6763. faceId: number;
  6764. /** Id of the the submesh that was picked */
  6765. subMeshId: number;
  6766. /** If a sprite was picked, this will be the sprite the pick collided with */
  6767. pickedSprite: Nullable<Sprite>;
  6768. /**
  6769. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  6770. */
  6771. originMesh: Nullable<AbstractMesh>;
  6772. /**
  6773. * The ray that was used to perform the picking.
  6774. */
  6775. ray: Nullable<Ray>;
  6776. /**
  6777. * Gets the normal correspodning to the face the pick collided with
  6778. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  6779. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  6780. * @returns The normal correspodning to the face the pick collided with
  6781. */
  6782. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  6783. /**
  6784. * Gets the texture coordinates of where the pick occured
  6785. * @returns the vector containing the coordnates of the texture
  6786. */
  6787. getTextureCoordinates(): Nullable<Vector2>;
  6788. }
  6789. }
  6790. declare module BABYLON {
  6791. class BoundingBox implements ICullable {
  6792. vectors: Vector3[];
  6793. center: Vector3;
  6794. centerWorld: Vector3;
  6795. extendSize: Vector3;
  6796. extendSizeWorld: Vector3;
  6797. directions: Vector3[];
  6798. vectorsWorld: Vector3[];
  6799. minimumWorld: Vector3;
  6800. maximumWorld: Vector3;
  6801. minimum: Vector3;
  6802. maximum: Vector3;
  6803. private _worldMatrix;
  6804. /**
  6805. * Creates a new bounding box
  6806. * @param min defines the minimum vector (in local space)
  6807. * @param max defines the maximum vector (in local space)
  6808. */
  6809. constructor(min: Vector3, max: Vector3);
  6810. /**
  6811. * Recreates the entire bounding box from scratch
  6812. * @param min defines the new minimum vector (in local space)
  6813. * @param max defines the new maximum vector (in local space)
  6814. */
  6815. reConstruct(min: Vector3, max: Vector3): void;
  6816. /**
  6817. * Scale the current bounding box by applying a scale factor
  6818. * @param factor defines the scale factor to apply
  6819. * @returns the current bounding box
  6820. */
  6821. scale(factor: number): BoundingBox;
  6822. getWorldMatrix(): Matrix;
  6823. setWorldMatrix(matrix: Matrix): BoundingBox;
  6824. /** @hidden */
  6825. _update(world: Matrix): void;
  6826. isInFrustum(frustumPlanes: Plane[]): boolean;
  6827. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6828. intersectsPoint(point: Vector3): boolean;
  6829. intersectsSphere(sphere: BoundingSphere): boolean;
  6830. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  6831. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  6832. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  6833. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6834. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6835. }
  6836. }
  6837. declare module BABYLON {
  6838. interface ICullable {
  6839. isInFrustum(frustumPlanes: Plane[]): boolean;
  6840. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6841. }
  6842. class BoundingInfo implements ICullable {
  6843. minimum: Vector3;
  6844. maximum: Vector3;
  6845. boundingBox: BoundingBox;
  6846. boundingSphere: BoundingSphere;
  6847. private _isLocked;
  6848. constructor(minimum: Vector3, maximum: Vector3);
  6849. isLocked: boolean;
  6850. update(world: Matrix): void;
  6851. /**
  6852. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6853. * @param center New center of the bounding info
  6854. * @param extend New extend of the bounding info
  6855. */
  6856. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  6857. /**
  6858. * Scale the current bounding info by applying a scale factor
  6859. * @param factor defines the scale factor to apply
  6860. * @returns the current bounding info
  6861. */
  6862. scale(factor: number): BoundingInfo;
  6863. isInFrustum(frustumPlanes: Plane[]): boolean;
  6864. /**
  6865. * Gets the world distance between the min and max points of the bounding box
  6866. */
  6867. readonly diagonalLength: number;
  6868. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6869. /** @hidden */
  6870. _checkCollision(collider: Collider): boolean;
  6871. intersectsPoint(point: Vector3): boolean;
  6872. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  6873. }
  6874. }
  6875. declare module BABYLON {
  6876. class BoundingSphere {
  6877. center: Vector3;
  6878. radius: number;
  6879. centerWorld: Vector3;
  6880. radiusWorld: number;
  6881. minimum: Vector3;
  6882. maximum: Vector3;
  6883. private _tempRadiusVector;
  6884. /**
  6885. * Creates a new bounding sphere
  6886. * @param min defines the minimum vector (in local space)
  6887. * @param max defines the maximum vector (in local space)
  6888. */
  6889. constructor(min: Vector3, max: Vector3);
  6890. /**
  6891. * Recreates the entire bounding sphere from scratch
  6892. * @param min defines the new minimum vector (in local space)
  6893. * @param max defines the new maximum vector (in local space)
  6894. */
  6895. reConstruct(min: Vector3, max: Vector3): void;
  6896. /**
  6897. * Scale the current bounding sphere by applying a scale factor
  6898. * @param factor defines the scale factor to apply
  6899. * @returns the current bounding box
  6900. */
  6901. scale(factor: number): BoundingSphere;
  6902. /** @hidden */
  6903. _update(world: Matrix): void;
  6904. isInFrustum(frustumPlanes: Plane[]): boolean;
  6905. intersectsPoint(point: Vector3): boolean;
  6906. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  6907. }
  6908. }
  6909. declare module BABYLON {
  6910. class Ray {
  6911. origin: Vector3;
  6912. direction: Vector3;
  6913. length: number;
  6914. private _edge1;
  6915. private _edge2;
  6916. private _pvec;
  6917. private _tvec;
  6918. private _qvec;
  6919. private _tmpRay;
  6920. constructor(origin: Vector3, direction: Vector3, length?: number);
  6921. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  6922. intersectsBox(box: BoundingBox): boolean;
  6923. intersectsSphere(sphere: BoundingSphere): boolean;
  6924. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  6925. intersectsPlane(plane: Plane): Nullable<number>;
  6926. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  6927. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  6928. private _comparePickingInfo;
  6929. private static smallnum;
  6930. private static rayl;
  6931. /**
  6932. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  6933. * @param sega the first point of the segment to test the intersection against
  6934. * @param segb the second point of the segment to test the intersection against
  6935. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  6936. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  6937. */
  6938. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  6939. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6940. static Zero(): Ray;
  6941. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6942. /**
  6943. * 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
  6944. * transformed to the given world matrix.
  6945. * @param origin The origin point
  6946. * @param end The end point
  6947. * @param world a matrix to transform the ray to. Default is the identity matrix.
  6948. */
  6949. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  6950. static Transform(ray: Ray, matrix: Matrix): Ray;
  6951. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  6952. }
  6953. }
  6954. /**
  6955. * Module Debug contains the (visual) components to debug a scene correctly
  6956. */
  6957. declare module BABYLON.Debug {
  6958. /**
  6959. * The Axes viewer will show 3 axes in a specific point in space
  6960. */
  6961. class AxesViewer {
  6962. private _xline;
  6963. private _yline;
  6964. private _zline;
  6965. private _xmesh;
  6966. private _ymesh;
  6967. private _zmesh;
  6968. /**
  6969. * Gets the hosting scene
  6970. */
  6971. scene: Nullable<Scene>;
  6972. /**
  6973. * Gets or sets a number used to scale line length
  6974. */
  6975. scaleLines: number;
  6976. /**
  6977. * Creates a new AxesViewer
  6978. * @param scene defines the hosting scene
  6979. * @param scaleLines defines a number used to scale line length (1 by default)
  6980. */
  6981. constructor(scene: Scene, scaleLines?: number);
  6982. /**
  6983. * Force the viewer to update
  6984. * @param position defines the position of the viewer
  6985. * @param xaxis defines the x axis of the viewer
  6986. * @param yaxis defines the y axis of the viewer
  6987. * @param zaxis defines the z axis of the viewer
  6988. */
  6989. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  6990. /** Releases resources */
  6991. dispose(): void;
  6992. }
  6993. }
  6994. declare module BABYLON.Debug {
  6995. /**
  6996. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  6997. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  6998. */
  6999. class BoneAxesViewer extends AxesViewer {
  7000. /**
  7001. * Gets or sets the target mesh where to display the axes viewer
  7002. */
  7003. mesh: Nullable<Mesh>;
  7004. /**
  7005. * Gets or sets the target bone where to display the axes viewer
  7006. */
  7007. bone: Nullable<Bone>;
  7008. /** Gets current position */
  7009. pos: Vector3;
  7010. /** Gets direction of X axis */
  7011. xaxis: Vector3;
  7012. /** Gets direction of Y axis */
  7013. yaxis: Vector3;
  7014. /** Gets direction of Z axis */
  7015. zaxis: Vector3;
  7016. /**
  7017. * Creates a new BoneAxesViewer
  7018. * @param scene defines the hosting scene
  7019. * @param bone defines the target bone
  7020. * @param mesh defines the target mesh
  7021. * @param scaleLines defines a scaling factor for line length (1 by default)
  7022. */
  7023. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  7024. /**
  7025. * Force the viewer to update
  7026. */
  7027. update(): void;
  7028. /** Releases resources */
  7029. dispose(): void;
  7030. }
  7031. }
  7032. declare module BABYLON {
  7033. class DebugLayer {
  7034. private _scene;
  7035. static InspectorURL: string;
  7036. private _inspector;
  7037. private BJSINSPECTOR;
  7038. onPropertyChangedObservable: Observable<{
  7039. object: any;
  7040. property: string;
  7041. value: any;
  7042. initialValue: any;
  7043. }>;
  7044. constructor(scene: Scene);
  7045. /** Creates the inspector window. */
  7046. private _createInspector;
  7047. isVisible(): boolean;
  7048. hide(): void;
  7049. /**
  7050. *
  7051. * Launch the debugLayer.
  7052. *
  7053. * initialTab:
  7054. * | Value | Tab Name |
  7055. * | --- | --- |
  7056. * | 0 | Scene |
  7057. * | 1 | Console |
  7058. * | 2 | Stats |
  7059. * | 3 | Textures |
  7060. * | 4 | Mesh |
  7061. * | 5 | Light |
  7062. * | 6 | Material |
  7063. * | 7 | GLTF |
  7064. * | 8 | GUI |
  7065. * | 9 | Physics |
  7066. * | 10 | Camera |
  7067. * | 11 | Audio |
  7068. *
  7069. */
  7070. show(config?: {
  7071. popup?: boolean;
  7072. initialTab?: number;
  7073. parentElement?: HTMLElement;
  7074. newColors?: {
  7075. backgroundColor?: string;
  7076. backgroundColorLighter?: string;
  7077. backgroundColorLighter2?: string;
  7078. backgroundColorLighter3?: string;
  7079. color?: string;
  7080. colorTop?: string;
  7081. colorBot?: string;
  7082. };
  7083. }): void;
  7084. /**
  7085. * Gets the active tab
  7086. * @return the index of the active tab or -1 if the inspector is hidden
  7087. */
  7088. getActiveTab(): number;
  7089. }
  7090. }
  7091. declare module BABYLON.Debug {
  7092. /**
  7093. * Used to show the physics impostor around the specific mesh
  7094. */
  7095. class PhysicsViewer {
  7096. /** @hidden */
  7097. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  7098. /** @hidden */
  7099. protected _meshes: Array<Nullable<AbstractMesh>>;
  7100. /** @hidden */
  7101. protected _scene: Nullable<Scene>;
  7102. /** @hidden */
  7103. protected _numMeshes: number;
  7104. /** @hidden */
  7105. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  7106. private _renderFunction;
  7107. private _debugBoxMesh;
  7108. private _debugSphereMesh;
  7109. private _debugMaterial;
  7110. /**
  7111. * Creates a new PhysicsViewer
  7112. * @param scene defines the hosting scene
  7113. */
  7114. constructor(scene: Scene);
  7115. /** @hidden */
  7116. protected _updateDebugMeshes(): void;
  7117. /**
  7118. * Renders a specified physic impostor
  7119. * @param impostor defines the impostor to render
  7120. */
  7121. showImpostor(impostor: PhysicsImpostor): void;
  7122. /**
  7123. * Hides a specified physic impostor
  7124. * @param impostor defines the impostor to hide
  7125. */
  7126. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  7127. private _getDebugMaterial;
  7128. private _getDebugBoxMesh;
  7129. private _getDebugSphereMesh;
  7130. private _getDebugMesh;
  7131. /** Releases all resources */
  7132. dispose(): void;
  7133. }
  7134. }
  7135. declare module BABYLON {
  7136. class RayHelper {
  7137. ray: Nullable<Ray>;
  7138. private _renderPoints;
  7139. private _renderLine;
  7140. private _renderFunction;
  7141. private _scene;
  7142. private _updateToMeshFunction;
  7143. private _attachedToMesh;
  7144. private _meshSpaceDirection;
  7145. private _meshSpaceOrigin;
  7146. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  7147. constructor(ray: Ray);
  7148. show(scene: Scene, color?: Color3): void;
  7149. hide(): void;
  7150. private _render;
  7151. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  7152. detachFromMesh(): void;
  7153. private _updateToMesh;
  7154. dispose(): void;
  7155. }
  7156. }
  7157. declare module BABYLON.Debug {
  7158. /**
  7159. * Class used to render a debug view of a given skeleton
  7160. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  7161. */
  7162. class SkeletonViewer {
  7163. /** defines the skeleton to render */
  7164. skeleton: Skeleton;
  7165. /** defines the mesh attached to the skeleton */
  7166. mesh: AbstractMesh;
  7167. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  7168. autoUpdateBonesMatrices: boolean;
  7169. /** defines the rendering group id to use with the viewer */
  7170. renderingGroupId: number;
  7171. /** Gets or sets the color used to render the skeleton */
  7172. color: Color3;
  7173. private _scene;
  7174. private _debugLines;
  7175. private _debugMesh;
  7176. private _isEnabled;
  7177. private _renderFunction;
  7178. /**
  7179. * Creates a new SkeletonViewer
  7180. * @param skeleton defines the skeleton to render
  7181. * @param mesh defines the mesh attached to the skeleton
  7182. * @param scene defines the hosting scene
  7183. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  7184. * @param renderingGroupId defines the rendering group id to use with the viewer
  7185. */
  7186. constructor(
  7187. /** defines the skeleton to render */
  7188. skeleton: Skeleton,
  7189. /** defines the mesh attached to the skeleton */
  7190. mesh: AbstractMesh, scene: Scene,
  7191. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  7192. autoUpdateBonesMatrices?: boolean,
  7193. /** defines the rendering group id to use with the viewer */
  7194. renderingGroupId?: number);
  7195. /** Gets or sets a boolean indicating if the viewer is enabled */
  7196. isEnabled: boolean;
  7197. private _getBonePosition;
  7198. private _getLinesForBonesWithLength;
  7199. private _getLinesForBonesNoLength;
  7200. /** Update the viewer to sync with current skeleton state */
  7201. update(): void;
  7202. /** Release associated resources */
  7203. dispose(): void;
  7204. }
  7205. }
  7206. declare module BABYLON {
  7207. /**
  7208. * Interface for attribute information associated with buffer instanciation
  7209. */
  7210. class InstancingAttributeInfo {
  7211. /**
  7212. * Index/offset of the attribute in the vertex shader
  7213. */
  7214. index: number;
  7215. /**
  7216. * size of the attribute, 1, 2, 3 or 4
  7217. */
  7218. attributeSize: number;
  7219. /**
  7220. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  7221. * default is FLOAT
  7222. */
  7223. attribyteType: number;
  7224. /**
  7225. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  7226. */
  7227. normalized: boolean;
  7228. /**
  7229. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  7230. */
  7231. offset: number;
  7232. /**
  7233. * Name of the GLSL attribute, for debugging purpose only
  7234. */
  7235. attributeName: string;
  7236. }
  7237. /**
  7238. * Define options used to create a render target texture
  7239. */
  7240. class RenderTargetCreationOptions {
  7241. /**
  7242. * Specifies is mipmaps must be generated
  7243. */
  7244. generateMipMaps?: boolean;
  7245. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  7246. generateDepthBuffer?: boolean;
  7247. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  7248. generateStencilBuffer?: boolean;
  7249. /** Defines texture type (int by default) */
  7250. type?: number;
  7251. /** Defines sampling mode (trilinear by default) */
  7252. samplingMode?: number;
  7253. /** Defines format (RGBA by default) */
  7254. format?: number;
  7255. }
  7256. /**
  7257. * Define options used to create a depth texture
  7258. */
  7259. class DepthTextureCreationOptions {
  7260. /** Specifies whether or not a stencil should be allocated in the texture */
  7261. generateStencil?: boolean;
  7262. /** Specifies whether or not bilinear filtering is enable on the texture */
  7263. bilinearFiltering?: boolean;
  7264. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7265. comparisonFunction?: number;
  7266. /** Specifies if the created texture is a cube texture */
  7267. isCube?: boolean;
  7268. }
  7269. /**
  7270. * Class used to describe the capabilities of the engine relatively to the current browser
  7271. */
  7272. class EngineCapabilities {
  7273. /** Maximum textures units per fragment shader */
  7274. maxTexturesImageUnits: number;
  7275. /** Maximum texture units per vertex shader */
  7276. maxVertexTextureImageUnits: number;
  7277. /** Maximum textures units in the entire pipeline */
  7278. maxCombinedTexturesImageUnits: number;
  7279. /** Maximum texture size */
  7280. maxTextureSize: number;
  7281. /** Maximum cube texture size */
  7282. maxCubemapTextureSize: number;
  7283. /** Maximum render texture size */
  7284. maxRenderTextureSize: number;
  7285. /** Maximum number of vertex attributes */
  7286. maxVertexAttribs: number;
  7287. /** Maximum number of varyings */
  7288. maxVaryingVectors: number;
  7289. /** Maximum number of uniforms per vertex shader */
  7290. maxVertexUniformVectors: number;
  7291. /** Maximum number of uniforms per fragment shader */
  7292. maxFragmentUniformVectors: number;
  7293. /** Defines if standard derivates (dx/dy) are supported */
  7294. standardDerivatives: boolean;
  7295. /** Defines if s3tc texture compression is supported */
  7296. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  7297. /** Defines if pvrtc texture compression is supported */
  7298. pvrtc: any;
  7299. /** Defines if etc1 texture compression is supported */
  7300. etc1: any;
  7301. /** Defines if etc2 texture compression is supported */
  7302. etc2: any;
  7303. /** Defines if astc texture compression is supported */
  7304. astc: any;
  7305. /** Defines if float textures are supported */
  7306. textureFloat: boolean;
  7307. /** Defines if vertex array objects are supported */
  7308. vertexArrayObject: boolean;
  7309. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  7310. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  7311. /** Gets the maximum level of anisotropy supported */
  7312. maxAnisotropy: number;
  7313. /** Defines if instancing is supported */
  7314. instancedArrays: boolean;
  7315. /** Defines if 32 bits indices are supported */
  7316. uintIndices: boolean;
  7317. /** Defines if high precision shaders are supported */
  7318. highPrecisionShaderSupported: boolean;
  7319. /** Defines if depth reading in the fragment shader is supported */
  7320. fragmentDepthSupported: boolean;
  7321. /** Defines if float texture linear filtering is supported*/
  7322. textureFloatLinearFiltering: boolean;
  7323. /** Defines if rendering to float textures is supported */
  7324. textureFloatRender: boolean;
  7325. /** Defines if half float textures are supported*/
  7326. textureHalfFloat: boolean;
  7327. /** Defines if half float texture linear filtering is supported*/
  7328. textureHalfFloatLinearFiltering: boolean;
  7329. /** Defines if rendering to half float textures is supported */
  7330. textureHalfFloatRender: boolean;
  7331. /** Defines if textureLOD shader command is supported */
  7332. textureLOD: boolean;
  7333. /** Defines if draw buffers extension is supported */
  7334. drawBuffersExtension: boolean;
  7335. /** Defines if depth textures are supported */
  7336. depthTextureExtension: boolean;
  7337. /** Defines if float color buffer are supported */
  7338. colorBufferFloat: boolean;
  7339. /** Gets disjoint timer query extension (null if not supported) */
  7340. timerQuery: EXT_disjoint_timer_query;
  7341. /** Defines if timestamp can be used with timer query */
  7342. canUseTimestampForTimerQuery: boolean;
  7343. }
  7344. /** Interface defining initialization parameters for Engine class */
  7345. interface EngineOptions extends WebGLContextAttributes {
  7346. /**
  7347. * Defines if the engine should no exceed a specified device ratio
  7348. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  7349. */
  7350. limitDeviceRatio?: number;
  7351. /**
  7352. * Defines if webvr should be enabled automatically
  7353. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7354. */
  7355. autoEnableWebVR?: boolean;
  7356. /**
  7357. * Defines if webgl2 should be turned off even if supported
  7358. * @see http://doc.babylonjs.com/features/webgl2
  7359. */
  7360. disableWebGL2Support?: boolean;
  7361. /**
  7362. * Defines if webaudio should be initialized as well
  7363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7364. */
  7365. audioEngine?: boolean;
  7366. /**
  7367. * Defines if animations should run using a deterministic lock step
  7368. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7369. */
  7370. deterministicLockstep?: boolean;
  7371. /** Defines the maximum steps to use with deterministic lock step mode */
  7372. lockstepMaxSteps?: number;
  7373. /**
  7374. * Defines that engine should ignore context lost events
  7375. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  7376. */
  7377. doNotHandleContextLost?: boolean;
  7378. }
  7379. /**
  7380. * Defines the interface used by display changed events
  7381. */
  7382. interface IDisplayChangedEventArgs {
  7383. /** Gets the vrDisplay object (if any) */
  7384. vrDisplay: Nullable<any>;
  7385. /** Gets a boolean indicating if webVR is supported */
  7386. vrSupported: boolean;
  7387. }
  7388. /**
  7389. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  7390. */
  7391. class Engine {
  7392. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  7393. static ExceptionList: ({
  7394. key: string;
  7395. capture: string;
  7396. captureConstraint: number;
  7397. targets: string[];
  7398. } | {
  7399. key: string;
  7400. capture: null;
  7401. captureConstraint: null;
  7402. targets: string[];
  7403. })[];
  7404. /** Gets the list of created engines */
  7405. static Instances: Engine[];
  7406. /**
  7407. * Gets the latest created engine
  7408. */
  7409. static readonly LastCreatedEngine: Nullable<Engine>;
  7410. /**
  7411. * Gets the latest created scene
  7412. */
  7413. static readonly LastCreatedScene: Nullable<Scene>;
  7414. /**
  7415. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  7416. * @param flag defines which part of the materials must be marked as dirty
  7417. * @param predicate defines a predicate used to filter which materials should be affected
  7418. */
  7419. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  7420. /**
  7421. * Hidden
  7422. */
  7423. static _TextureLoaders: IInternalTextureLoader[];
  7424. /** Defines that alpha blending is disabled */
  7425. static readonly ALPHA_DISABLE: number;
  7426. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  7427. static readonly ALPHA_ADD: number;
  7428. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  7429. static readonly ALPHA_COMBINE: number;
  7430. /** Defines that alpha blending to DEST - SRC * DEST */
  7431. static readonly ALPHA_SUBTRACT: number;
  7432. /** Defines that alpha blending to SRC * DEST */
  7433. static readonly ALPHA_MULTIPLY: number;
  7434. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  7435. static readonly ALPHA_MAXIMIZED: number;
  7436. /** Defines that alpha blending to SRC + DEST */
  7437. static readonly ALPHA_ONEONE: number;
  7438. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  7439. static readonly ALPHA_PREMULTIPLIED: number;
  7440. /**
  7441. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  7442. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  7443. */
  7444. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  7445. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  7446. static readonly ALPHA_INTERPOLATE: number;
  7447. /**
  7448. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  7449. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  7450. */
  7451. static readonly ALPHA_SCREENMODE: number;
  7452. /** Defines that the ressource is not delayed*/
  7453. static readonly DELAYLOADSTATE_NONE: number;
  7454. /** Defines that the ressource was successfully delay loaded */
  7455. static readonly DELAYLOADSTATE_LOADED: number;
  7456. /** Defines that the ressource is currently delay loading */
  7457. static readonly DELAYLOADSTATE_LOADING: number;
  7458. /** Defines that the ressource is delayed and has not started loading */
  7459. static readonly DELAYLOADSTATE_NOTLOADED: number;
  7460. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  7461. static readonly NEVER: number;
  7462. /** 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 */
  7463. static readonly ALWAYS: number;
  7464. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  7465. static readonly LESS: number;
  7466. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  7467. static readonly EQUAL: number;
  7468. /** 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 */
  7469. static readonly LEQUAL: number;
  7470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  7471. static readonly GREATER: number;
  7472. /** 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 */
  7473. static readonly GEQUAL: number;
  7474. /** 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 */
  7475. static readonly NOTEQUAL: number;
  7476. /** Passed to stencilOperation to specify that stencil value must be kept */
  7477. static readonly KEEP: number;
  7478. /** Passed to stencilOperation to specify that stencil value must be replaced */
  7479. static readonly REPLACE: number;
  7480. /** Passed to stencilOperation to specify that stencil value must be incremented */
  7481. static readonly INCR: number;
  7482. /** Passed to stencilOperation to specify that stencil value must be decremented */
  7483. static readonly DECR: number;
  7484. /** Passed to stencilOperation to specify that stencil value must be inverted */
  7485. static readonly INVERT: number;
  7486. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  7487. static readonly INCR_WRAP: number;
  7488. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  7489. static readonly DECR_WRAP: number;
  7490. /** Texture is not repeating outside of 0..1 UVs */
  7491. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  7492. /** Texture is repeating outside of 0..1 UVs */
  7493. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  7494. /** Texture is repeating and mirrored */
  7495. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  7496. /** ALPHA */
  7497. static readonly TEXTUREFORMAT_ALPHA: number;
  7498. /** LUMINANCE */
  7499. static readonly TEXTUREFORMAT_LUMINANCE: number;
  7500. /** LUMINANCE_ALPHA */
  7501. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  7502. /** RGB */
  7503. static readonly TEXTUREFORMAT_RGB: number;
  7504. /** RGBA */
  7505. static readonly TEXTUREFORMAT_RGBA: number;
  7506. /** R */
  7507. static readonly TEXTUREFORMAT_R: number;
  7508. /** RG */
  7509. static readonly TEXTUREFORMAT_RG: number;
  7510. /** UNSIGNED_INT */
  7511. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  7512. /** FLOAT */
  7513. static readonly TEXTURETYPE_FLOAT: number;
  7514. /** HALF_FLOAT */
  7515. static readonly TEXTURETYPE_HALF_FLOAT: number;
  7516. /** nearest is mag = nearest and min = nearest and mip = linear */
  7517. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  7518. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7519. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  7520. /** Trilinear is mag = linear and min = linear and mip = linear */
  7521. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  7522. /** nearest is mag = nearest and min = nearest and mip = linear */
  7523. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  7524. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7525. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  7526. /** Trilinear is mag = linear and min = linear and mip = linear */
  7527. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  7528. /** mag = nearest and min = nearest and mip = nearest */
  7529. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  7530. /** mag = nearest and min = linear and mip = nearest */
  7531. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  7532. /** mag = nearest and min = linear and mip = linear */
  7533. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  7534. /** mag = nearest and min = linear and mip = none */
  7535. static readonly TEXTURE_NEAREST_LINEAR: number;
  7536. /** mag = nearest and min = nearest and mip = none */
  7537. static readonly TEXTURE_NEAREST_NEAREST: number;
  7538. /** mag = linear and min = nearest and mip = nearest */
  7539. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  7540. /** mag = linear and min = nearest and mip = linear */
  7541. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  7542. /** mag = linear and min = linear and mip = none */
  7543. static readonly TEXTURE_LINEAR_LINEAR: number;
  7544. /** mag = linear and min = nearest and mip = none */
  7545. static readonly TEXTURE_LINEAR_NEAREST: number;
  7546. /** Explicit coordinates mode */
  7547. static readonly TEXTURE_EXPLICIT_MODE: number;
  7548. /** Spherical coordinates mode */
  7549. static readonly TEXTURE_SPHERICAL_MODE: number;
  7550. /** Planar coordinates mode */
  7551. static readonly TEXTURE_PLANAR_MODE: number;
  7552. /** Cubic coordinates mode */
  7553. static readonly TEXTURE_CUBIC_MODE: number;
  7554. /** Projection coordinates mode */
  7555. static readonly TEXTURE_PROJECTION_MODE: number;
  7556. /** Skybox coordinates mode */
  7557. static readonly TEXTURE_SKYBOX_MODE: number;
  7558. /** Inverse Cubic coordinates mode */
  7559. static readonly TEXTURE_INVCUBIC_MODE: number;
  7560. /** Equirectangular coordinates mode */
  7561. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  7562. /** Equirectangular Fixed coordinates mode */
  7563. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  7564. /** Equirectangular Fixed Mirrored coordinates mode */
  7565. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  7566. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  7567. static readonly SCALEMODE_FLOOR: number;
  7568. /** Defines that texture rescaling will look for the nearest power of 2 size */
  7569. static readonly SCALEMODE_NEAREST: number;
  7570. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  7571. static readonly SCALEMODE_CEILING: number;
  7572. /**
  7573. * Returns the current version of the framework
  7574. */
  7575. static readonly Version: string;
  7576. /**
  7577. * Gets or sets the epsilon value used by collision engine
  7578. */
  7579. static CollisionsEpsilon: number;
  7580. /**
  7581. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  7582. */
  7583. static CodeRepository: string;
  7584. /**
  7585. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  7586. */
  7587. static ShadersRepository: string;
  7588. /**
  7589. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  7590. */
  7591. forcePOTTextures: boolean;
  7592. /**
  7593. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  7594. */
  7595. isFullscreen: boolean;
  7596. /**
  7597. * Gets a boolean indicating if the pointer is currently locked
  7598. */
  7599. isPointerLock: boolean;
  7600. /**
  7601. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  7602. */
  7603. cullBackFaces: boolean;
  7604. /**
  7605. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  7606. */
  7607. renderEvenInBackground: boolean;
  7608. /**
  7609. * Gets or sets a boolean indicating that cache can be kept between frames
  7610. */
  7611. preventCacheWipeBetweenFrames: boolean;
  7612. /**
  7613. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7614. **/
  7615. enableOfflineSupport: boolean;
  7616. /**
  7617. * 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)
  7618. **/
  7619. disableManifestCheck: boolean;
  7620. /**
  7621. * Gets the list of created scenes
  7622. */
  7623. scenes: Scene[];
  7624. /**
  7625. * Gets the list of created postprocesses
  7626. */
  7627. postProcesses: PostProcess[];
  7628. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  7629. validateShaderPrograms: boolean;
  7630. /**
  7631. * Observable event triggered each time the rendering canvas is resized
  7632. */
  7633. onResizeObservable: Observable<Engine>;
  7634. /**
  7635. * Observable event triggered each time the canvas loses focus
  7636. */
  7637. onCanvasBlurObservable: Observable<Engine>;
  7638. /**
  7639. * Observable event triggered each time the canvas gains focus
  7640. */
  7641. onCanvasFocusObservable: Observable<Engine>;
  7642. /**
  7643. * Observable event triggered each time the canvas receives pointerout event
  7644. */
  7645. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7646. /**
  7647. * Observable event triggered before each texture is initialized
  7648. */
  7649. onBeforeTextureInitObservable: Observable<Texture>;
  7650. private _vrDisplay;
  7651. private _vrSupported;
  7652. private _oldSize;
  7653. private _oldHardwareScaleFactor;
  7654. private _vrExclusivePointerMode;
  7655. private _webVRInitPromise;
  7656. /**
  7657. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7658. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7659. */
  7660. readonly isInVRExclusivePointerMode: boolean;
  7661. /**
  7662. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7663. */
  7664. disableUniformBuffers: boolean;
  7665. /** @hidden */
  7666. _uniformBuffers: UniformBuffer[];
  7667. /**
  7668. * Gets a boolean indicating that the engine supports uniform buffers
  7669. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7670. */
  7671. readonly supportsUniformBuffers: boolean;
  7672. /**
  7673. * Observable raised when the engine begins a new frame
  7674. */
  7675. onBeginFrameObservable: Observable<Engine>;
  7676. /**
  7677. * Observable raised when the engine ends the current frame
  7678. */
  7679. onEndFrameObservable: Observable<Engine>;
  7680. /**
  7681. * Observable raised when the engine is about to compile a shader
  7682. */
  7683. onBeforeShaderCompilationObservable: Observable<Engine>;
  7684. /**
  7685. * Observable raised when the engine has jsut compiled a shader
  7686. */
  7687. onAfterShaderCompilationObservable: Observable<Engine>;
  7688. /** @hidden */
  7689. _gl: WebGLRenderingContext;
  7690. private _renderingCanvas;
  7691. private _windowIsBackground;
  7692. private _webGLVersion;
  7693. /**
  7694. * Gets a boolean indicating that only power of 2 textures are supported
  7695. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7696. */
  7697. readonly needPOTTextures: boolean;
  7698. /** @hidden */
  7699. _badOS: boolean;
  7700. /** @hidden */
  7701. _badDesktopOS: boolean;
  7702. /**
  7703. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7704. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7705. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7706. */
  7707. disableTextureBindingOptimization: boolean;
  7708. /**
  7709. * Gets the audio engine
  7710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7711. * @ignorenaming
  7712. */
  7713. static audioEngine: AudioEngine;
  7714. private _onFocus;
  7715. private _onBlur;
  7716. private _onCanvasPointerOut;
  7717. private _onCanvasBlur;
  7718. private _onCanvasFocus;
  7719. private _onFullscreenChange;
  7720. private _onPointerLockChange;
  7721. private _onVRDisplayPointerRestricted;
  7722. private _onVRDisplayPointerUnrestricted;
  7723. private _onVrDisplayConnect;
  7724. private _onVrDisplayDisconnect;
  7725. private _onVrDisplayPresentChange;
  7726. /**
  7727. * Observable signaled when VR display mode changes
  7728. */
  7729. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7730. /**
  7731. * Observable signaled when VR request present is complete
  7732. */
  7733. onVRRequestPresentComplete: Observable<boolean>;
  7734. /**
  7735. * Observable signaled when VR request present starts
  7736. */
  7737. onVRRequestPresentStart: Observable<Engine>;
  7738. private _hardwareScalingLevel;
  7739. /** @hidden */
  7740. protected _caps: EngineCapabilities;
  7741. private _pointerLockRequested;
  7742. private _isStencilEnable;
  7743. private _colorWrite;
  7744. private _loadingScreen;
  7745. /** @hidden */
  7746. _drawCalls: PerfCounter;
  7747. /** @hidden */
  7748. _textureCollisions: PerfCounter;
  7749. private _glVersion;
  7750. private _glRenderer;
  7751. private _glVendor;
  7752. private _videoTextureSupported;
  7753. private _renderingQueueLaunched;
  7754. private _activeRenderLoops;
  7755. private _deterministicLockstep;
  7756. private _lockstepMaxSteps;
  7757. /**
  7758. * Observable signaled when a context lost event is raised
  7759. */
  7760. onContextLostObservable: Observable<Engine>;
  7761. /**
  7762. * Observable signaled when a context restored event is raised
  7763. */
  7764. onContextRestoredObservable: Observable<Engine>;
  7765. private _onContextLost;
  7766. private _onContextRestored;
  7767. private _contextWasLost;
  7768. private _doNotHandleContextLost;
  7769. /**
  7770. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  7771. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  7772. */
  7773. doNotHandleContextLost: boolean;
  7774. private _performanceMonitor;
  7775. private _fps;
  7776. private _deltaTime;
  7777. /**
  7778. * Turn this value on if you want to pause FPS computation when in background
  7779. */
  7780. disablePerformanceMonitorInBackground: boolean;
  7781. /**
  7782. * Gets the performance monitor attached to this engine
  7783. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7784. */
  7785. readonly performanceMonitor: PerformanceMonitor;
  7786. /** @hidden */
  7787. protected _depthCullingState: _DepthCullingState;
  7788. /** @hidden */
  7789. protected _stencilState: _StencilState;
  7790. /** @hidden */
  7791. protected _alphaState: _AlphaState;
  7792. /** @hidden */
  7793. protected _alphaMode: number;
  7794. protected _internalTexturesCache: InternalTexture[];
  7795. /** @hidden */
  7796. protected _activeChannel: number;
  7797. private _currentTextureChannel;
  7798. /** @hidden */
  7799. protected _boundTexturesCache: {
  7800. [key: string]: Nullable<InternalTexture>;
  7801. };
  7802. /** @hidden */
  7803. protected _currentEffect: Nullable<Effect>;
  7804. /** @hidden */
  7805. protected _currentProgram: Nullable<WebGLProgram>;
  7806. private _compiledEffects;
  7807. private _vertexAttribArraysEnabled;
  7808. /** @hidden */
  7809. protected _cachedViewport: Nullable<Viewport>;
  7810. private _cachedVertexArrayObject;
  7811. /** @hidden */
  7812. protected _cachedVertexBuffers: any;
  7813. /** @hidden */
  7814. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7815. /** @hidden */
  7816. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7817. /** @hidden */
  7818. protected _currentRenderTarget: Nullable<InternalTexture>;
  7819. private _uintIndicesCurrentlySet;
  7820. private _currentBoundBuffer;
  7821. /** @hidden */
  7822. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7823. private _currentBufferPointers;
  7824. private _currentInstanceLocations;
  7825. private _currentInstanceBuffers;
  7826. private _textureUnits;
  7827. private _firstBoundInternalTextureTracker;
  7828. private _lastBoundInternalTextureTracker;
  7829. private _workingCanvas;
  7830. private _workingContext;
  7831. private _rescalePostProcess;
  7832. private _dummyFramebuffer;
  7833. private _externalData;
  7834. private _bindedRenderFunction;
  7835. private _vaoRecordInProgress;
  7836. private _mustWipeVertexAttributes;
  7837. private _emptyTexture;
  7838. private _emptyCubeTexture;
  7839. private _emptyTexture3D;
  7840. private _frameHandler;
  7841. private _nextFreeTextureSlots;
  7842. private _maxSimultaneousTextures;
  7843. private _activeRequests;
  7844. private _texturesSupported;
  7845. private _textureFormatInUse;
  7846. /**
  7847. * Gets the list of texture formats supported
  7848. */
  7849. readonly texturesSupported: Array<string>;
  7850. /**
  7851. * Gets the list of texture formats in use
  7852. */
  7853. readonly textureFormatInUse: Nullable<string>;
  7854. /**
  7855. * Gets the current viewport
  7856. */
  7857. readonly currentViewport: Nullable<Viewport>;
  7858. /**
  7859. * Gets the default empty texture
  7860. */
  7861. readonly emptyTexture: InternalTexture;
  7862. /**
  7863. * Gets the default empty 3D texture
  7864. */
  7865. readonly emptyTexture3D: InternalTexture;
  7866. /**
  7867. * Gets the default empty cube texture
  7868. */
  7869. readonly emptyCubeTexture: InternalTexture;
  7870. /**
  7871. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  7872. */
  7873. readonly premultipliedAlpha: boolean;
  7874. /**
  7875. * Creates a new engine
  7876. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  7877. * @param antialias defines enable antialiasing (default: false)
  7878. * @param options defines further options to be sent to the getContext() function
  7879. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7880. */
  7881. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7882. private _rebuildInternalTextures;
  7883. private _rebuildEffects;
  7884. private _rebuildBuffers;
  7885. private _initGLContext;
  7886. /**
  7887. * Gets version of the current webGL context
  7888. */
  7889. readonly webGLVersion: number;
  7890. /**
  7891. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7892. */
  7893. readonly isStencilEnable: boolean;
  7894. private _prepareWorkingCanvas;
  7895. /**
  7896. * Reset the texture cache to empty state
  7897. */
  7898. resetTextureCache(): void;
  7899. /**
  7900. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7901. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7902. * @returns true if engine is in deterministic lock step mode
  7903. */
  7904. isDeterministicLockStep(): boolean;
  7905. /**
  7906. * Gets the max steps when engine is running in deterministic lock step
  7907. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7908. * @returns the max steps
  7909. */
  7910. getLockstepMaxSteps(): number;
  7911. /**
  7912. * Gets an object containing information about the current webGL context
  7913. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7914. */
  7915. getGlInfo(): {
  7916. vendor: string;
  7917. renderer: string;
  7918. version: string;
  7919. };
  7920. /**
  7921. * Gets current aspect ratio
  7922. * @param camera defines the camera to use to get the aspect ratio
  7923. * @param useScreen defines if screen size must be used (or the current render target if any)
  7924. * @returns a number defining the aspect ratio
  7925. */
  7926. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7927. /**
  7928. * Gets current screen aspect ratio
  7929. * @returns a number defining the aspect ratio
  7930. */
  7931. getScreenAspectRatio(): number;
  7932. /**
  7933. * Gets the current render width
  7934. * @param useScreen defines if screen size must be used (or the current render target if any)
  7935. * @returns a number defining the current render width
  7936. */
  7937. getRenderWidth(useScreen?: boolean): number;
  7938. /**
  7939. * Gets the current render height
  7940. * @param useScreen defines if screen size must be used (or the current render target if any)
  7941. * @returns a number defining the current render height
  7942. */
  7943. getRenderHeight(useScreen?: boolean): number;
  7944. /**
  7945. * Gets the HTML canvas attached with the current webGL context
  7946. * @returns a HTML canvas
  7947. */
  7948. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7949. /**
  7950. * Gets the client rect of the HTML canvas attached with the current webGL context
  7951. * @returns a client rectanglee
  7952. */
  7953. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7954. /**
  7955. * Defines the hardware scaling level.
  7956. * By default the hardware scaling level is computed from the window device ratio.
  7957. * 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.
  7958. * @param level defines the level to use
  7959. */
  7960. setHardwareScalingLevel(level: number): void;
  7961. /**
  7962. * Gets the current hardware scaling level.
  7963. * By default the hardware scaling level is computed from the window device ratio.
  7964. * 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.
  7965. * @returns a number indicating the current hardware scaling level
  7966. */
  7967. getHardwareScalingLevel(): number;
  7968. /**
  7969. * Gets the list of loaded textures
  7970. * @returns an array containing all loaded textures
  7971. */
  7972. getLoadedTexturesCache(): InternalTexture[];
  7973. /**
  7974. * Gets the object containing all engine capabilities
  7975. * @returns the EngineCapabilities object
  7976. */
  7977. getCaps(): EngineCapabilities;
  7978. /** @hidden */
  7979. readonly drawCalls: number;
  7980. /** @hidden */
  7981. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  7982. /**
  7983. * Gets the current depth function
  7984. * @returns a number defining the depth function
  7985. */
  7986. getDepthFunction(): Nullable<number>;
  7987. /**
  7988. * Sets the current depth function
  7989. * @param depthFunc defines the function to use
  7990. */
  7991. setDepthFunction(depthFunc: number): void;
  7992. /**
  7993. * Sets the current depth function to GREATER
  7994. */
  7995. setDepthFunctionToGreater(): void;
  7996. /**
  7997. * Sets the current depth function to GEQUAL
  7998. */
  7999. setDepthFunctionToGreaterOrEqual(): void;
  8000. /**
  8001. * Sets the current depth function to LESS
  8002. */
  8003. setDepthFunctionToLess(): void;
  8004. /**
  8005. * Sets the current depth function to LEQUAL
  8006. */
  8007. setDepthFunctionToLessOrEqual(): void;
  8008. /**
  8009. * Gets a boolean indicating if stencil buffer is enabled
  8010. * @returns the current stencil buffer state
  8011. */
  8012. getStencilBuffer(): boolean;
  8013. /**
  8014. * Enable or disable the stencil buffer
  8015. * @param enable defines if the stencil buffer must be enabled or disabled
  8016. */
  8017. setStencilBuffer(enable: boolean): void;
  8018. /**
  8019. * Gets the current stencil mask
  8020. * @returns a number defining the new stencil mask to use
  8021. */
  8022. getStencilMask(): number;
  8023. /**
  8024. * Sets the current stencil mask
  8025. * @param mask defines the new stencil mask to use
  8026. */
  8027. setStencilMask(mask: number): void;
  8028. /**
  8029. * Gets the current stencil function
  8030. * @returns a number defining the stencil function to use
  8031. */
  8032. getStencilFunction(): number;
  8033. /**
  8034. * Gets the current stencil reference value
  8035. * @returns a number defining the stencil reference value to use
  8036. */
  8037. getStencilFunctionReference(): number;
  8038. /**
  8039. * Gets the current stencil mask
  8040. * @returns a number defining the stencil mask to use
  8041. */
  8042. getStencilFunctionMask(): number;
  8043. /**
  8044. * Sets the current stencil function
  8045. * @param stencilFunc defines the new stencil function to use
  8046. */
  8047. setStencilFunction(stencilFunc: number): void;
  8048. /**
  8049. * Sets the current stencil reference
  8050. * @param reference defines the new stencil reference to use
  8051. */
  8052. setStencilFunctionReference(reference: number): void;
  8053. /**
  8054. * Sets the current stencil mask
  8055. * @param mask defines the new stencil mask to use
  8056. */
  8057. setStencilFunctionMask(mask: number): void;
  8058. /**
  8059. * Gets the current stencil operation when stencil fails
  8060. * @returns a number defining stencil operation to use when stencil fails
  8061. */
  8062. getStencilOperationFail(): number;
  8063. /**
  8064. * Gets the current stencil operation when depth fails
  8065. * @returns a number defining stencil operation to use when depth fails
  8066. */
  8067. getStencilOperationDepthFail(): number;
  8068. /**
  8069. * Gets the current stencil operation when stencil passes
  8070. * @returns a number defining stencil operation to use when stencil passes
  8071. */
  8072. getStencilOperationPass(): number;
  8073. /**
  8074. * Sets the stencil operation to use when stencil fails
  8075. * @param operation defines the stencil operation to use when stencil fails
  8076. */
  8077. setStencilOperationFail(operation: number): void;
  8078. /**
  8079. * Sets the stencil operation to use when depth fails
  8080. * @param operation defines the stencil operation to use when depth fails
  8081. */
  8082. setStencilOperationDepthFail(operation: number): void;
  8083. /**
  8084. * Sets the stencil operation to use when stencil passes
  8085. * @param operation defines the stencil operation to use when stencil passes
  8086. */
  8087. setStencilOperationPass(operation: number): void;
  8088. /**
  8089. * Sets a boolean indicating if the dithering state is enabled or disabled
  8090. * @param value defines the dithering state
  8091. */
  8092. setDitheringState(value: boolean): void;
  8093. /**
  8094. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  8095. * @param value defines the rasterizer state
  8096. */
  8097. setRasterizerState(value: boolean): void;
  8098. /**
  8099. * stop executing a render loop function and remove it from the execution array
  8100. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  8101. */
  8102. stopRenderLoop(renderFunction?: () => void): void;
  8103. /** @hidden */
  8104. _renderLoop(): void;
  8105. /**
  8106. * Register and execute a render loop. The engine can have more than one render function
  8107. * @param renderFunction defines the function to continuously execute
  8108. */
  8109. runRenderLoop(renderFunction: () => void): void;
  8110. /**
  8111. * Toggle full screen mode
  8112. * @param requestPointerLock defines if a pointer lock should be requested from the user
  8113. * @param options defines an option object to be sent to the requestFullscreen function
  8114. */
  8115. switchFullscreen(requestPointerLock: boolean): void;
  8116. /**
  8117. * Clear the current render buffer or the current render target (if any is set up)
  8118. * @param color defines the color to use
  8119. * @param backBuffer defines if the back buffer must be cleared
  8120. * @param depth defines if the depth buffer must be cleared
  8121. * @param stencil defines if the stencil buffer must be cleared
  8122. */
  8123. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8124. /**
  8125. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  8126. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  8127. * @param y defines the y-coordinate of the corner of the clear rectangle
  8128. * @param width defines the width of the clear rectangle
  8129. * @param height defines the height of the clear rectangle
  8130. * @param clearColor defines the clear color
  8131. */
  8132. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  8133. private _viewportCached;
  8134. /** @hidden */
  8135. _viewport(x: number, y: number, width: number, height: number): void;
  8136. /**
  8137. * Set the WebGL's viewport
  8138. * @param viewport defines the viewport element to be used
  8139. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  8140. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  8141. */
  8142. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8143. /**
  8144. * Directly set the WebGL Viewport
  8145. * @param x defines the x coordinate of the viewport (in screen space)
  8146. * @param y defines the y coordinate of the viewport (in screen space)
  8147. * @param width defines the width of the viewport (in screen space)
  8148. * @param height defines the height of the viewport (in screen space)
  8149. * @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
  8150. */
  8151. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  8152. /**
  8153. * Begin a new frame
  8154. */
  8155. beginFrame(): void;
  8156. /**
  8157. * Enf the current frame
  8158. */
  8159. endFrame(): void;
  8160. /**
  8161. * Resize the view according to the canvas' size
  8162. */
  8163. resize(): void;
  8164. /**
  8165. * Force a specific size of the canvas
  8166. * @param width defines the new canvas' width
  8167. * @param height defines the new canvas' height
  8168. */
  8169. setSize(width: number, height: number): void;
  8170. /**
  8171. * Gets a boolean indicating if a webVR device was detected
  8172. * @returns true if a webVR device was detected
  8173. */
  8174. isVRDevicePresent(): boolean;
  8175. /**
  8176. * Gets the current webVR device
  8177. * @returns the current webVR device (or null)
  8178. */
  8179. getVRDevice(): any;
  8180. /**
  8181. * Initializes a webVR display and starts listening to display change events
  8182. * The onVRDisplayChangedObservable will be notified upon these changes
  8183. * @returns The onVRDisplayChangedObservable
  8184. */
  8185. initWebVR(): Observable<IDisplayChangedEventArgs>;
  8186. /**
  8187. * Initializes a webVR display and starts listening to display change events
  8188. * The onVRDisplayChangedObservable will be notified upon these changes
  8189. * @returns A promise containing a VRDisplay and if vr is supported
  8190. */
  8191. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  8192. /**
  8193. * Call this function to switch to webVR mode
  8194. * Will do nothing if webVR is not supported or if there is no webVR device
  8195. * @see http://doc.babylonjs.com/how_to/webvr_camera
  8196. */
  8197. enableVR(): void;
  8198. /**
  8199. * Call this function to leave webVR mode
  8200. * Will do nothing if webVR is not supported or if there is no webVR device
  8201. * @see http://doc.babylonjs.com/how_to/webvr_camera
  8202. */
  8203. disableVR(): void;
  8204. private _onVRFullScreenTriggered;
  8205. private _getVRDisplaysAsync;
  8206. /**
  8207. * Binds the frame buffer to the specified texture.
  8208. * @param texture The texture to render to or null for the default canvas
  8209. * @param faceIndex The face of the texture to render to in case of cube texture
  8210. * @param requiredWidth The width of the target to render to
  8211. * @param requiredHeight The height of the target to render to
  8212. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  8213. * @param depthStencilTexture The depth stencil texture to use to render
  8214. * @param lodLevel defines le lod level to bind to the frame buffer
  8215. */
  8216. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  8217. private bindUnboundFramebuffer;
  8218. /**
  8219. * Unbind the current render target texture from the webGL context
  8220. * @param texture defines the render target texture to unbind
  8221. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8222. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8223. */
  8224. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8225. /**
  8226. * Unbind a list of render target textures from the webGL context
  8227. * This is used only when drawBuffer extension or webGL2 are active
  8228. * @param textures defines the render target textures to unbind
  8229. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8230. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8231. */
  8232. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8233. /**
  8234. * Force the mipmap generation for the given render target texture
  8235. * @param texture defines the render target texture to use
  8236. */
  8237. generateMipMapsForCubemap(texture: InternalTexture): void;
  8238. /**
  8239. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  8240. */
  8241. flushFramebuffer(): void;
  8242. /**
  8243. * Unbind the current render target and bind the default framebuffer
  8244. */
  8245. restoreDefaultFramebuffer(): void;
  8246. /**
  8247. * Create an uniform buffer
  8248. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8249. * @param elements defines the content of the uniform buffer
  8250. * @returns the webGL uniform buffer
  8251. */
  8252. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  8253. /**
  8254. * Create a dynamic uniform buffer
  8255. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8256. * @param elements defines the content of the uniform buffer
  8257. * @returns the webGL uniform buffer
  8258. */
  8259. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  8260. /**
  8261. * Update an existing uniform buffer
  8262. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8263. * @param uniformBuffer defines the target uniform buffer
  8264. * @param elements defines the content to update
  8265. * @param offset defines the offset in the uniform buffer where update should start
  8266. * @param count defines the size of the data to update
  8267. */
  8268. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8269. private _resetVertexBufferBinding;
  8270. /**
  8271. * Creates a vertex buffer
  8272. * @param data the data for the vertex buffer
  8273. * @returns the new WebGL static buffer
  8274. */
  8275. createVertexBuffer(data: DataArray): WebGLBuffer;
  8276. /**
  8277. * Creates a dynamic vertex buffer
  8278. * @param data the data for the dynamic vertex buffer
  8279. * @returns the new WebGL dynamic buffer
  8280. */
  8281. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  8282. /**
  8283. * Update a dynamic index buffer
  8284. * @param indexBuffer defines the target index buffer
  8285. * @param indices defines the data to update
  8286. * @param offset defines the offset in the target index buffer where update should start
  8287. */
  8288. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8289. /**
  8290. * Updates a dynamic vertex buffer.
  8291. * @param vertexBuffer the vertex buffer to update
  8292. * @param data the data used to update the vertex buffer
  8293. * @param byteOffset the byte offset of the data
  8294. * @param byteLength the byte length of the data
  8295. */
  8296. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  8297. private _resetIndexBufferBinding;
  8298. /**
  8299. * Creates a new index buffer
  8300. * @param indices defines the content of the index buffer
  8301. * @param updatable defines if the index buffer must be updatable
  8302. * @returns a new webGL buffer
  8303. */
  8304. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  8305. /**
  8306. * Bind a webGL buffer to the webGL context
  8307. * @param buffer defines the buffer to bind
  8308. */
  8309. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  8310. /**
  8311. * Bind an uniform buffer to the current webGL context
  8312. * @param buffer defines the buffer to bind
  8313. */
  8314. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  8315. /**
  8316. * Bind a buffer to the current webGL context at a given location
  8317. * @param buffer defines the buffer to bind
  8318. * @param location defines the index where to bind the buffer
  8319. */
  8320. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  8321. /**
  8322. * Bind a specific block at a given index in a specific shader program
  8323. * @param shaderProgram defines the shader program
  8324. * @param blockName defines the block name
  8325. * @param index defines the index where to bind the block
  8326. */
  8327. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  8328. private bindIndexBuffer;
  8329. private bindBuffer;
  8330. /**
  8331. * update the bound buffer with the given data
  8332. * @param data defines the data to update
  8333. */
  8334. updateArrayBuffer(data: Float32Array): void;
  8335. private _vertexAttribPointer;
  8336. private _bindIndexBufferWithCache;
  8337. private _bindVertexBuffersAttributes;
  8338. /**
  8339. * Records a vertex array object
  8340. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8341. * @param vertexBuffers defines the list of vertex buffers to store
  8342. * @param indexBuffer defines the index buffer to store
  8343. * @param effect defines the effect to store
  8344. * @returns the new vertex array object
  8345. */
  8346. recordVertexArrayObject(vertexBuffers: {
  8347. [key: string]: VertexBuffer;
  8348. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  8349. /**
  8350. * Bind a specific vertex array object
  8351. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8352. * @param vertexArrayObject defines the vertex array object to bind
  8353. * @param indexBuffer defines the index buffer to bind
  8354. */
  8355. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  8356. /**
  8357. * Bind webGl buffers directly to the webGL context
  8358. * @param vertexBuffer defines the vertex buffer to bind
  8359. * @param indexBuffer defines the index buffer to bind
  8360. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  8361. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  8362. * @param effect defines the effect associated with the vertex buffer
  8363. */
  8364. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  8365. private _unbindVertexArrayObject;
  8366. /**
  8367. * Bind a list of vertex buffers to the webGL context
  8368. * @param vertexBuffers defines the list of vertex buffers to bind
  8369. * @param indexBuffer defines the index buffer to bind
  8370. * @param effect defines the effect associated with the vertex buffers
  8371. */
  8372. bindBuffers(vertexBuffers: {
  8373. [key: string]: Nullable<VertexBuffer>;
  8374. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  8375. /**
  8376. * Unbind all instance attributes
  8377. */
  8378. unbindInstanceAttributes(): void;
  8379. /**
  8380. * Release and free the memory of a vertex array object
  8381. * @param vao defines the vertex array object to delete
  8382. */
  8383. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  8384. /** @hidden */
  8385. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8386. /**
  8387. * Creates a webGL buffer to use with instanciation
  8388. * @param capacity defines the size of the buffer
  8389. * @returns the webGL buffer
  8390. */
  8391. createInstancesBuffer(capacity: number): WebGLBuffer;
  8392. /**
  8393. * Delete a webGL buffer used with instanciation
  8394. * @param buffer defines the webGL buffer to delete
  8395. */
  8396. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  8397. /**
  8398. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  8399. * @param instancesBuffer defines the webGL buffer to update and bind
  8400. * @param data defines the data to store in the buffer
  8401. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  8402. */
  8403. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  8404. /**
  8405. * Apply all cached states (depth, culling, stencil and alpha)
  8406. */
  8407. applyStates(): void;
  8408. /**
  8409. * Send a draw order
  8410. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8411. * @param indexStart defines the starting index
  8412. * @param indexCount defines the number of index to draw
  8413. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8414. */
  8415. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8416. /**
  8417. * Draw a list of points
  8418. * @param verticesStart defines the index of first vertex to draw
  8419. * @param verticesCount defines the count of vertices to draw
  8420. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8421. */
  8422. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8423. /**
  8424. * Draw a list of unindexed primitives
  8425. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8426. * @param verticesStart defines the index of first vertex to draw
  8427. * @param verticesCount defines the count of vertices to draw
  8428. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8429. */
  8430. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8431. /**
  8432. * Draw a list of indexed primitives
  8433. * @param fillMode defines the primitive to use
  8434. * @param indexStart defines the starting index
  8435. * @param indexCount defines the number of index to draw
  8436. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8437. */
  8438. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8439. /**
  8440. * Draw a list of unindexed primitives
  8441. * @param fillMode defines the primitive to use
  8442. * @param verticesStart defines the index of first vertex to draw
  8443. * @param verticesCount defines the count of vertices to draw
  8444. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8445. */
  8446. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8447. private _drawMode;
  8448. /** @hidden */
  8449. _releaseEffect(effect: Effect): void;
  8450. /** @hidden */
  8451. _deleteProgram(program: WebGLProgram): void;
  8452. /**
  8453. * Create a new effect (used to store vertex/fragment shaders)
  8454. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  8455. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  8456. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  8457. * @param samplers defines an array of string used to represent textures
  8458. * @param defines defines the string containing the defines to use to compile the shaders
  8459. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8460. * @param onCompiled defines a function to call when the effect creation is successful
  8461. * @param onError defines a function to call when the effect creation has failed
  8462. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  8463. * @returns the new Effect
  8464. */
  8465. 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;
  8466. private _compileShader;
  8467. private _compileRawShader;
  8468. /**
  8469. * Directly creates a webGL program
  8470. * @param vertexCode defines the vertex shader code to use
  8471. * @param fragmentCode defines the fragment shader code to use
  8472. * @param context defines the webGL context to use (if not set, the current one will be used)
  8473. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8474. * @returns the new webGL program
  8475. */
  8476. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8477. /**
  8478. * Creates a webGL program
  8479. * @param vertexCode defines the vertex shader code to use
  8480. * @param fragmentCode defines the fragment shader code to use
  8481. * @param defines defines the string containing the defines to use to compile the shaders
  8482. * @param context defines the webGL context to use (if not set, the current one will be used)
  8483. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8484. * @returns the new webGL program
  8485. */
  8486. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8487. private _createShaderProgram;
  8488. /**
  8489. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  8490. * @param shaderProgram defines the webGL program to use
  8491. * @param uniformsNames defines the list of uniform names
  8492. * @returns an array of webGL uniform locations
  8493. */
  8494. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  8495. /**
  8496. * Gets the lsit of active attributes for a given webGL program
  8497. * @param shaderProgram defines the webGL program to use
  8498. * @param attributesNames defines the list of attribute names to get
  8499. * @returns an array of indices indicating the offset of each attribute
  8500. */
  8501. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8502. /**
  8503. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  8504. * @param effect defines the effect to activate
  8505. */
  8506. enableEffect(effect: Nullable<Effect>): void;
  8507. /**
  8508. * Set the value of an uniform to an array of int32
  8509. * @param uniform defines the webGL uniform location where to store the value
  8510. * @param array defines the array of int32 to store
  8511. */
  8512. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8513. /**
  8514. * Set the value of an uniform to an array of int32 (stored as vec2)
  8515. * @param uniform defines the webGL uniform location where to store the value
  8516. * @param array defines the array of int32 to store
  8517. */
  8518. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8519. /**
  8520. * Set the value of an uniform to an array of int32 (stored as vec3)
  8521. * @param uniform defines the webGL uniform location where to store the value
  8522. * @param array defines the array of int32 to store
  8523. */
  8524. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8525. /**
  8526. * Set the value of an uniform to an array of int32 (stored as vec4)
  8527. * @param uniform defines the webGL uniform location where to store the value
  8528. * @param array defines the array of int32 to store
  8529. */
  8530. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8531. /**
  8532. * Set the value of an uniform to an array of float32
  8533. * @param uniform defines the webGL uniform location where to store the value
  8534. * @param array defines the array of float32 to store
  8535. */
  8536. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8537. /**
  8538. * Set the value of an uniform to an array of float32 (stored as vec2)
  8539. * @param uniform defines the webGL uniform location where to store the value
  8540. * @param array defines the array of float32 to store
  8541. */
  8542. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8543. /**
  8544. * Set the value of an uniform to an array of float32 (stored as vec3)
  8545. * @param uniform defines the webGL uniform location where to store the value
  8546. * @param array defines the array of float32 to store
  8547. */
  8548. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8549. /**
  8550. * Set the value of an uniform to an array of float32 (stored as vec4)
  8551. * @param uniform defines the webGL uniform location where to store the value
  8552. * @param array defines the array of float32 to store
  8553. */
  8554. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8555. /**
  8556. * Set the value of an uniform to an array of number
  8557. * @param uniform defines the webGL uniform location where to store the value
  8558. * @param array defines the array of number to store
  8559. */
  8560. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8561. /**
  8562. * Set the value of an uniform to an array of number (stored as vec2)
  8563. * @param uniform defines the webGL uniform location where to store the value
  8564. * @param array defines the array of number to store
  8565. */
  8566. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8567. /**
  8568. * Set the value of an uniform to an array of number (stored as vec3)
  8569. * @param uniform defines the webGL uniform location where to store the value
  8570. * @param array defines the array of number to store
  8571. */
  8572. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8573. /**
  8574. * Set the value of an uniform to an array of number (stored as vec4)
  8575. * @param uniform defines the webGL uniform location where to store the value
  8576. * @param array defines the array of number to store
  8577. */
  8578. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8579. /**
  8580. * Set the value of an uniform to an array of float32 (stored as matrices)
  8581. * @param uniform defines the webGL uniform location where to store the value
  8582. * @param matrices defines the array of float32 to store
  8583. */
  8584. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  8585. /**
  8586. * Set the value of an uniform to a matrix
  8587. * @param uniform defines the webGL uniform location where to store the value
  8588. * @param matrix defines the matrix to store
  8589. */
  8590. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  8591. /**
  8592. * Set the value of an uniform to a matrix (3x3)
  8593. * @param uniform defines the webGL uniform location where to store the value
  8594. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  8595. */
  8596. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8597. /**
  8598. * Set the value of an uniform to a matrix (2x2)
  8599. * @param uniform defines the webGL uniform location where to store the value
  8600. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  8601. */
  8602. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8603. /**
  8604. * Set the value of an uniform to a number (int)
  8605. * @param uniform defines the webGL uniform location where to store the value
  8606. * @param value defines the int number to store
  8607. */
  8608. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8609. /**
  8610. * Set the value of an uniform to a number (float)
  8611. * @param uniform defines the webGL uniform location where to store the value
  8612. * @param value defines the float number to store
  8613. */
  8614. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8615. /**
  8616. * Set the value of an uniform to a vec2
  8617. * @param uniform defines the webGL uniform location where to store the value
  8618. * @param x defines the 1st component of the value
  8619. * @param y defines the 2nd component of the value
  8620. */
  8621. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8622. /**
  8623. * Set the value of an uniform to a vec3
  8624. * @param uniform defines the webGL uniform location where to store the value
  8625. * @param x defines the 1st component of the value
  8626. * @param y defines the 2nd component of the value
  8627. * @param z defines the 3rd component of the value
  8628. */
  8629. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8630. /**
  8631. * Set the value of an uniform to a boolean
  8632. * @param uniform defines the webGL uniform location where to store the value
  8633. * @param bool defines the boolean to store
  8634. */
  8635. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8636. /**
  8637. * Set the value of an uniform to a vec4
  8638. * @param uniform defines the webGL uniform location where to store the value
  8639. * @param x defines the 1st component of the value
  8640. * @param y defines the 2nd component of the value
  8641. * @param z defines the 3rd component of the value
  8642. * @param w defines the 4th component of the value
  8643. */
  8644. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8645. /**
  8646. * Set the value of an uniform to a Color3
  8647. * @param uniform defines the webGL uniform location where to store the value
  8648. * @param color3 defines the color to store
  8649. */
  8650. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8651. /**
  8652. * Set the value of an uniform to a Color3 and an alpha value
  8653. * @param uniform defines the webGL uniform location where to store the value
  8654. * @param color3 defines the color to store
  8655. * @param alpha defines the alpha component to store
  8656. */
  8657. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8658. /**
  8659. * Sets a Color4 on a uniform variable
  8660. * @param uniform defines the uniform location
  8661. * @param color4 defines the value to be set
  8662. */
  8663. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8664. /**
  8665. * Set various states to the webGL context
  8666. * @param culling defines backface culling state
  8667. * @param zOffset defines the value to apply to zOffset (0 by default)
  8668. * @param force defines if states must be applied even if cache is up to date
  8669. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8670. */
  8671. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8672. /**
  8673. * Set the z offset to apply to current rendering
  8674. * @param value defines the offset to apply
  8675. */
  8676. setZOffset(value: number): void;
  8677. /**
  8678. * Gets the current value of the zOffset
  8679. * @returns the current zOffset state
  8680. */
  8681. getZOffset(): number;
  8682. /**
  8683. * Enable or disable depth buffering
  8684. * @param enable defines the state to set
  8685. */
  8686. setDepthBuffer(enable: boolean): void;
  8687. /**
  8688. * Gets a boolean indicating if depth writing is enabled
  8689. * @returns the current depth writing state
  8690. */
  8691. getDepthWrite(): boolean;
  8692. /**
  8693. * Enable or disable depth writing
  8694. * @param enable defines the state to set
  8695. */
  8696. setDepthWrite(enable: boolean): void;
  8697. /**
  8698. * Enable or disable color writing
  8699. * @param enable defines the state to set
  8700. */
  8701. setColorWrite(enable: boolean): void;
  8702. /**
  8703. * Gets a boolean indicating if color writing is enabled
  8704. * @returns the current color writing state
  8705. */
  8706. getColorWrite(): boolean;
  8707. /**
  8708. * Sets alpha constants used by some alpha blending modes
  8709. * @param r defines the red component
  8710. * @param g defines the green component
  8711. * @param b defines the blue component
  8712. * @param a defines the alpha component
  8713. */
  8714. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8715. /**
  8716. * Sets the current alpha mode
  8717. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8718. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8719. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8720. */
  8721. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8722. /**
  8723. * Gets the current alpha mode
  8724. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8725. * @returns the current alpha mode
  8726. */
  8727. getAlphaMode(): number;
  8728. /**
  8729. * Clears the list of texture accessible through engine.
  8730. * This can help preventing texture load conflict due to name collision.
  8731. */
  8732. clearInternalTexturesCache(): void;
  8733. /**
  8734. * Force the entire cache to be cleared
  8735. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8736. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8737. */
  8738. wipeCaches(bruteForce?: boolean): void;
  8739. /**
  8740. * Set the compressed texture format to use, based on the formats you have, and the formats
  8741. * supported by the hardware / browser.
  8742. *
  8743. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8744. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8745. * to API arguments needed to compressed textures. This puts the burden on the container
  8746. * generator to house the arcane code for determining these for current & future formats.
  8747. *
  8748. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8749. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8750. *
  8751. * Note: The result of this call is not taken into account when a texture is base64.
  8752. *
  8753. * @param formatsAvailable defines the list of those format families you have created
  8754. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8755. *
  8756. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8757. * @returns The extension selected.
  8758. */
  8759. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8760. private _getSamplingParameters;
  8761. private _partialLoadImg;
  8762. private _cascadeLoadImgs;
  8763. /** @hidden */
  8764. _createTexture(): WebGLTexture;
  8765. /**
  8766. * Usually called from BABYLON.Texture.ts.
  8767. * Passed information to create a WebGLTexture
  8768. * @param urlArg defines a value which contains one of the following:
  8769. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8770. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8771. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8772. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8773. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8774. * @param scene needed for loading to the correct scene
  8775. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8776. * @param onLoad optional callback to be called upon successful completion
  8777. * @param onError optional callback to be called upon failure
  8778. * @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
  8779. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8780. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8781. * @param forcedExtension defines the extension to use to pick the right loader
  8782. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8783. */
  8784. 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;
  8785. private _rescaleTexture;
  8786. /**
  8787. * Update a raw texture
  8788. * @param texture defines the texture to update
  8789. * @param data defines the data to store in the texture
  8790. * @param format defines the format of the data
  8791. * @param invertY defines if data must be stored with Y axis inverted
  8792. * @param compression defines the compression used (null by default)
  8793. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8794. */
  8795. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8796. /**
  8797. * Creates a raw texture
  8798. * @param data defines the data to store in the texture
  8799. * @param width defines the width of the texture
  8800. * @param height defines the height of the texture
  8801. * @param format defines the format of the data
  8802. * @param generateMipMaps defines if the engine should generate the mip levels
  8803. * @param invertY defines if data must be stored with Y axis inverted
  8804. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8805. * @param compression defines the compression used (null by default)
  8806. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8807. * @returns the raw texture inside an InternalTexture
  8808. */
  8809. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8810. private _unpackFlipYCached;
  8811. /** @hidden */
  8812. _unpackFlipY(value: boolean): void;
  8813. /** @hidden */
  8814. _getUnpackAlignement(): number;
  8815. /**
  8816. * Creates a dynamic texture
  8817. * @param width defines the width of the texture
  8818. * @param height defines the height of the texture
  8819. * @param generateMipMaps defines if the engine should generate the mip levels
  8820. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8821. * @returns the dynamic texture inside an InternalTexture
  8822. */
  8823. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8824. /**
  8825. * Update the sampling mode of a given texture
  8826. * @param samplingMode defines the required sampling mode
  8827. * @param texture defines the texture to update
  8828. */
  8829. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8830. /**
  8831. * Update the content of a dynamic texture
  8832. * @param texture defines the texture to update
  8833. * @param canvas defines the canvas containing the source
  8834. * @param invertY defines if data must be stored with Y axis inverted
  8835. * @param premulAlpha defines if alpha is stored as premultiplied
  8836. * @param format defines the format of the data
  8837. */
  8838. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8839. /**
  8840. * Update a video texture
  8841. * @param texture defines the texture to update
  8842. * @param video defines the video element to use
  8843. * @param invertY defines if data must be stored with Y axis inverted
  8844. */
  8845. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8846. /**
  8847. * Updates a depth texture Comparison Mode and Function.
  8848. * If the comparison Function is equal to 0, the mode will be set to none.
  8849. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8850. * @param texture The texture to set the comparison function for
  8851. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8852. */
  8853. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8854. private _setupDepthStencilTexture;
  8855. /**
  8856. * Creates a depth stencil texture.
  8857. * This is only available in WebGL 2 or with the depth texture extension available.
  8858. * @param size The size of face edge in the texture.
  8859. * @param options The options defining the texture.
  8860. * @returns The texture
  8861. */
  8862. createDepthStencilTexture(size: number | {
  8863. width: number;
  8864. height: number;
  8865. }, options: DepthTextureCreationOptions): InternalTexture;
  8866. /**
  8867. * Creates a depth stencil texture.
  8868. * This is only available in WebGL 2 or with the depth texture extension available.
  8869. * @param size The size of face edge in the texture.
  8870. * @param options The options defining the texture.
  8871. * @returns The texture
  8872. */
  8873. private _createDepthStencilTexture;
  8874. /**
  8875. * Creates a depth stencil cube texture.
  8876. * This is only available in WebGL 2.
  8877. * @param size The size of face edge in the cube texture.
  8878. * @param options The options defining the cube texture.
  8879. * @returns The cube texture
  8880. */
  8881. private _createDepthStencilCubeTexture;
  8882. /**
  8883. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8884. * @param renderTarget The render target to set the frame buffer for
  8885. */
  8886. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8887. /**
  8888. * Creates a new render target texture
  8889. * @param size defines the size of the texture
  8890. * @param options defines the options used to create the texture
  8891. * @returns a new render target texture stored in an InternalTexture
  8892. */
  8893. createRenderTargetTexture(size: number | {
  8894. width: number;
  8895. height: number;
  8896. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8897. /**
  8898. * Create a multi render target texture
  8899. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8900. * @param size defines the size of the texture
  8901. * @param options defines the creation options
  8902. * @returns the cube texture as an InternalTexture
  8903. */
  8904. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8905. private _setupFramebufferDepthAttachments;
  8906. /**
  8907. * Updates the sample count of a render target texture
  8908. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8909. * @param texture defines the texture to update
  8910. * @param samples defines the sample count to set
  8911. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8912. */
  8913. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8914. /**
  8915. * Update the sample count for a given multiple render target texture
  8916. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8917. * @param textures defines the textures to update
  8918. * @param samples defines the sample count to set
  8919. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8920. */
  8921. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8922. /** @hidden */
  8923. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8924. /** @hidden */
  8925. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8926. /** @hidden */
  8927. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8928. /** @hidden */
  8929. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  8930. /**
  8931. * Creates a new render target cube texture
  8932. * @param size defines the size of the texture
  8933. * @param options defines the options used to create the texture
  8934. * @returns a new render target cube texture stored in an InternalTexture
  8935. */
  8936. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8937. /**
  8938. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8939. * @param rootUrl defines the url where the file to load is located
  8940. * @param scene defines the current scene
  8941. * @param lodScale defines scale to apply to the mip map selection
  8942. * @param lodOffset defines offset to apply to the mip map selection
  8943. * @param onLoad defines an optional callback raised when the texture is loaded
  8944. * @param onError defines an optional callback raised if there is an issue to load the texture
  8945. * @param format defines the format of the data
  8946. * @param forcedExtension defines the extension to use to pick the right loader
  8947. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  8948. * @returns the cube texture as an InternalTexture
  8949. */
  8950. 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;
  8951. /**
  8952. * Creates a cube texture
  8953. * @param rootUrl defines the url where the files to load is located
  8954. * @param scene defines the current scene
  8955. * @param files defines the list of files to load (1 per face)
  8956. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8957. * @param onLoad defines an optional callback raised when the texture is loaded
  8958. * @param onError defines an optional callback raised if there is an issue to load the texture
  8959. * @param format defines the format of the data
  8960. * @param forcedExtension defines the extension to use to pick the right loader
  8961. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8962. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8963. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8964. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8965. * @returns the cube texture as an InternalTexture
  8966. */
  8967. 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;
  8968. /**
  8969. * @hidden
  8970. */
  8971. _setCubeMapTextureParams(loadMipmap: boolean): void;
  8972. /**
  8973. * Update a raw cube texture
  8974. * @param texture defines the texture to udpdate
  8975. * @param data defines the data to store
  8976. * @param format defines the data format
  8977. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8978. * @param invertY defines if data must be stored with Y axis inverted
  8979. * @param compression defines the compression used (null by default)
  8980. * @param level defines which level of the texture to update
  8981. */
  8982. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  8983. /**
  8984. * Creates a new raw cube texture
  8985. * @param data defines the array of data to use to create each face
  8986. * @param size defines the size of the textures
  8987. * @param format defines the format of the data
  8988. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8989. * @param generateMipMaps defines if the engine should generate the mip levels
  8990. * @param invertY defines if data must be stored with Y axis inverted
  8991. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8992. * @param compression defines the compression used (null by default)
  8993. * @returns the cube texture as an InternalTexture
  8994. */
  8995. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8996. /**
  8997. * Creates a new raw cube texture from a specified url
  8998. * @param url defines the url where the data is located
  8999. * @param scene defines the current scene
  9000. * @param size defines the size of the textures
  9001. * @param format defines the format of the data
  9002. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  9003. * @param noMipmap defines if the engine should avoid generating the mip levels
  9004. * @param callback defines a callback used to extract texture data from loaded data
  9005. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9006. * @param onLoad defines a callback called when texture is loaded
  9007. * @param onError defines a callback called if there is an error
  9008. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  9009. * @param invertY defines if data must be stored with Y axis inverted
  9010. * @returns the cube texture as an InternalTexture
  9011. */
  9012. 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;
  9013. /**
  9014. * Update a raw 3D texture
  9015. * @param texture defines the texture to update
  9016. * @param data defines the data to store
  9017. * @param format defines the data format
  9018. * @param invertY defines if data must be stored with Y axis inverted
  9019. * @param compression defines the used compression (can be null)
  9020. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9021. */
  9022. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  9023. /**
  9024. * Creates a new raw 3D texture
  9025. * @param data defines the data used to create the texture
  9026. * @param width defines the width of the texture
  9027. * @param height defines the height of the texture
  9028. * @param depth defines the depth of the texture
  9029. * @param format defines the format of the texture
  9030. * @param generateMipMaps defines if the engine must generate mip levels
  9031. * @param invertY defines if data must be stored with Y axis inverted
  9032. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  9033. * @param compression defines the compressed used (can be null)
  9034. * @param textureType defines the compressed used (can be null)
  9035. * @returns a new raw 3D texture (stored in an InternalTexture)
  9036. */
  9037. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  9038. private _prepareWebGLTextureContinuation;
  9039. private _prepareWebGLTexture;
  9040. private _convertRGBtoRGBATextureData;
  9041. /** @hidden */
  9042. _releaseFramebufferObjects(texture: InternalTexture): void;
  9043. /** @hidden */
  9044. _releaseTexture(texture: InternalTexture): void;
  9045. private setProgram;
  9046. private _boundUniforms;
  9047. /**
  9048. * Binds an effect to the webGL context
  9049. * @param effect defines the effect to bind
  9050. */
  9051. bindSamplers(effect: Effect): void;
  9052. private _moveBoundTextureOnTop;
  9053. private _getCorrectTextureChannel;
  9054. private _linkTrackers;
  9055. private _removeDesignatedSlot;
  9056. private _activateCurrentTexture;
  9057. /** @hidden */
  9058. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  9059. /** @hidden */
  9060. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  9061. /**
  9062. * Sets a texture to the webGL context from a postprocess
  9063. * @param channel defines the channel to use
  9064. * @param postProcess defines the source postprocess
  9065. */
  9066. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  9067. /**
  9068. * Binds the output of the passed in post process to the texture channel specified
  9069. * @param channel The channel the texture should be bound to
  9070. * @param postProcess The post process which's output should be bound
  9071. */
  9072. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  9073. /**
  9074. * Unbind all textures from the webGL context
  9075. */
  9076. unbindAllTextures(): void;
  9077. /**
  9078. * Sets a texture to the according uniform.
  9079. * @param channel The texture channel
  9080. * @param uniform The uniform to set
  9081. * @param texture The texture to apply
  9082. */
  9083. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  9084. /**
  9085. * Sets a depth stencil texture from a render target to the according uniform.
  9086. * @param channel The texture channel
  9087. * @param uniform The uniform to set
  9088. * @param texture The render target texture containing the depth stencil texture to apply
  9089. */
  9090. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  9091. private _bindSamplerUniformToChannel;
  9092. private _getTextureWrapMode;
  9093. private _setTexture;
  9094. /**
  9095. * Sets an array of texture to the webGL context
  9096. * @param channel defines the channel where the texture array must be set
  9097. * @param uniform defines the associated uniform location
  9098. * @param textures defines the array of textures to bind
  9099. */
  9100. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  9101. /** @hidden */
  9102. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  9103. private _setTextureParameterFloat;
  9104. private _setTextureParameterInteger;
  9105. /**
  9106. * Reads pixels from the current frame buffer. Please note that this function can be slow
  9107. * @param x defines the x coordinate of the rectangle where pixels must be read
  9108. * @param y defines the y coordinate of the rectangle where pixels must be read
  9109. * @param width defines the width of the rectangle where pixels must be read
  9110. * @param height defines the height of the rectangle where pixels must be read
  9111. * @returns a Uint8Array containing RGBA colors
  9112. */
  9113. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  9114. /**
  9115. * Add an externaly attached data from its key.
  9116. * This method call will fail and return false, if such key already exists.
  9117. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  9118. * @param key the unique key that identifies the data
  9119. * @param data the data object to associate to the key for this Engine instance
  9120. * @return true if no such key were already present and the data was added successfully, false otherwise
  9121. */
  9122. addExternalData<T>(key: string, data: T): boolean;
  9123. /**
  9124. * Get an externaly attached data from its key
  9125. * @param key the unique key that identifies the data
  9126. * @return the associated data, if present (can be null), or undefined if not present
  9127. */
  9128. getExternalData<T>(key: string): T;
  9129. /**
  9130. * Get an externaly attached data from its key, create it using a factory if it's not already present
  9131. * @param key the unique key that identifies the data
  9132. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  9133. * @return the associated data, can be null if the factory returned null.
  9134. */
  9135. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  9136. /**
  9137. * Remove an externaly attached data from the Engine instance
  9138. * @param key the unique key that identifies the data
  9139. * @return true if the data was successfully removed, false if it doesn't exist
  9140. */
  9141. removeExternalData(key: string): boolean;
  9142. /**
  9143. * Unbind all vertex attributes from the webGL context
  9144. */
  9145. unbindAllAttributes(): void;
  9146. /**
  9147. * 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
  9148. */
  9149. releaseEffects(): void;
  9150. /**
  9151. * Dispose and release all associated resources
  9152. */
  9153. dispose(): void;
  9154. /**
  9155. * Display the loading screen
  9156. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9157. */
  9158. displayLoadingUI(): void;
  9159. /**
  9160. * Hide the loading screen
  9161. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9162. */
  9163. hideLoadingUI(): void;
  9164. /**
  9165. * Gets the current loading screen object
  9166. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9167. */
  9168. /**
  9169. * Sets the current loading screen object
  9170. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9171. */
  9172. loadingScreen: ILoadingScreen;
  9173. /**
  9174. * Sets the current loading screen text
  9175. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9176. */
  9177. loadingUIText: string;
  9178. /**
  9179. * Sets the current loading screen background color
  9180. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9181. */
  9182. loadingUIBackgroundColor: string;
  9183. /**
  9184. * Attach a new callback raised when context lost event is fired
  9185. * @param callback defines the callback to call
  9186. */
  9187. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  9188. /**
  9189. * Attach a new callback raised when context restored event is fired
  9190. * @param callback defines the callback to call
  9191. */
  9192. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  9193. /**
  9194. * Gets the source code of the vertex shader associated with a specific webGL program
  9195. * @param program defines the program to use
  9196. * @returns a string containing the source code of the vertex shader associated with the program
  9197. */
  9198. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  9199. /**
  9200. * Gets the source code of the fragment shader associated with a specific webGL program
  9201. * @param program defines the program to use
  9202. * @returns a string containing the source code of the fragment shader associated with the program
  9203. */
  9204. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  9205. /**
  9206. * Get the current error code of the webGL context
  9207. * @returns the error code
  9208. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  9209. */
  9210. getError(): number;
  9211. /**
  9212. * Gets the current framerate
  9213. * @returns a number representing the framerate
  9214. */
  9215. getFps(): number;
  9216. /**
  9217. * Gets the time spent between current and previous frame
  9218. * @returns a number representing the delta time in ms
  9219. */
  9220. getDeltaTime(): number;
  9221. private _measureFps;
  9222. /** @hidden */
  9223. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number): ArrayBufferView;
  9224. private _canRenderToFloatFramebuffer;
  9225. private _canRenderToHalfFloatFramebuffer;
  9226. private _canRenderToFramebuffer;
  9227. /** @hidden */
  9228. _getWebGLTextureType(type: number): number;
  9229. private _getInternalFormat;
  9230. /** @hidden */
  9231. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  9232. /** @hidden */
  9233. _getRGBAMultiSampleBufferFormat(type: number): number;
  9234. /** @hidden */
  9235. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, database?: Database, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  9236. /** @hidden */
  9237. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  9238. private _partialLoadFile;
  9239. private _cascadeLoadFiles;
  9240. /**
  9241. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  9242. * @returns true if the engine can be created
  9243. * @ignorenaming
  9244. */
  9245. static isSupported(): boolean;
  9246. }
  9247. }
  9248. declare module BABYLON {
  9249. class NullEngineOptions {
  9250. renderWidth: number;
  9251. renderHeight: number;
  9252. textureSize: number;
  9253. deterministicLockstep: boolean;
  9254. lockstepMaxSteps: number;
  9255. }
  9256. /**
  9257. * The null engine class provides support for headless version of babylon.js.
  9258. * This can be used in server side scenario or for testing purposes
  9259. */
  9260. class NullEngine extends Engine {
  9261. private _options;
  9262. isDeterministicLockStep(): boolean;
  9263. getLockstepMaxSteps(): number;
  9264. getHardwareScalingLevel(): number;
  9265. constructor(options?: NullEngineOptions);
  9266. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9267. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  9268. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  9269. getRenderWidth(useScreen?: boolean): number;
  9270. getRenderHeight(useScreen?: boolean): number;
  9271. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  9272. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  9273. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  9274. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  9275. bindSamplers(effect: Effect): void;
  9276. enableEffect(effect: Effect): void;
  9277. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  9278. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  9279. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  9280. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  9281. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  9282. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  9283. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  9284. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  9285. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  9286. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  9287. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  9288. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  9289. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  9290. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  9291. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  9292. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9293. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9294. setFloat(uniform: WebGLUniformLocation, value: number): void;
  9295. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  9296. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  9297. setBool(uniform: WebGLUniformLocation, bool: number): void;
  9298. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  9299. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  9300. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  9301. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  9302. bindBuffers(vertexBuffers: {
  9303. [key: string]: VertexBuffer;
  9304. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  9305. wipeCaches(bruteForce?: boolean): void;
  9306. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  9307. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  9308. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  9309. /** @hidden */
  9310. _createTexture(): WebGLTexture;
  9311. /** @hidden */
  9312. _releaseTexture(texture: InternalTexture): void;
  9313. 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;
  9314. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  9315. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  9316. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  9317. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  9318. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9319. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  9320. /**
  9321. * @hidden
  9322. * Get the current error code of the webGL context
  9323. * @returns the error code
  9324. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  9325. */
  9326. getError(): number;
  9327. /** @hidden */
  9328. _getUnpackAlignement(): number;
  9329. /** @hidden */
  9330. _unpackFlipY(value: boolean): void;
  9331. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  9332. /**
  9333. * Updates a dynamic vertex buffer.
  9334. * @param vertexBuffer the vertex buffer to update
  9335. * @param data the data used to update the vertex buffer
  9336. * @param byteOffset the byte offset of the data (optional)
  9337. * @param byteLength the byte length of the data (optional)
  9338. */
  9339. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  9340. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  9341. /** @hidden */
  9342. _bindTexture(channel: number, texture: InternalTexture): void;
  9343. /** @hidden */
  9344. _releaseBuffer(buffer: WebGLBuffer): boolean;
  9345. releaseEffects(): void;
  9346. displayLoadingUI(): void;
  9347. hideLoadingUI(): void;
  9348. /** @hidden */
  9349. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9350. /** @hidden */
  9351. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9352. /** @hidden */
  9353. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9354. /** @hidden */
  9355. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  9356. }
  9357. }
  9358. interface WebGLRenderingContext {
  9359. readonly RASTERIZER_DISCARD: number;
  9360. readonly DEPTH_COMPONENT24: number;
  9361. readonly TEXTURE_3D: number;
  9362. readonly TEXTURE_2D_ARRAY: number;
  9363. readonly TEXTURE_COMPARE_FUNC: number;
  9364. readonly TEXTURE_COMPARE_MODE: number;
  9365. readonly COMPARE_REF_TO_TEXTURE: number;
  9366. readonly TEXTURE_WRAP_R: number;
  9367. readonly HALF_FLOAT: number;
  9368. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  9369. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  9370. 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;
  9371. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  9372. readonly TRANSFORM_FEEDBACK: number;
  9373. readonly INTERLEAVED_ATTRIBS: number;
  9374. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  9375. createTransformFeedback(): WebGLTransformFeedback;
  9376. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  9377. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  9378. beginTransformFeedback(primitiveMode: number): void;
  9379. endTransformFeedback(): void;
  9380. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  9381. }
  9382. interface ImageBitmap {
  9383. readonly width: number;
  9384. readonly height: number;
  9385. close(): void;
  9386. }
  9387. interface WebGLQuery extends WebGLObject {
  9388. }
  9389. declare var WebGLQuery: {
  9390. prototype: WebGLQuery;
  9391. new (): WebGLQuery;
  9392. };
  9393. interface WebGLSampler extends WebGLObject {
  9394. }
  9395. declare var WebGLSampler: {
  9396. prototype: WebGLSampler;
  9397. new (): WebGLSampler;
  9398. };
  9399. interface WebGLSync extends WebGLObject {
  9400. }
  9401. declare var WebGLSync: {
  9402. prototype: WebGLSync;
  9403. new (): WebGLSync;
  9404. };
  9405. interface WebGLTransformFeedback extends WebGLObject {
  9406. }
  9407. declare var WebGLTransformFeedback: {
  9408. prototype: WebGLTransformFeedback;
  9409. new (): WebGLTransformFeedback;
  9410. };
  9411. interface WebGLVertexArrayObject extends WebGLObject {
  9412. }
  9413. declare var WebGLVertexArrayObject: {
  9414. prototype: WebGLVertexArrayObject;
  9415. new (): WebGLVertexArrayObject;
  9416. };
  9417. declare module BABYLON {
  9418. class KeyboardEventTypes {
  9419. static _KEYDOWN: number;
  9420. static _KEYUP: number;
  9421. static readonly KEYDOWN: number;
  9422. static readonly KEYUP: number;
  9423. }
  9424. class KeyboardInfo {
  9425. type: number;
  9426. event: KeyboardEvent;
  9427. constructor(type: number, event: KeyboardEvent);
  9428. }
  9429. /**
  9430. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9431. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9432. */
  9433. class KeyboardInfoPre extends KeyboardInfo {
  9434. constructor(type: number, event: KeyboardEvent);
  9435. skipOnPointerObservable: boolean;
  9436. }
  9437. }
  9438. declare module BABYLON {
  9439. class PointerEventTypes {
  9440. static _POINTERDOWN: number;
  9441. static _POINTERUP: number;
  9442. static _POINTERMOVE: number;
  9443. static _POINTERWHEEL: number;
  9444. static _POINTERPICK: number;
  9445. static _POINTERTAP: number;
  9446. static _POINTERDOUBLETAP: number;
  9447. static readonly POINTERDOWN: number;
  9448. static readonly POINTERUP: number;
  9449. static readonly POINTERMOVE: number;
  9450. static readonly POINTERWHEEL: number;
  9451. static readonly POINTERPICK: number;
  9452. static readonly POINTERTAP: number;
  9453. static readonly POINTERDOUBLETAP: number;
  9454. }
  9455. class PointerInfoBase {
  9456. type: number;
  9457. event: PointerEvent | MouseWheelEvent;
  9458. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  9459. }
  9460. /**
  9461. * This class is used to store pointer related info for the onPrePointerObservable event.
  9462. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  9463. */
  9464. class PointerInfoPre extends PointerInfoBase {
  9465. /**
  9466. * Ray from a pointer if availible (eg. 6dof controller)
  9467. */
  9468. ray: Nullable<Ray>;
  9469. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  9470. localPosition: Vector2;
  9471. skipOnPointerObservable: boolean;
  9472. }
  9473. /**
  9474. * This type contains all the data related to a pointer event in Babylon.js.
  9475. * 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.
  9476. */
  9477. class PointerInfo extends PointerInfoBase {
  9478. pickInfo: Nullable<PickingInfo>;
  9479. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  9480. }
  9481. }
  9482. declare module BABYLON {
  9483. class StickValues {
  9484. x: number;
  9485. y: number;
  9486. constructor(x: number, y: number);
  9487. }
  9488. interface GamepadButtonChanges {
  9489. changed: boolean;
  9490. pressChanged: boolean;
  9491. touchChanged: boolean;
  9492. valueChanged: boolean;
  9493. }
  9494. class Gamepad {
  9495. id: string;
  9496. index: number;
  9497. browserGamepad: any;
  9498. type: number;
  9499. private _leftStick;
  9500. private _rightStick;
  9501. /** @hidden */
  9502. _isConnected: boolean;
  9503. private _leftStickAxisX;
  9504. private _leftStickAxisY;
  9505. private _rightStickAxisX;
  9506. private _rightStickAxisY;
  9507. private _onleftstickchanged;
  9508. private _onrightstickchanged;
  9509. static GAMEPAD: number;
  9510. static GENERIC: number;
  9511. static XBOX: number;
  9512. static POSE_ENABLED: number;
  9513. protected _invertLeftStickY: boolean;
  9514. readonly isConnected: boolean;
  9515. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9516. onleftstickchanged(callback: (values: StickValues) => void): void;
  9517. onrightstickchanged(callback: (values: StickValues) => void): void;
  9518. leftStick: StickValues;
  9519. rightStick: StickValues;
  9520. update(): void;
  9521. dispose(): void;
  9522. }
  9523. class GenericPad extends Gamepad {
  9524. private _buttons;
  9525. private _onbuttondown;
  9526. private _onbuttonup;
  9527. onButtonDownObservable: Observable<number>;
  9528. onButtonUpObservable: Observable<number>;
  9529. onbuttondown(callback: (buttonPressed: number) => void): void;
  9530. onbuttonup(callback: (buttonReleased: number) => void): void;
  9531. constructor(id: string, index: number, browserGamepad: any);
  9532. private _setButtonValue;
  9533. update(): void;
  9534. dispose(): void;
  9535. }
  9536. }
  9537. declare module BABYLON {
  9538. class GamepadManager {
  9539. private _scene?;
  9540. private _babylonGamepads;
  9541. private _oneGamepadConnected;
  9542. /** @hidden */
  9543. _isMonitoring: boolean;
  9544. private _gamepadEventSupported;
  9545. private _gamepadSupport;
  9546. onGamepadConnectedObservable: Observable<Gamepad>;
  9547. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9548. private _onGamepadConnectedEvent;
  9549. private _onGamepadDisconnectedEvent;
  9550. constructor(_scene?: Scene | undefined);
  9551. readonly gamepads: Gamepad[];
  9552. getGamepadByType(type?: number): Nullable<Gamepad>;
  9553. dispose(): void;
  9554. private _addNewGamepad;
  9555. private _startMonitoringGamepads;
  9556. private _stopMonitoringGamepads;
  9557. /** @hidden */
  9558. _checkGamepadsStatus(): void;
  9559. private _updateGamepadObjects;
  9560. }
  9561. }
  9562. declare module BABYLON {
  9563. interface Scene {
  9564. /** @hidden */
  9565. _gamepadManager: Nullable<GamepadManager>;
  9566. /**
  9567. * Gets the gamepad manager associated with the scene
  9568. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  9569. */
  9570. gamepadManager: GamepadManager;
  9571. }
  9572. interface FreeCameraInputsManager {
  9573. addGamepad(): FreeCameraInputsManager;
  9574. }
  9575. interface ArcRotateCameraInputsManager {
  9576. addGamepad(): ArcRotateCameraInputsManager;
  9577. }
  9578. /**
  9579. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  9580. */
  9581. class GamepadSystemSceneComponent implements ISceneComponent {
  9582. /**
  9583. * The component name helpfull to identify the component in the list of scene components.
  9584. */
  9585. readonly name: string;
  9586. /**
  9587. * The scene the component belongs to.
  9588. */
  9589. scene: Scene;
  9590. /**
  9591. * Creates a new instance of the component for the given scene
  9592. * @param scene Defines the scene to register the component in
  9593. */
  9594. constructor(scene: Scene);
  9595. /**
  9596. * Registers the component in a given scene
  9597. */
  9598. register(): void;
  9599. /**
  9600. * Rebuilds the elements related to this component in case of
  9601. * context lost for instance.
  9602. */
  9603. rebuild(): void;
  9604. /**
  9605. * Disposes the component and the associated ressources
  9606. */
  9607. dispose(): void;
  9608. private _beforeCameraUpdate;
  9609. }
  9610. }
  9611. declare module BABYLON {
  9612. /**
  9613. * Defines supported buttons for XBox360 compatible gamepads
  9614. */
  9615. enum Xbox360Button {
  9616. /** A */
  9617. A = 0,
  9618. /** B */
  9619. B = 1,
  9620. /** X */
  9621. X = 2,
  9622. /** Y */
  9623. Y = 3,
  9624. /** Start */
  9625. Start = 4,
  9626. /** Back */
  9627. Back = 5,
  9628. /** Left button */
  9629. LB = 6,
  9630. /** Right button */
  9631. RB = 7,
  9632. /** Left stick */
  9633. LeftStick = 8,
  9634. /** Right stick */
  9635. RightStick = 9
  9636. }
  9637. /** Defines values for XBox360 DPad */
  9638. enum Xbox360Dpad {
  9639. /** Up */
  9640. Up = 0,
  9641. /** Down */
  9642. Down = 1,
  9643. /** Left */
  9644. Left = 2,
  9645. /** Right */
  9646. Right = 3
  9647. }
  9648. /**
  9649. * Defines a XBox360 gamepad
  9650. */
  9651. class Xbox360Pad extends Gamepad {
  9652. private _leftTrigger;
  9653. private _rightTrigger;
  9654. private _onlefttriggerchanged;
  9655. private _onrighttriggerchanged;
  9656. private _onbuttondown;
  9657. private _onbuttonup;
  9658. private _ondpaddown;
  9659. private _ondpadup;
  9660. /** Observable raised when a button is pressed */
  9661. onButtonDownObservable: Observable<Xbox360Button>;
  9662. /** Observable raised when a button is released */
  9663. onButtonUpObservable: Observable<Xbox360Button>;
  9664. /** Observable raised when a pad is pressed */
  9665. onPadDownObservable: Observable<Xbox360Dpad>;
  9666. /** Observable raised when a pad is released */
  9667. onPadUpObservable: Observable<Xbox360Dpad>;
  9668. private _buttonA;
  9669. private _buttonB;
  9670. private _buttonX;
  9671. private _buttonY;
  9672. private _buttonBack;
  9673. private _buttonStart;
  9674. private _buttonLB;
  9675. private _buttonRB;
  9676. private _buttonLeftStick;
  9677. private _buttonRightStick;
  9678. private _dPadUp;
  9679. private _dPadDown;
  9680. private _dPadLeft;
  9681. private _dPadRight;
  9682. private _isXboxOnePad;
  9683. /**
  9684. * Creates a new XBox360 gamepad object
  9685. * @param id defines the id of this gamepad
  9686. * @param index defines its index
  9687. * @param gamepad defines the internal HTML gamepad object
  9688. * @param xboxOne defines if it is a XBox One gamepad
  9689. */
  9690. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9691. /**
  9692. * Defines the callback to call when left trigger is pressed
  9693. * @param callback defines the callback to use
  9694. */
  9695. onlefttriggerchanged(callback: (value: number) => void): void;
  9696. /**
  9697. * Defines the callback to call when right trigger is pressed
  9698. * @param callback defines the callback to use
  9699. */
  9700. onrighttriggerchanged(callback: (value: number) => void): void;
  9701. /**
  9702. * Gets or sets left trigger value
  9703. */
  9704. leftTrigger: number;
  9705. /**
  9706. * Gets or sets right trigger value
  9707. */
  9708. rightTrigger: number;
  9709. /**
  9710. * Defines the callback to call when a button is pressed
  9711. * @param callback defines the callback to use
  9712. */
  9713. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9714. /**
  9715. * Defines the callback to call when a button is released
  9716. * @param callback defines the callback to use
  9717. */
  9718. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9719. /**
  9720. * Defines the callback to call when a pad is pressed
  9721. * @param callback defines the callback to use
  9722. */
  9723. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9724. /**
  9725. * Defines the callback to call when a pad is released
  9726. * @param callback defines the callback to use
  9727. */
  9728. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9729. private _setButtonValue;
  9730. private _setDPadValue;
  9731. /** Gets or sets value of A button */
  9732. buttonA: number;
  9733. /** Gets or sets value of B button */
  9734. buttonB: number;
  9735. /** Gets or sets value of X button */
  9736. buttonX: number;
  9737. /** Gets or sets value of Y button */
  9738. buttonY: number;
  9739. /** Gets or sets value of Start button */
  9740. buttonStart: number;
  9741. /** Gets or sets value of Back button */
  9742. buttonBack: number;
  9743. /** Gets or sets value of Left button */
  9744. buttonLB: number;
  9745. /** Gets or sets value of Right button */
  9746. buttonRB: number;
  9747. /** Gets or sets value of left stick */
  9748. buttonLeftStick: number;
  9749. /** Gets or sets value of right stick */
  9750. buttonRightStick: number;
  9751. /** Gets or sets value of DPad up */
  9752. dPadUp: number;
  9753. /** Gets or sets value of DPad down */
  9754. dPadDown: number;
  9755. /** Gets or sets value of DPad left */
  9756. dPadLeft: number;
  9757. /** Gets or sets value of DPad right */
  9758. dPadRight: number;
  9759. /**
  9760. * Force the gamepad to synchronize with device values
  9761. */
  9762. update(): void;
  9763. dispose(): void;
  9764. }
  9765. }
  9766. declare module BABYLON {
  9767. /**
  9768. * Single axis drag gizmo
  9769. */
  9770. class AxisDragGizmo extends Gizmo {
  9771. /**
  9772. * Drag behavior responsible for the gizmos dragging interactions
  9773. */
  9774. dragBehavior: PointerDragBehavior;
  9775. private _pointerObserver;
  9776. /**
  9777. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9778. */
  9779. snapDistance: number;
  9780. /**
  9781. * Event that fires each time the gizmo snaps to a new location.
  9782. * * snapDistance is the the change in distance
  9783. */
  9784. onSnapObservable: Observable<{
  9785. snapDistance: number;
  9786. }>;
  9787. /**
  9788. * Creates an AxisDragGizmo
  9789. * @param gizmoLayer The utility layer the gizmo will be added to
  9790. * @param dragAxis The axis which the gizmo will be able to drag on
  9791. * @param color The color of the gizmo
  9792. */
  9793. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9794. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9795. /**
  9796. * Disposes of the gizmo
  9797. */
  9798. dispose(): void;
  9799. }
  9800. }
  9801. declare module BABYLON {
  9802. /**
  9803. * Single axis scale gizmo
  9804. */
  9805. class AxisScaleGizmo extends Gizmo {
  9806. private _coloredMaterial;
  9807. /**
  9808. * Drag behavior responsible for the gizmos dragging interactions
  9809. */
  9810. dragBehavior: PointerDragBehavior;
  9811. private _pointerObserver;
  9812. /**
  9813. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9814. */
  9815. snapDistance: number;
  9816. /**
  9817. * Event that fires each time the gizmo snaps to a new location.
  9818. * * snapDistance is the the change in distance
  9819. */
  9820. onSnapObservable: Observable<{
  9821. snapDistance: number;
  9822. }>;
  9823. /**
  9824. * If the scaling operation should be done on all axis (default: false)
  9825. */
  9826. uniformScaling: boolean;
  9827. /**
  9828. * Creates an AxisScaleGizmo
  9829. * @param gizmoLayer The utility layer the gizmo will be added to
  9830. * @param dragAxis The axis which the gizmo will be able to scale on
  9831. * @param color The color of the gizmo
  9832. */
  9833. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9834. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9835. /**
  9836. * Disposes of the gizmo
  9837. */
  9838. dispose(): void;
  9839. /**
  9840. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  9841. * @param mesh The mesh to replace the default mesh of the gizmo
  9842. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  9843. */
  9844. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  9845. }
  9846. }
  9847. declare module BABYLON {
  9848. /**
  9849. * Bounding box gizmo
  9850. */
  9851. class BoundingBoxGizmo extends Gizmo {
  9852. private _lineBoundingBox;
  9853. private _rotateSpheresParent;
  9854. private _scaleBoxesParent;
  9855. private _boundingDimensions;
  9856. private _renderObserver;
  9857. private _pointerObserver;
  9858. private _scaleDragSpeed;
  9859. private _tmpQuaternion;
  9860. private _tmpVector;
  9861. /**
  9862. * 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)
  9863. */
  9864. ignoreChildren: boolean;
  9865. /**
  9866. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  9867. */
  9868. rotationSphereSize: number;
  9869. /**
  9870. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  9871. */
  9872. scaleBoxSize: number;
  9873. /**
  9874. * 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)
  9875. */
  9876. fixedDragMeshScreenSize: boolean;
  9877. /**
  9878. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  9879. */
  9880. fixedDragMeshScreenSizeDistanceFactor: number;
  9881. /**
  9882. * Fired when a rotation sphere or scale box is dragged
  9883. */
  9884. onDragStartObservable: Observable<{}>;
  9885. /**
  9886. * Fired when a scale box is dragged
  9887. */
  9888. onScaleBoxDragObservable: Observable<{}>;
  9889. /**
  9890. * Fired when a scale box drag is ended
  9891. */
  9892. onScaleBoxDragEndObservable: Observable<{}>;
  9893. /**
  9894. * Fired when a rotation sphere is dragged
  9895. */
  9896. onRotationSphereDragObservable: Observable<{}>;
  9897. /**
  9898. * Fired when a rotation sphere drag is ended
  9899. */
  9900. onRotationSphereDragEndObservable: Observable<{}>;
  9901. private _anchorMesh;
  9902. private _existingMeshScale;
  9903. /**
  9904. * Creates an BoundingBoxGizmo
  9905. * @param gizmoLayer The utility layer the gizmo will be added to
  9906. * @param color The color of the gizmo
  9907. */
  9908. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9909. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9910. private _selectNode;
  9911. private _recurseComputeWorld;
  9912. /**
  9913. * Updates the bounding box information for the Gizmo
  9914. */
  9915. updateBoundingBox(): void;
  9916. /**
  9917. * Enables rotation on the specified axis and disables rotation on the others
  9918. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  9919. */
  9920. setEnabledRotationAxis(axis: string): void;
  9921. /**
  9922. * Disposes of the gizmo
  9923. */
  9924. dispose(): void;
  9925. /**
  9926. * 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)
  9927. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  9928. * @returns the bounding box mesh with the passed in mesh as a child
  9929. */
  9930. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  9931. /**
  9932. * CustomMeshes are not supported by this gizmo
  9933. * @param mesh The mesh to replace the default mesh of the gizmo
  9934. */
  9935. setCustomMesh(mesh: Mesh): void;
  9936. }
  9937. }
  9938. declare module BABYLON {
  9939. /**
  9940. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  9941. */
  9942. class Gizmo implements IDisposable {
  9943. /** The utility layer the gizmo will be added to */
  9944. gizmoLayer: UtilityLayerRenderer;
  9945. /**
  9946. * The root mesh of the gizmo
  9947. */
  9948. protected _rootMesh: Mesh;
  9949. private _attachedMesh;
  9950. private _scaleFactor;
  9951. private _tmpMatrix;
  9952. /**
  9953. * If a custom mesh has been set (Default: false)
  9954. */
  9955. protected _customMeshSet: boolean;
  9956. /**
  9957. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  9958. * * When set, interactions will be enabled
  9959. */
  9960. attachedMesh: Nullable<AbstractMesh>;
  9961. /**
  9962. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  9963. * @param mesh The mesh to replace the default mesh of the gizmo
  9964. */
  9965. setCustomMesh(mesh: Mesh): void;
  9966. /**
  9967. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  9968. */
  9969. updateGizmoRotationToMatchAttachedMesh: boolean;
  9970. /**
  9971. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  9972. */
  9973. updateGizmoPositionToMatchAttachedMesh: boolean;
  9974. /**
  9975. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  9976. */
  9977. protected _updateScale: boolean;
  9978. protected _interactionsEnabled: boolean;
  9979. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9980. private _beforeRenderObserver;
  9981. /**
  9982. * Creates a gizmo
  9983. * @param gizmoLayer The utility layer the gizmo will be added to
  9984. */
  9985. constructor(
  9986. /** The utility layer the gizmo will be added to */
  9987. gizmoLayer?: UtilityLayerRenderer);
  9988. private _tempVector;
  9989. /**
  9990. * @hidden
  9991. * Updates the gizmo to match the attached mesh's position/rotation
  9992. */
  9993. protected _update(): void;
  9994. /**
  9995. * Disposes of the gizmo
  9996. */
  9997. dispose(): void;
  9998. }
  9999. }
  10000. declare module BABYLON {
  10001. /**
  10002. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  10003. */
  10004. class GizmoManager implements IDisposable {
  10005. private scene;
  10006. /**
  10007. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  10008. */
  10009. gizmos: {
  10010. positionGizmo: Nullable<PositionGizmo>;
  10011. rotationGizmo: Nullable<RotationGizmo>;
  10012. scaleGizmo: Nullable<ScaleGizmo>;
  10013. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  10014. };
  10015. private _gizmosEnabled;
  10016. private _pointerObserver;
  10017. private _attachedMesh;
  10018. private _boundingBoxColor;
  10019. private _dragBehavior;
  10020. /**
  10021. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  10022. */
  10023. attachableMeshes: Nullable<Array<AbstractMesh>>;
  10024. /**
  10025. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  10026. */
  10027. usePointerToAttachGizmos: boolean;
  10028. /**
  10029. * Instatiates a gizmo manager
  10030. * @param scene the scene to overlay the gizmos on top of
  10031. */
  10032. constructor(scene: Scene);
  10033. /**
  10034. * Attaches a set of gizmos to the specified mesh
  10035. * @param mesh The mesh the gizmo's should be attached to
  10036. */
  10037. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  10038. /**
  10039. * If the position gizmo is enabled
  10040. */
  10041. positionGizmoEnabled: boolean;
  10042. /**
  10043. * If the rotation gizmo is enabled
  10044. */
  10045. rotationGizmoEnabled: boolean;
  10046. /**
  10047. * If the scale gizmo is enabled
  10048. */
  10049. scaleGizmoEnabled: boolean;
  10050. /**
  10051. * If the boundingBox gizmo is enabled
  10052. */
  10053. boundingBoxGizmoEnabled: boolean;
  10054. /**
  10055. * Disposes of the gizmo manager
  10056. */
  10057. dispose(): void;
  10058. }
  10059. }
  10060. declare module BABYLON {
  10061. /**
  10062. * Single plane rotation gizmo
  10063. */
  10064. class PlaneRotationGizmo extends Gizmo {
  10065. /**
  10066. * Drag behavior responsible for the gizmos dragging interactions
  10067. */
  10068. dragBehavior: PointerDragBehavior;
  10069. private _pointerObserver;
  10070. /**
  10071. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  10072. */
  10073. snapDistance: number;
  10074. /**
  10075. * Event that fires each time the gizmo snaps to a new location.
  10076. * * snapDistance is the the change in distance
  10077. */
  10078. onSnapObservable: Observable<{
  10079. snapDistance: number;
  10080. }>;
  10081. /**
  10082. * Creates a PlaneRotationGizmo
  10083. * @param gizmoLayer The utility layer the gizmo will be added to
  10084. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  10085. * @param color The color of the gizmo
  10086. */
  10087. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  10088. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10089. /**
  10090. * Disposes of the gizmo
  10091. */
  10092. dispose(): void;
  10093. }
  10094. }
  10095. declare module BABYLON {
  10096. /**
  10097. * Gizmo that enables dragging a mesh along 3 axis
  10098. */
  10099. class PositionGizmo extends Gizmo {
  10100. /**
  10101. * Internal gizmo used for interactions on the x axis
  10102. */
  10103. xGizmo: AxisDragGizmo;
  10104. /**
  10105. * Internal gizmo used for interactions on the y axis
  10106. */
  10107. yGizmo: AxisDragGizmo;
  10108. /**
  10109. * Internal gizmo used for interactions on the z axis
  10110. */
  10111. zGizmo: AxisDragGizmo;
  10112. attachedMesh: Nullable<AbstractMesh>;
  10113. /**
  10114. * Creates a PositionGizmo
  10115. * @param gizmoLayer The utility layer the gizmo will be added to
  10116. */
  10117. constructor(gizmoLayer?: UtilityLayerRenderer);
  10118. updateGizmoRotationToMatchAttachedMesh: boolean;
  10119. /**
  10120. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10121. */
  10122. snapDistance: number;
  10123. /**
  10124. * Disposes of the gizmo
  10125. */
  10126. dispose(): void;
  10127. /**
  10128. * CustomMeshes are not supported by this gizmo
  10129. * @param mesh The mesh to replace the default mesh of the gizmo
  10130. */
  10131. setCustomMesh(mesh: Mesh): void;
  10132. }
  10133. }
  10134. declare module BABYLON {
  10135. /**
  10136. * Gizmo that enables rotating a mesh along 3 axis
  10137. */
  10138. class RotationGizmo extends Gizmo {
  10139. /**
  10140. * Internal gizmo used for interactions on the x axis
  10141. */
  10142. xGizmo: PlaneRotationGizmo;
  10143. /**
  10144. * Internal gizmo used for interactions on the y axis
  10145. */
  10146. yGizmo: PlaneRotationGizmo;
  10147. /**
  10148. * Internal gizmo used for interactions on the z axis
  10149. */
  10150. zGizmo: PlaneRotationGizmo;
  10151. attachedMesh: Nullable<AbstractMesh>;
  10152. /**
  10153. * Creates a RotationGizmo
  10154. * @param gizmoLayer The utility layer the gizmo will be added to
  10155. */
  10156. constructor(gizmoLayer?: UtilityLayerRenderer);
  10157. updateGizmoRotationToMatchAttachedMesh: boolean;
  10158. /**
  10159. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10160. */
  10161. snapDistance: number;
  10162. /**
  10163. * Disposes of the gizmo
  10164. */
  10165. dispose(): void;
  10166. /**
  10167. * CustomMeshes are not supported by this gizmo
  10168. * @param mesh The mesh to replace the default mesh of the gizmo
  10169. */
  10170. setCustomMesh(mesh: Mesh): void;
  10171. }
  10172. }
  10173. declare module BABYLON {
  10174. /**
  10175. * Gizmo that enables scaling a mesh along 3 axis
  10176. */
  10177. class ScaleGizmo extends Gizmo {
  10178. /**
  10179. * Internal gizmo used for interactions on the x axis
  10180. */
  10181. xGizmo: AxisScaleGizmo;
  10182. /**
  10183. * Internal gizmo used for interactions on the y axis
  10184. */
  10185. yGizmo: AxisScaleGizmo;
  10186. /**
  10187. * Internal gizmo used for interactions on the z axis
  10188. */
  10189. zGizmo: AxisScaleGizmo;
  10190. /**
  10191. * @hidden
  10192. * Internal gizmo used to scale all axis equally
  10193. */
  10194. private _uniformGizmo;
  10195. attachedMesh: Nullable<AbstractMesh>;
  10196. /**
  10197. * Creates a ScaleGizmo
  10198. * @param gizmoLayer The utility layer the gizmo will be added to
  10199. */
  10200. constructor(gizmoLayer?: UtilityLayerRenderer);
  10201. updateGizmoRotationToMatchAttachedMesh: boolean;
  10202. /**
  10203. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10204. */
  10205. snapDistance: number;
  10206. /**
  10207. * Disposes of the gizmo
  10208. */
  10209. dispose(): void;
  10210. }
  10211. }
  10212. declare module BABYLON {
  10213. /**
  10214. * Represents the different options available during the creation of
  10215. * a Environment helper.
  10216. *
  10217. * This can control the default ground, skybox and image processing setup of your scene.
  10218. */
  10219. interface IEnvironmentHelperOptions {
  10220. /**
  10221. * Specifies wether or not to create a ground.
  10222. * True by default.
  10223. */
  10224. createGround: boolean;
  10225. /**
  10226. * Specifies the ground size.
  10227. * 15 by default.
  10228. */
  10229. groundSize: number;
  10230. /**
  10231. * The texture used on the ground for the main color.
  10232. * Comes from the BabylonJS CDN by default.
  10233. *
  10234. * Remarks: Can be either a texture or a url.
  10235. */
  10236. groundTexture: string | BaseTexture;
  10237. /**
  10238. * The color mixed in the ground texture by default.
  10239. * BabylonJS clearColor by default.
  10240. */
  10241. groundColor: Color3;
  10242. /**
  10243. * Specifies the ground opacity.
  10244. * 1 by default.
  10245. */
  10246. groundOpacity: number;
  10247. /**
  10248. * Enables the ground to receive shadows.
  10249. * True by default.
  10250. */
  10251. enableGroundShadow: boolean;
  10252. /**
  10253. * Helps preventing the shadow to be fully black on the ground.
  10254. * 0.5 by default.
  10255. */
  10256. groundShadowLevel: number;
  10257. /**
  10258. * Creates a mirror texture attach to the ground.
  10259. * false by default.
  10260. */
  10261. enableGroundMirror: boolean;
  10262. /**
  10263. * Specifies the ground mirror size ratio.
  10264. * 0.3 by default as the default kernel is 64.
  10265. */
  10266. groundMirrorSizeRatio: number;
  10267. /**
  10268. * Specifies the ground mirror blur kernel size.
  10269. * 64 by default.
  10270. */
  10271. groundMirrorBlurKernel: number;
  10272. /**
  10273. * Specifies the ground mirror visibility amount.
  10274. * 1 by default
  10275. */
  10276. groundMirrorAmount: number;
  10277. /**
  10278. * Specifies the ground mirror reflectance weight.
  10279. * This uses the standard weight of the background material to setup the fresnel effect
  10280. * of the mirror.
  10281. * 1 by default.
  10282. */
  10283. groundMirrorFresnelWeight: number;
  10284. /**
  10285. * Specifies the ground mirror Falloff distance.
  10286. * This can helps reducing the size of the reflection.
  10287. * 0 by Default.
  10288. */
  10289. groundMirrorFallOffDistance: number;
  10290. /**
  10291. * Specifies the ground mirror texture type.
  10292. * Unsigned Int by Default.
  10293. */
  10294. groundMirrorTextureType: number;
  10295. /**
  10296. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  10297. * the shown objects.
  10298. */
  10299. groundYBias: number;
  10300. /**
  10301. * Specifies wether or not to create a skybox.
  10302. * True by default.
  10303. */
  10304. createSkybox: boolean;
  10305. /**
  10306. * Specifies the skybox size.
  10307. * 20 by default.
  10308. */
  10309. skyboxSize: number;
  10310. /**
  10311. * The texture used on the skybox for the main color.
  10312. * Comes from the BabylonJS CDN by default.
  10313. *
  10314. * Remarks: Can be either a texture or a url.
  10315. */
  10316. skyboxTexture: string | BaseTexture;
  10317. /**
  10318. * The color mixed in the skybox texture by default.
  10319. * BabylonJS clearColor by default.
  10320. */
  10321. skyboxColor: Color3;
  10322. /**
  10323. * The background rotation around the Y axis of the scene.
  10324. * This helps aligning the key lights of your scene with the background.
  10325. * 0 by default.
  10326. */
  10327. backgroundYRotation: number;
  10328. /**
  10329. * Compute automatically the size of the elements to best fit with the scene.
  10330. */
  10331. sizeAuto: boolean;
  10332. /**
  10333. * Default position of the rootMesh if autoSize is not true.
  10334. */
  10335. rootPosition: Vector3;
  10336. /**
  10337. * Sets up the image processing in the scene.
  10338. * true by default.
  10339. */
  10340. setupImageProcessing: boolean;
  10341. /**
  10342. * The texture used as your environment texture in the scene.
  10343. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  10344. *
  10345. * Remarks: Can be either a texture or a url.
  10346. */
  10347. environmentTexture: string | BaseTexture;
  10348. /**
  10349. * The value of the exposure to apply to the scene.
  10350. * 0.6 by default if setupImageProcessing is true.
  10351. */
  10352. cameraExposure: number;
  10353. /**
  10354. * The value of the contrast to apply to the scene.
  10355. * 1.6 by default if setupImageProcessing is true.
  10356. */
  10357. cameraContrast: number;
  10358. /**
  10359. * Specifies wether or not tonemapping should be enabled in the scene.
  10360. * true by default if setupImageProcessing is true.
  10361. */
  10362. toneMappingEnabled: boolean;
  10363. }
  10364. /**
  10365. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  10366. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  10367. * It also helps with the default setup of your imageProcessing configuration.
  10368. */
  10369. class EnvironmentHelper {
  10370. /**
  10371. * Default ground texture URL.
  10372. */
  10373. private static _groundTextureCDNUrl;
  10374. /**
  10375. * Default skybox texture URL.
  10376. */
  10377. private static _skyboxTextureCDNUrl;
  10378. /**
  10379. * Default environment texture URL.
  10380. */
  10381. private static _environmentTextureCDNUrl;
  10382. /**
  10383. * Creates the default options for the helper.
  10384. */
  10385. private static _getDefaultOptions;
  10386. private _rootMesh;
  10387. /**
  10388. * Gets the root mesh created by the helper.
  10389. */
  10390. readonly rootMesh: Mesh;
  10391. private _skybox;
  10392. /**
  10393. * Gets the skybox created by the helper.
  10394. */
  10395. readonly skybox: Nullable<Mesh>;
  10396. private _skyboxTexture;
  10397. /**
  10398. * Gets the skybox texture created by the helper.
  10399. */
  10400. readonly skyboxTexture: Nullable<BaseTexture>;
  10401. private _skyboxMaterial;
  10402. /**
  10403. * Gets the skybox material created by the helper.
  10404. */
  10405. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  10406. private _ground;
  10407. /**
  10408. * Gets the ground mesh created by the helper.
  10409. */
  10410. readonly ground: Nullable<Mesh>;
  10411. private _groundTexture;
  10412. /**
  10413. * Gets the ground texture created by the helper.
  10414. */
  10415. readonly groundTexture: Nullable<BaseTexture>;
  10416. private _groundMirror;
  10417. /**
  10418. * Gets the ground mirror created by the helper.
  10419. */
  10420. readonly groundMirror: Nullable<MirrorTexture>;
  10421. /**
  10422. * Gets the ground mirror render list to helps pushing the meshes
  10423. * you wish in the ground reflection.
  10424. */
  10425. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  10426. private _groundMaterial;
  10427. /**
  10428. * Gets the ground material created by the helper.
  10429. */
  10430. readonly groundMaterial: Nullable<BackgroundMaterial>;
  10431. /**
  10432. * Stores the creation options.
  10433. */
  10434. private readonly _scene;
  10435. private _options;
  10436. /**
  10437. * This observable will be notified with any error during the creation of the environment,
  10438. * mainly texture creation errors.
  10439. */
  10440. onErrorObservable: Observable<{
  10441. message?: string;
  10442. exception?: any;
  10443. }>;
  10444. /**
  10445. * constructor
  10446. * @param options
  10447. * @param scene The scene to add the material to
  10448. */
  10449. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  10450. /**
  10451. * Updates the background according to the new options
  10452. * @param options
  10453. */
  10454. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  10455. /**
  10456. * Sets the primary color of all the available elements.
  10457. * @param color the main color to affect to the ground and the background
  10458. */
  10459. setMainColor(color: Color3): void;
  10460. /**
  10461. * Setup the image processing according to the specified options.
  10462. */
  10463. private _setupImageProcessing;
  10464. /**
  10465. * Setup the environment texture according to the specified options.
  10466. */
  10467. private _setupEnvironmentTexture;
  10468. /**
  10469. * Setup the background according to the specified options.
  10470. */
  10471. private _setupBackground;
  10472. /**
  10473. * Get the scene sizes according to the setup.
  10474. */
  10475. private _getSceneSize;
  10476. /**
  10477. * Setup the ground according to the specified options.
  10478. */
  10479. private _setupGround;
  10480. /**
  10481. * Setup the ground material according to the specified options.
  10482. */
  10483. private _setupGroundMaterial;
  10484. /**
  10485. * Setup the ground diffuse texture according to the specified options.
  10486. */
  10487. private _setupGroundDiffuseTexture;
  10488. /**
  10489. * Setup the ground mirror texture according to the specified options.
  10490. */
  10491. private _setupGroundMirrorTexture;
  10492. /**
  10493. * Setup the ground to receive the mirror texture.
  10494. */
  10495. private _setupMirrorInGroundMaterial;
  10496. /**
  10497. * Setup the skybox according to the specified options.
  10498. */
  10499. private _setupSkybox;
  10500. /**
  10501. * Setup the skybox material according to the specified options.
  10502. */
  10503. private _setupSkyboxMaterial;
  10504. /**
  10505. * Setup the skybox reflection texture according to the specified options.
  10506. */
  10507. private _setupSkyboxReflectionTexture;
  10508. private _errorHandler;
  10509. /**
  10510. * Dispose all the elements created by the Helper.
  10511. */
  10512. dispose(): void;
  10513. }
  10514. }
  10515. declare module BABYLON {
  10516. /**
  10517. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  10518. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  10519. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  10520. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10521. */
  10522. class PhotoDome extends TransformNode {
  10523. private _useDirectMapping;
  10524. /**
  10525. * The texture being displayed on the sphere
  10526. */
  10527. protected _photoTexture: Texture;
  10528. /**
  10529. * Gets or sets the texture being displayed on the sphere
  10530. */
  10531. photoTexture: Texture;
  10532. /**
  10533. * The skybox material
  10534. */
  10535. protected _material: BackgroundMaterial;
  10536. /**
  10537. * The surface used for the skybox
  10538. */
  10539. protected _mesh: Mesh;
  10540. /**
  10541. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10542. * Also see the options.resolution property.
  10543. */
  10544. fovMultiplier: number;
  10545. /**
  10546. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  10547. * @param name Element's name, child elements will append suffixes for their own names.
  10548. * @param urlsOfPhoto define the url of the photo to display
  10549. * @param options An object containing optional or exposed sub element properties
  10550. */
  10551. constructor(name: string, urlOfPhoto: string, options: {
  10552. resolution?: number;
  10553. size?: number;
  10554. useDirectMapping?: boolean;
  10555. }, scene: Scene);
  10556. /**
  10557. * Releases resources associated with this node.
  10558. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10559. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10560. */
  10561. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10562. }
  10563. }
  10564. declare module BABYLON {
  10565. /**
  10566. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  10567. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  10568. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  10569. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10570. */
  10571. class VideoDome extends TransformNode {
  10572. private _useDirectMapping;
  10573. /**
  10574. * The video texture being displayed on the sphere
  10575. */
  10576. protected _videoTexture: VideoTexture;
  10577. /**
  10578. * Gets the video texture being displayed on the sphere
  10579. */
  10580. readonly videoTexture: VideoTexture;
  10581. /**
  10582. * The skybox material
  10583. */
  10584. protected _material: BackgroundMaterial;
  10585. /**
  10586. * The surface used for the skybox
  10587. */
  10588. protected _mesh: Mesh;
  10589. /**
  10590. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10591. * Also see the options.resolution property.
  10592. */
  10593. fovMultiplier: number;
  10594. /**
  10595. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  10596. * @param name Element's name, child elements will append suffixes for their own names.
  10597. * @param urlsOrVideo defines the url(s) or the video element to use
  10598. * @param options An object containing optional or exposed sub element properties
  10599. */
  10600. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  10601. resolution?: number;
  10602. clickToPlay?: boolean;
  10603. autoPlay?: boolean;
  10604. loop?: boolean;
  10605. size?: number;
  10606. poster?: string;
  10607. useDirectMapping?: boolean;
  10608. }, scene: Scene);
  10609. /**
  10610. * Releases resources associated with this node.
  10611. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10612. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10613. */
  10614. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10615. }
  10616. }
  10617. declare module BABYLON {
  10618. /**
  10619. * This class can be used to get instrumentation data from a Babylon engine
  10620. */
  10621. class EngineInstrumentation implements IDisposable {
  10622. engine: Engine;
  10623. private _captureGPUFrameTime;
  10624. private _gpuFrameTimeToken;
  10625. private _gpuFrameTime;
  10626. private _captureShaderCompilationTime;
  10627. private _shaderCompilationTime;
  10628. private _onBeginFrameObserver;
  10629. private _onEndFrameObserver;
  10630. private _onBeforeShaderCompilationObserver;
  10631. private _onAfterShaderCompilationObserver;
  10632. /**
  10633. * Gets the perf counter used for GPU frame time
  10634. */
  10635. readonly gpuFrameTimeCounter: PerfCounter;
  10636. /**
  10637. * Gets the GPU frame time capture status
  10638. */
  10639. /**
  10640. * Enable or disable the GPU frame time capture
  10641. */
  10642. captureGPUFrameTime: boolean;
  10643. /**
  10644. * Gets the perf counter used for shader compilation time
  10645. */
  10646. readonly shaderCompilationTimeCounter: PerfCounter;
  10647. /**
  10648. * Gets the shader compilation time capture status
  10649. */
  10650. /**
  10651. * Enable or disable the shader compilation time capture
  10652. */
  10653. captureShaderCompilationTime: boolean;
  10654. constructor(engine: Engine);
  10655. dispose(): void;
  10656. }
  10657. }
  10658. declare module BABYLON {
  10659. /**
  10660. * This class can be used to get instrumentation data from a Babylon engine
  10661. */
  10662. class SceneInstrumentation implements IDisposable {
  10663. scene: Scene;
  10664. private _captureActiveMeshesEvaluationTime;
  10665. private _activeMeshesEvaluationTime;
  10666. private _captureRenderTargetsRenderTime;
  10667. private _renderTargetsRenderTime;
  10668. private _captureFrameTime;
  10669. private _frameTime;
  10670. private _captureRenderTime;
  10671. private _renderTime;
  10672. private _captureInterFrameTime;
  10673. private _interFrameTime;
  10674. private _captureParticlesRenderTime;
  10675. private _particlesRenderTime;
  10676. private _captureSpritesRenderTime;
  10677. private _spritesRenderTime;
  10678. private _capturePhysicsTime;
  10679. private _physicsTime;
  10680. private _captureAnimationsTime;
  10681. private _animationsTime;
  10682. private _captureCameraRenderTime;
  10683. private _cameraRenderTime;
  10684. private _onBeforeActiveMeshesEvaluationObserver;
  10685. private _onAfterActiveMeshesEvaluationObserver;
  10686. private _onBeforeRenderTargetsRenderObserver;
  10687. private _onAfterRenderTargetsRenderObserver;
  10688. private _onAfterRenderObserver;
  10689. private _onBeforeDrawPhaseObserver;
  10690. private _onAfterDrawPhaseObserver;
  10691. private _onBeforeAnimationsObserver;
  10692. private _onBeforeParticlesRenderingObserver;
  10693. private _onAfterParticlesRenderingObserver;
  10694. private _onBeforeSpritesRenderingObserver;
  10695. private _onAfterSpritesRenderingObserver;
  10696. private _onBeforePhysicsObserver;
  10697. private _onAfterPhysicsObserver;
  10698. private _onAfterAnimationsObserver;
  10699. private _onBeforeCameraRenderObserver;
  10700. private _onAfterCameraRenderObserver;
  10701. /**
  10702. * Gets the perf counter used for active meshes evaluation time
  10703. */
  10704. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  10705. /**
  10706. * Gets the active meshes evaluation time capture status
  10707. */
  10708. /**
  10709. * Enable or disable the active meshes evaluation time capture
  10710. */
  10711. captureActiveMeshesEvaluationTime: boolean;
  10712. /**
  10713. * Gets the perf counter used for render targets render time
  10714. */
  10715. readonly renderTargetsRenderTimeCounter: PerfCounter;
  10716. /**
  10717. * Gets the render targets render time capture status
  10718. */
  10719. /**
  10720. * Enable or disable the render targets render time capture
  10721. */
  10722. captureRenderTargetsRenderTime: boolean;
  10723. /**
  10724. * Gets the perf counter used for particles render time
  10725. */
  10726. readonly particlesRenderTimeCounter: PerfCounter;
  10727. /**
  10728. * Gets the particles render time capture status
  10729. */
  10730. /**
  10731. * Enable or disable the particles render time capture
  10732. */
  10733. captureParticlesRenderTime: boolean;
  10734. /**
  10735. * Gets the perf counter used for sprites render time
  10736. */
  10737. readonly spritesRenderTimeCounter: PerfCounter;
  10738. /**
  10739. * Gets the sprites render time capture status
  10740. */
  10741. /**
  10742. * Enable or disable the sprites render time capture
  10743. */
  10744. captureSpritesRenderTime: boolean;
  10745. /**
  10746. * Gets the perf counter used for physics time
  10747. */
  10748. readonly physicsTimeCounter: PerfCounter;
  10749. /**
  10750. * Gets the physics time capture status
  10751. */
  10752. /**
  10753. * Enable or disable the physics time capture
  10754. */
  10755. capturePhysicsTime: boolean;
  10756. /**
  10757. * Gets the perf counter used for animations time
  10758. */
  10759. readonly animationsTimeCounter: PerfCounter;
  10760. /**
  10761. * Gets the animations time capture status
  10762. */
  10763. /**
  10764. * Enable or disable the animations time capture
  10765. */
  10766. captureAnimationsTime: boolean;
  10767. /**
  10768. * Gets the perf counter used for frame time capture
  10769. */
  10770. readonly frameTimeCounter: PerfCounter;
  10771. /**
  10772. * Gets the frame time capture status
  10773. */
  10774. /**
  10775. * Enable or disable the frame time capture
  10776. */
  10777. captureFrameTime: boolean;
  10778. /**
  10779. * Gets the perf counter used for inter-frames time capture
  10780. */
  10781. readonly interFrameTimeCounter: PerfCounter;
  10782. /**
  10783. * Gets the inter-frames time capture status
  10784. */
  10785. /**
  10786. * Enable or disable the inter-frames time capture
  10787. */
  10788. captureInterFrameTime: boolean;
  10789. /**
  10790. * Gets the perf counter used for render time capture
  10791. */
  10792. readonly renderTimeCounter: PerfCounter;
  10793. /**
  10794. * Gets the render time capture status
  10795. */
  10796. /**
  10797. * Enable or disable the render time capture
  10798. */
  10799. captureRenderTime: boolean;
  10800. /**
  10801. * Gets the perf counter used for camera render time capture
  10802. */
  10803. readonly cameraRenderTimeCounter: PerfCounter;
  10804. /**
  10805. * Gets the camera render time capture status
  10806. */
  10807. /**
  10808. * Enable or disable the camera render time capture
  10809. */
  10810. captureCameraRenderTime: boolean;
  10811. /**
  10812. * Gets the perf counter used for draw calls
  10813. */
  10814. readonly drawCallsCounter: PerfCounter;
  10815. /**
  10816. * Gets the perf counter used for texture collisions
  10817. */
  10818. readonly textureCollisionsCounter: PerfCounter;
  10819. constructor(scene: Scene);
  10820. dispose(): void;
  10821. }
  10822. }
  10823. declare module BABYLON {
  10824. /**
  10825. * @hidden
  10826. **/
  10827. class _TimeToken {
  10828. _startTimeQuery: Nullable<WebGLQuery>;
  10829. _endTimeQuery: Nullable<WebGLQuery>;
  10830. _timeElapsedQuery: Nullable<WebGLQuery>;
  10831. _timeElapsedQueryEnded: boolean;
  10832. }
  10833. }
  10834. declare module BABYLON {
  10835. /**
  10836. * Effect layer options. This helps customizing the behaviour
  10837. * of the effect layer.
  10838. */
  10839. interface IEffectLayerOptions {
  10840. /**
  10841. * Multiplication factor apply to the canvas size to compute the render target size
  10842. * used to generated the objects (the smaller the faster).
  10843. */
  10844. mainTextureRatio: number;
  10845. /**
  10846. * Enforces a fixed size texture to ensure effect stability across devices.
  10847. */
  10848. mainTextureFixedSize?: number;
  10849. /**
  10850. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  10851. */
  10852. alphaBlendingMode: number;
  10853. /**
  10854. * The camera attached to the layer.
  10855. */
  10856. camera: Nullable<Camera>;
  10857. /**
  10858. * The rendering group to draw the layer in.
  10859. */
  10860. renderingGroupId: number;
  10861. }
  10862. /**
  10863. * The effect layer Helps adding post process effect blended with the main pass.
  10864. *
  10865. * This can be for instance use to generate glow or higlight effects on the scene.
  10866. *
  10867. * The effect layer class can not be used directly and is intented to inherited from to be
  10868. * customized per effects.
  10869. */
  10870. abstract class EffectLayer {
  10871. private _vertexBuffers;
  10872. private _indexBuffer;
  10873. private _cachedDefines;
  10874. private _effectLayerMapGenerationEffect;
  10875. private _effectLayerOptions;
  10876. private _mergeEffect;
  10877. protected _scene: Scene;
  10878. protected _engine: Engine;
  10879. protected _maxSize: number;
  10880. protected _mainTextureDesiredSize: ISize;
  10881. protected _mainTexture: RenderTargetTexture;
  10882. protected _shouldRender: boolean;
  10883. protected _postProcesses: PostProcess[];
  10884. protected _textures: BaseTexture[];
  10885. protected _emissiveTextureAndColor: {
  10886. texture: Nullable<BaseTexture>;
  10887. color: Color4;
  10888. };
  10889. /**
  10890. * The name of the layer
  10891. */
  10892. name: string;
  10893. /**
  10894. * The clear color of the texture used to generate the glow map.
  10895. */
  10896. neutralColor: Color4;
  10897. /**
  10898. * Specifies wether the highlight layer is enabled or not.
  10899. */
  10900. isEnabled: boolean;
  10901. /**
  10902. * Gets the camera attached to the layer.
  10903. */
  10904. readonly camera: Nullable<Camera>;
  10905. /**
  10906. * Gets the rendering group id the layer should render in.
  10907. */
  10908. readonly renderingGroupId: number;
  10909. /**
  10910. * An event triggered when the effect layer has been disposed.
  10911. */
  10912. onDisposeObservable: Observable<EffectLayer>;
  10913. /**
  10914. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  10915. */
  10916. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  10917. /**
  10918. * An event triggered when the generated texture is being merged in the scene.
  10919. */
  10920. onBeforeComposeObservable: Observable<EffectLayer>;
  10921. /**
  10922. * An event triggered when the generated texture has been merged in the scene.
  10923. */
  10924. onAfterComposeObservable: Observable<EffectLayer>;
  10925. /**
  10926. * An event triggered when the efffect layer changes its size.
  10927. */
  10928. onSizeChangedObservable: Observable<EffectLayer>;
  10929. /**
  10930. * Instantiates a new effect Layer and references it in the scene.
  10931. * @param name The name of the layer
  10932. * @param scene The scene to use the layer in
  10933. */
  10934. constructor(
  10935. /** The Friendly of the effect in the scene */
  10936. name: string, scene: Scene);
  10937. /**
  10938. * Get the effect name of the layer.
  10939. * @return The effect name
  10940. */
  10941. abstract getEffectName(): string;
  10942. /**
  10943. * Checks for the readiness of the element composing the layer.
  10944. * @param subMesh the mesh to check for
  10945. * @param useInstances specify wether or not to use instances to render the mesh
  10946. * @return true if ready otherwise, false
  10947. */
  10948. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10949. /**
  10950. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10951. * @returns true if the effect requires stencil during the main canvas render pass.
  10952. */
  10953. abstract needStencil(): boolean;
  10954. /**
  10955. * Create the merge effect. This is the shader use to blit the information back
  10956. * to the main canvas at the end of the scene rendering.
  10957. * @returns The effect containing the shader used to merge the effect on the main canvas
  10958. */
  10959. protected abstract _createMergeEffect(): Effect;
  10960. /**
  10961. * Creates the render target textures and post processes used in the effect layer.
  10962. */
  10963. protected abstract _createTextureAndPostProcesses(): void;
  10964. /**
  10965. * Implementation specific of rendering the generating effect on the main canvas.
  10966. * @param effect The effect used to render through
  10967. */
  10968. protected abstract _internalRender(effect: Effect): void;
  10969. /**
  10970. * Sets the required values for both the emissive texture and and the main color.
  10971. */
  10972. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10973. /**
  10974. * Free any resources and references associated to a mesh.
  10975. * Internal use
  10976. * @param mesh The mesh to free.
  10977. */
  10978. abstract _disposeMesh(mesh: Mesh): void;
  10979. /**
  10980. * Serializes this layer (Glow or Highlight for example)
  10981. * @returns a serialized layer object
  10982. */
  10983. abstract serialize?(): any;
  10984. /**
  10985. * Initializes the effect layer with the required options.
  10986. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  10987. */
  10988. protected _init(options: Partial<IEffectLayerOptions>): void;
  10989. /**
  10990. * Generates the index buffer of the full screen quad blending to the main canvas.
  10991. */
  10992. private _generateIndexBuffer;
  10993. /**
  10994. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  10995. */
  10996. private _genrateVertexBuffer;
  10997. /**
  10998. * Sets the main texture desired size which is the closest power of two
  10999. * of the engine canvas size.
  11000. */
  11001. private _setMainTextureSize;
  11002. /**
  11003. * Creates the main texture for the effect layer.
  11004. */
  11005. protected _createMainTexture(): void;
  11006. /**
  11007. * Checks for the readiness of the element composing the layer.
  11008. * @param subMesh the mesh to check for
  11009. * @param useInstances specify wether or not to use instances to render the mesh
  11010. * @param emissiveTexture the associated emissive texture used to generate the glow
  11011. * @return true if ready otherwise, false
  11012. */
  11013. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  11014. /**
  11015. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  11016. */
  11017. render(): void;
  11018. /**
  11019. * Determine if a given mesh will be used in the current effect.
  11020. * @param mesh mesh to test
  11021. * @returns true if the mesh will be used
  11022. */
  11023. hasMesh(mesh: AbstractMesh): boolean;
  11024. /**
  11025. * Returns true if the layer contains information to display, otherwise false.
  11026. * @returns true if the glow layer should be rendered
  11027. */
  11028. shouldRender(): boolean;
  11029. /**
  11030. * Returns true if the mesh should render, otherwise false.
  11031. * @param mesh The mesh to render
  11032. * @returns true if it should render otherwise false
  11033. */
  11034. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11035. /**
  11036. * Returns true if the mesh should render, otherwise false.
  11037. * @param mesh The mesh to render
  11038. * @returns true if it should render otherwise false
  11039. */
  11040. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  11041. /**
  11042. * Renders the submesh passed in parameter to the generation map.
  11043. */
  11044. protected _renderSubMesh(subMesh: SubMesh): void;
  11045. /**
  11046. * Rebuild the required buffers.
  11047. * @hidden Internal use only.
  11048. */
  11049. _rebuild(): void;
  11050. /**
  11051. * Dispose only the render target textures and post process.
  11052. */
  11053. private _disposeTextureAndPostProcesses;
  11054. /**
  11055. * Dispose the highlight layer and free resources.
  11056. */
  11057. dispose(): void;
  11058. /**
  11059. * Gets the class name of the effect layer
  11060. * @returns the string with the class name of the effect layer
  11061. */
  11062. getClassName(): string;
  11063. /**
  11064. * Creates an effect layer from parsed effect layer data
  11065. * @param parsedEffectLayer defines effect layer data
  11066. * @param scene defines the current scene
  11067. * @param rootUrl defines the root URL containing the effect layer information
  11068. * @returns a parsed effect Layer
  11069. */
  11070. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  11071. }
  11072. }
  11073. declare module BABYLON {
  11074. interface AbstractScene {
  11075. /**
  11076. * The list of effect layers (highlights/glow) added to the scene
  11077. * @see http://doc.babylonjs.com/how_to/highlight_layer
  11078. * @see http://doc.babylonjs.com/how_to/glow_layer
  11079. */
  11080. effectLayers: Array<EffectLayer>;
  11081. /**
  11082. * Removes the given effect layer from this scene.
  11083. * @param toRemove defines the effect layer to remove
  11084. * @returns the index of the removed effect layer
  11085. */
  11086. removeEffectLayer(toRemove: EffectLayer): number;
  11087. /**
  11088. * Adds the given effect layer to this scene
  11089. * @param newEffectLayer defines the effect layer to add
  11090. */
  11091. addEffectLayer(newEffectLayer: EffectLayer): void;
  11092. }
  11093. /**
  11094. * Defines the layer scene component responsible to manage any effect layers
  11095. * in a given scene.
  11096. */
  11097. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  11098. /**
  11099. * The component name helpfull to identify the component in the list of scene components.
  11100. */
  11101. readonly name: string;
  11102. /**
  11103. * The scene the component belongs to.
  11104. */
  11105. scene: Scene;
  11106. private _engine;
  11107. private _renderEffects;
  11108. private _needStencil;
  11109. private _previousStencilState;
  11110. /**
  11111. * Creates a new instance of the component for the given scene
  11112. * @param scene Defines the scene to register the component in
  11113. */
  11114. constructor(scene: Scene);
  11115. /**
  11116. * Registers the component in a given scene
  11117. */
  11118. register(): void;
  11119. /**
  11120. * Rebuilds the elements related to this component in case of
  11121. * context lost for instance.
  11122. */
  11123. rebuild(): void;
  11124. /**
  11125. * Serializes the component data to the specified json object
  11126. * @param serializationObject The object to serialize to
  11127. */
  11128. serialize(serializationObject: any): void;
  11129. /**
  11130. * Adds all the element from the container to the scene
  11131. * @param container the container holding the elements
  11132. */
  11133. addFromContainer(container: AbstractScene): void;
  11134. /**
  11135. * Removes all the elements in the container from the scene
  11136. * @param container contains the elements to remove
  11137. */
  11138. removeFromContainer(container: AbstractScene): void;
  11139. /**
  11140. * Disposes the component and the associated ressources.
  11141. */
  11142. dispose(): void;
  11143. private _isReadyForMesh;
  11144. private _renderMainTexture;
  11145. private _setStencil;
  11146. private _setStencilBack;
  11147. private _draw;
  11148. private _drawCamera;
  11149. private _drawRenderingGroup;
  11150. }
  11151. }
  11152. declare module BABYLON {
  11153. interface AbstractScene {
  11154. /**
  11155. * Return a the first highlight layer of the scene with a given name.
  11156. * @param name The name of the highlight layer to look for.
  11157. * @return The highlight layer if found otherwise null.
  11158. */
  11159. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  11160. }
  11161. /**
  11162. * Glow layer options. This helps customizing the behaviour
  11163. * of the glow layer.
  11164. */
  11165. interface IGlowLayerOptions {
  11166. /**
  11167. * Multiplication factor apply to the canvas size to compute the render target size
  11168. * used to generated the glowing objects (the smaller the faster).
  11169. */
  11170. mainTextureRatio: number;
  11171. /**
  11172. * Enforces a fixed size texture to ensure resize independant blur.
  11173. */
  11174. mainTextureFixedSize?: number;
  11175. /**
  11176. * How big is the kernel of the blur texture.
  11177. */
  11178. blurKernelSize: number;
  11179. /**
  11180. * The camera attached to the layer.
  11181. */
  11182. camera: Nullable<Camera>;
  11183. /**
  11184. * Enable MSAA by chosing the number of samples.
  11185. */
  11186. mainTextureSamples?: number;
  11187. /**
  11188. * The rendering group to draw the layer in.
  11189. */
  11190. renderingGroupId: number;
  11191. }
  11192. /**
  11193. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  11194. *
  11195. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11196. * glowy meshes to your scene.
  11197. *
  11198. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  11199. */
  11200. class GlowLayer extends EffectLayer {
  11201. /**
  11202. * Effect Name of the layer.
  11203. */
  11204. static readonly EffectName: string;
  11205. /**
  11206. * The default blur kernel size used for the glow.
  11207. */
  11208. static DefaultBlurKernelSize: number;
  11209. /**
  11210. * The default texture size ratio used for the glow.
  11211. */
  11212. static DefaultTextureRatio: number;
  11213. /**
  11214. * Sets the kernel size of the blur.
  11215. */
  11216. /**
  11217. * Gets the kernel size of the blur.
  11218. */
  11219. blurKernelSize: number;
  11220. /**
  11221. * Sets the glow intensity.
  11222. */
  11223. /**
  11224. * Gets the glow intensity.
  11225. */
  11226. intensity: number;
  11227. private _options;
  11228. private _intensity;
  11229. private _horizontalBlurPostprocess1;
  11230. private _verticalBlurPostprocess1;
  11231. private _horizontalBlurPostprocess2;
  11232. private _verticalBlurPostprocess2;
  11233. private _blurTexture1;
  11234. private _blurTexture2;
  11235. private _postProcesses1;
  11236. private _postProcesses2;
  11237. private _includedOnlyMeshes;
  11238. private _excludedMeshes;
  11239. /**
  11240. * Callback used to let the user override the color selection on a per mesh basis
  11241. */
  11242. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  11243. /**
  11244. * Callback used to let the user override the texture selection on a per mesh basis
  11245. */
  11246. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  11247. /**
  11248. * Instantiates a new glow Layer and references it to the scene.
  11249. * @param name The name of the layer
  11250. * @param scene The scene to use the layer in
  11251. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  11252. */
  11253. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  11254. /**
  11255. * Get the effect name of the layer.
  11256. * @return The effect name
  11257. */
  11258. getEffectName(): string;
  11259. /**
  11260. * Create the merge effect. This is the shader use to blit the information back
  11261. * to the main canvas at the end of the scene rendering.
  11262. */
  11263. protected _createMergeEffect(): Effect;
  11264. /**
  11265. * Creates the render target textures and post processes used in the glow layer.
  11266. */
  11267. protected _createTextureAndPostProcesses(): void;
  11268. /**
  11269. * Checks for the readiness of the element composing the layer.
  11270. * @param subMesh the mesh to check for
  11271. * @param useInstances specify wether or not to use instances to render the mesh
  11272. * @param emissiveTexture the associated emissive texture used to generate the glow
  11273. * @return true if ready otherwise, false
  11274. */
  11275. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11276. /**
  11277. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11278. */
  11279. needStencil(): boolean;
  11280. /**
  11281. * Implementation specific of rendering the generating effect on the main canvas.
  11282. * @param effect The effect used to render through
  11283. */
  11284. protected _internalRender(effect: Effect): void;
  11285. /**
  11286. * Sets the required values for both the emissive texture and and the main color.
  11287. */
  11288. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11289. /**
  11290. * Returns true if the mesh should render, otherwise false.
  11291. * @param mesh The mesh to render
  11292. * @returns true if it should render otherwise false
  11293. */
  11294. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11295. /**
  11296. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  11297. * @param mesh The mesh to exclude from the glow layer
  11298. */
  11299. addExcludedMesh(mesh: Mesh): void;
  11300. /**
  11301. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  11302. * @param mesh The mesh to remove
  11303. */
  11304. removeExcludedMesh(mesh: Mesh): void;
  11305. /**
  11306. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  11307. * @param mesh The mesh to include in the glow layer
  11308. */
  11309. addIncludedOnlyMesh(mesh: Mesh): void;
  11310. /**
  11311. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  11312. * @param mesh The mesh to remove
  11313. */
  11314. removeIncludedOnlyMesh(mesh: Mesh): void;
  11315. /**
  11316. * Determine if a given mesh will be used in the glow layer
  11317. * @param mesh The mesh to test
  11318. * @returns true if the mesh will be highlighted by the current glow layer
  11319. */
  11320. hasMesh(mesh: AbstractMesh): boolean;
  11321. /**
  11322. * Free any resources and references associated to a mesh.
  11323. * Internal use
  11324. * @param mesh The mesh to free.
  11325. * @hidden
  11326. */
  11327. _disposeMesh(mesh: Mesh): void;
  11328. /**
  11329. * Gets the class name of the effect layer
  11330. * @returns the string with the class name of the effect layer
  11331. */
  11332. getClassName(): string;
  11333. /**
  11334. * Serializes this glow layer
  11335. * @returns a serialized glow layer object
  11336. */
  11337. serialize(): any;
  11338. /**
  11339. * Creates a Glow Layer from parsed glow layer data
  11340. * @param parsedGlowLayer defines glow layer data
  11341. * @param scene defines the current scene
  11342. * @param rootUrl defines the root URL containing the glow layer information
  11343. * @returns a parsed Glow Layer
  11344. */
  11345. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  11346. }
  11347. }
  11348. declare module BABYLON {
  11349. interface AbstractScene {
  11350. /**
  11351. * Return a the first highlight layer of the scene with a given name.
  11352. * @param name The name of the highlight layer to look for.
  11353. * @return The highlight layer if found otherwise null.
  11354. */
  11355. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  11356. }
  11357. /**
  11358. * Highlight layer options. This helps customizing the behaviour
  11359. * of the highlight layer.
  11360. */
  11361. interface IHighlightLayerOptions {
  11362. /**
  11363. * Multiplication factor apply to the canvas size to compute the render target size
  11364. * used to generated the glowing objects (the smaller the faster).
  11365. */
  11366. mainTextureRatio: number;
  11367. /**
  11368. * Enforces a fixed size texture to ensure resize independant blur.
  11369. */
  11370. mainTextureFixedSize?: number;
  11371. /**
  11372. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  11373. * of the picture to blur (the smaller the faster).
  11374. */
  11375. blurTextureSizeRatio: number;
  11376. /**
  11377. * How big in texel of the blur texture is the vertical blur.
  11378. */
  11379. blurVerticalSize: number;
  11380. /**
  11381. * How big in texel of the blur texture is the horizontal blur.
  11382. */
  11383. blurHorizontalSize: number;
  11384. /**
  11385. * Alpha blending mode used to apply the blur. Default is combine.
  11386. */
  11387. alphaBlendingMode: number;
  11388. /**
  11389. * The camera attached to the layer.
  11390. */
  11391. camera: Nullable<Camera>;
  11392. /**
  11393. * Should we display highlight as a solid stroke?
  11394. */
  11395. isStroke?: boolean;
  11396. /**
  11397. * The rendering group to draw the layer in.
  11398. */
  11399. renderingGroupId: number;
  11400. }
  11401. /**
  11402. * The highlight layer Helps adding a glow effect around a mesh.
  11403. *
  11404. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11405. * glowy meshes to your scene.
  11406. *
  11407. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  11408. */
  11409. class HighlightLayer extends EffectLayer {
  11410. name: string;
  11411. /**
  11412. * Effect Name of the highlight layer.
  11413. */
  11414. static readonly EffectName: string;
  11415. /**
  11416. * The neutral color used during the preparation of the glow effect.
  11417. * This is black by default as the blend operation is a blend operation.
  11418. */
  11419. static NeutralColor: Color4;
  11420. /**
  11421. * Stencil value used for glowing meshes.
  11422. */
  11423. static GlowingMeshStencilReference: number;
  11424. /**
  11425. * Stencil value used for the other meshes in the scene.
  11426. */
  11427. static NormalMeshStencilReference: number;
  11428. /**
  11429. * Specifies whether or not the inner glow is ACTIVE in the layer.
  11430. */
  11431. innerGlow: boolean;
  11432. /**
  11433. * Specifies whether or not the outer glow is ACTIVE in the layer.
  11434. */
  11435. outerGlow: boolean;
  11436. /**
  11437. * Specifies the horizontal size of the blur.
  11438. */
  11439. /**
  11440. * Gets the horizontal size of the blur.
  11441. */
  11442. blurHorizontalSize: number;
  11443. /**
  11444. * Specifies the vertical size of the blur.
  11445. */
  11446. /**
  11447. * Gets the vertical size of the blur.
  11448. */
  11449. blurVerticalSize: number;
  11450. /**
  11451. * An event triggered when the highlight layer is being blurred.
  11452. */
  11453. onBeforeBlurObservable: Observable<HighlightLayer>;
  11454. /**
  11455. * An event triggered when the highlight layer has been blurred.
  11456. */
  11457. onAfterBlurObservable: Observable<HighlightLayer>;
  11458. private _instanceGlowingMeshStencilReference;
  11459. private _options;
  11460. private _downSamplePostprocess;
  11461. private _horizontalBlurPostprocess;
  11462. private _verticalBlurPostprocess;
  11463. private _blurTexture;
  11464. private _meshes;
  11465. private _excludedMeshes;
  11466. /**
  11467. * Instantiates a new highlight Layer and references it to the scene..
  11468. * @param name The name of the layer
  11469. * @param scene The scene to use the layer in
  11470. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  11471. */
  11472. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  11473. /**
  11474. * Get the effect name of the layer.
  11475. * @return The effect name
  11476. */
  11477. getEffectName(): string;
  11478. /**
  11479. * Create the merge effect. This is the shader use to blit the information back
  11480. * to the main canvas at the end of the scene rendering.
  11481. */
  11482. protected _createMergeEffect(): Effect;
  11483. /**
  11484. * Creates the render target textures and post processes used in the highlight layer.
  11485. */
  11486. protected _createTextureAndPostProcesses(): void;
  11487. /**
  11488. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11489. */
  11490. needStencil(): boolean;
  11491. /**
  11492. * Checks for the readiness of the element composing the layer.
  11493. * @param subMesh the mesh to check for
  11494. * @param useInstances specify wether or not to use instances to render the mesh
  11495. * @param emissiveTexture the associated emissive texture used to generate the glow
  11496. * @return true if ready otherwise, false
  11497. */
  11498. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11499. /**
  11500. * Implementation specific of rendering the generating effect on the main canvas.
  11501. * @param effect The effect used to render through
  11502. */
  11503. protected _internalRender(effect: Effect): void;
  11504. /**
  11505. * Returns true if the layer contains information to display, otherwise false.
  11506. */
  11507. shouldRender(): boolean;
  11508. /**
  11509. * Returns true if the mesh should render, otherwise false.
  11510. * @param mesh The mesh to render
  11511. * @returns true if it should render otherwise false
  11512. */
  11513. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11514. /**
  11515. * Sets the required values for both the emissive texture and and the main color.
  11516. */
  11517. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11518. /**
  11519. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  11520. * @param mesh The mesh to exclude from the highlight layer
  11521. */
  11522. addExcludedMesh(mesh: Mesh): void;
  11523. /**
  11524. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  11525. * @param mesh The mesh to highlight
  11526. */
  11527. removeExcludedMesh(mesh: Mesh): void;
  11528. /**
  11529. * Determine if a given mesh will be highlighted by the current HighlightLayer
  11530. * @param mesh mesh to test
  11531. * @returns true if the mesh will be highlighted by the current HighlightLayer
  11532. */
  11533. hasMesh(mesh: AbstractMesh): boolean;
  11534. /**
  11535. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  11536. * @param mesh The mesh to highlight
  11537. * @param color The color of the highlight
  11538. * @param glowEmissiveOnly Extract the glow from the emissive texture
  11539. */
  11540. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  11541. /**
  11542. * Remove a mesh from the highlight layer in order to make it stop glowing.
  11543. * @param mesh The mesh to highlight
  11544. */
  11545. removeMesh(mesh: Mesh): void;
  11546. /**
  11547. * Force the stencil to the normal expected value for none glowing parts
  11548. */
  11549. private _defaultStencilReference;
  11550. /**
  11551. * Free any resources and references associated to a mesh.
  11552. * Internal use
  11553. * @param mesh The mesh to free.
  11554. * @hidden
  11555. */
  11556. _disposeMesh(mesh: Mesh): void;
  11557. /**
  11558. * Dispose the highlight layer and free resources.
  11559. */
  11560. dispose(): void;
  11561. /**
  11562. * Gets the class name of the effect layer
  11563. * @returns the string with the class name of the effect layer
  11564. */
  11565. getClassName(): string;
  11566. /**
  11567. * Serializes this Highlight layer
  11568. * @returns a serialized Highlight layer object
  11569. */
  11570. serialize(): any;
  11571. /**
  11572. * Creates a Highlight layer from parsed Highlight layer data
  11573. * @param parsedHightlightLayer defines the Highlight layer data
  11574. * @param scene defines the current scene
  11575. * @param rootUrl defines the root URL containing the Highlight layer information
  11576. * @returns a parsed Highlight layer
  11577. */
  11578. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  11579. }
  11580. }
  11581. declare module BABYLON {
  11582. class Layer {
  11583. name: string;
  11584. texture: Nullable<Texture>;
  11585. isBackground: boolean;
  11586. color: Color4;
  11587. scale: Vector2;
  11588. offset: Vector2;
  11589. alphaBlendingMode: number;
  11590. alphaTest: boolean;
  11591. layerMask: number;
  11592. private _scene;
  11593. private _vertexBuffers;
  11594. private _indexBuffer;
  11595. private _effect;
  11596. private _alphaTestEffect;
  11597. /**
  11598. * An event triggered when the layer is disposed.
  11599. */
  11600. onDisposeObservable: Observable<Layer>;
  11601. private _onDisposeObserver;
  11602. onDispose: () => void;
  11603. /**
  11604. * An event triggered before rendering the scene
  11605. */
  11606. onBeforeRenderObservable: Observable<Layer>;
  11607. private _onBeforeRenderObserver;
  11608. onBeforeRender: () => void;
  11609. /**
  11610. * An event triggered after rendering the scene
  11611. */
  11612. onAfterRenderObservable: Observable<Layer>;
  11613. private _onAfterRenderObserver;
  11614. onAfterRender: () => void;
  11615. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  11616. private _createIndexBuffer;
  11617. /** @hidden */
  11618. _rebuild(): void;
  11619. render(): void;
  11620. dispose(): void;
  11621. }
  11622. }
  11623. declare module BABYLON {
  11624. interface AbstractScene {
  11625. /**
  11626. * The list of layers (background and foreground) of the scene
  11627. */
  11628. layers: Array<Layer>;
  11629. }
  11630. /**
  11631. * Defines the layer scene component responsible to manage any layers
  11632. * in a given scene.
  11633. */
  11634. class LayerSceneComponent implements ISceneComponent {
  11635. /**
  11636. * The component name helpfull to identify the component in the list of scene components.
  11637. */
  11638. readonly name: string;
  11639. /**
  11640. * The scene the component belongs to.
  11641. */
  11642. scene: Scene;
  11643. private _engine;
  11644. /**
  11645. * Creates a new instance of the component for the given scene
  11646. * @param scene Defines the scene to register the component in
  11647. */
  11648. constructor(scene: Scene);
  11649. /**
  11650. * Registers the component in a given scene
  11651. */
  11652. register(): void;
  11653. /**
  11654. * Rebuilds the elements related to this component in case of
  11655. * context lost for instance.
  11656. */
  11657. rebuild(): void;
  11658. /**
  11659. * Disposes the component and the associated ressources.
  11660. */
  11661. dispose(): void;
  11662. private _draw;
  11663. private _drawBackground;
  11664. private _drawForeground;
  11665. }
  11666. }
  11667. declare module BABYLON {
  11668. class LensFlare {
  11669. size: number;
  11670. position: number;
  11671. color: Color3;
  11672. texture: Nullable<Texture>;
  11673. alphaMode: number;
  11674. private _system;
  11675. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  11676. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  11677. dispose(): void;
  11678. }
  11679. }
  11680. declare module BABYLON {
  11681. class LensFlareSystem {
  11682. name: string;
  11683. lensFlares: LensFlare[];
  11684. borderLimit: number;
  11685. viewportBorder: number;
  11686. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  11687. layerMask: number;
  11688. id: string;
  11689. private _scene;
  11690. private _emitter;
  11691. private _vertexBuffers;
  11692. private _indexBuffer;
  11693. private _effect;
  11694. private _positionX;
  11695. private _positionY;
  11696. private _isEnabled;
  11697. constructor(name: string, emitter: any, scene: Scene);
  11698. isEnabled: boolean;
  11699. getScene(): Scene;
  11700. getEmitter(): any;
  11701. setEmitter(newEmitter: any): void;
  11702. getEmitterPosition(): Vector3;
  11703. computeEffectivePosition(globalViewport: Viewport): boolean;
  11704. /** @hidden */
  11705. _isVisible(): boolean;
  11706. render(): boolean;
  11707. dispose(): void;
  11708. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  11709. serialize(): any;
  11710. }
  11711. }
  11712. declare module BABYLON {
  11713. interface AbstractScene {
  11714. /**
  11715. * The list of lens flare system added to the scene
  11716. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  11717. */
  11718. lensFlareSystems: Array<LensFlareSystem>;
  11719. /**
  11720. * Removes the given lens flare system from this scene.
  11721. * @param toRemove The lens flare system to remove
  11722. * @returns The index of the removed lens flare system
  11723. */
  11724. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  11725. /**
  11726. * Adds the given lens flare system to this scene
  11727. * @param newLensFlareSystem The lens flare system to add
  11728. */
  11729. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  11730. /**
  11731. * Gets a lens flare system using its name
  11732. * @param name defines the name to look for
  11733. * @returns the lens flare system or null if not found
  11734. */
  11735. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  11736. /**
  11737. * Gets a lens flare system using its id
  11738. * @param id defines the id to look for
  11739. * @returns the lens flare system or null if not found
  11740. */
  11741. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  11742. }
  11743. /**
  11744. * Defines the lens flare scene component responsible to manage any lens flares
  11745. * in a given scene.
  11746. */
  11747. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  11748. /**
  11749. * The component name helpfull to identify the component in the list of scene components.
  11750. */
  11751. readonly name: string;
  11752. /**
  11753. * The scene the component belongs to.
  11754. */
  11755. scene: Scene;
  11756. /**
  11757. * Creates a new instance of the component for the given scene
  11758. * @param scene Defines the scene to register the component in
  11759. */
  11760. constructor(scene: Scene);
  11761. /**
  11762. * Registers the component in a given scene
  11763. */
  11764. register(): void;
  11765. /**
  11766. * Rebuilds the elements related to this component in case of
  11767. * context lost for instance.
  11768. */
  11769. rebuild(): void;
  11770. /**
  11771. * Adds all the element from the container to the scene
  11772. * @param container the container holding the elements
  11773. */
  11774. addFromContainer(container: AbstractScene): void;
  11775. /**
  11776. * Removes all the elements in the container from the scene
  11777. * @param container contains the elements to remove
  11778. */
  11779. removeFromContainer(container: AbstractScene): void;
  11780. /**
  11781. * Serializes the component data to the specified json object
  11782. * @param serializationObject The object to serialize to
  11783. */
  11784. serialize(serializationObject: any): void;
  11785. /**
  11786. * Disposes the component and the associated ressources.
  11787. */
  11788. dispose(): void;
  11789. private _draw;
  11790. }
  11791. }
  11792. declare module BABYLON {
  11793. /**
  11794. * A directional light is defined by a direction (what a surprise!).
  11795. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  11796. * 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.
  11797. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11798. */
  11799. class DirectionalLight extends ShadowLight {
  11800. private _shadowFrustumSize;
  11801. /**
  11802. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  11803. */
  11804. /**
  11805. * Specifies a fix frustum size for the shadow generation.
  11806. */
  11807. shadowFrustumSize: number;
  11808. private _shadowOrthoScale;
  11809. /**
  11810. * Gets the shadow projection scale against the optimal computed one.
  11811. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11812. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11813. */
  11814. /**
  11815. * Sets the shadow projection scale against the optimal computed one.
  11816. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11817. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11818. */
  11819. shadowOrthoScale: number;
  11820. /**
  11821. * Automatically compute the projection matrix to best fit (including all the casters)
  11822. * on each frame.
  11823. */
  11824. autoUpdateExtends: boolean;
  11825. private _orthoLeft;
  11826. private _orthoRight;
  11827. private _orthoTop;
  11828. private _orthoBottom;
  11829. /**
  11830. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  11831. * The directional light is emitted from everywhere in the given direction.
  11832. * It can cast shawdows.
  11833. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11834. * @param name The friendly name of the light
  11835. * @param direction The direction of the light
  11836. * @param scene The scene the light belongs to
  11837. */
  11838. constructor(name: string, direction: Vector3, scene: Scene);
  11839. /**
  11840. * Returns the string "DirectionalLight".
  11841. * @return The class name
  11842. */
  11843. getClassName(): string;
  11844. /**
  11845. * Returns the integer 1.
  11846. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11847. */
  11848. getTypeID(): number;
  11849. /**
  11850. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  11851. * Returns the DirectionalLight Shadow projection matrix.
  11852. */
  11853. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11854. /**
  11855. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  11856. * Returns the DirectionalLight Shadow projection matrix.
  11857. */
  11858. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  11859. /**
  11860. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  11861. * Returns the DirectionalLight Shadow projection matrix.
  11862. */
  11863. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11864. protected _buildUniformLayout(): void;
  11865. /**
  11866. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  11867. * @param effect The effect to update
  11868. * @param lightIndex The index of the light in the effect to update
  11869. * @returns The directional light
  11870. */
  11871. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  11872. /**
  11873. * Gets the minZ used for shadow according to both the scene and the light.
  11874. *
  11875. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11876. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11877. * @param activeCamera The camera we are returning the min for
  11878. * @returns the depth min z
  11879. */
  11880. getDepthMinZ(activeCamera: Camera): number;
  11881. /**
  11882. * Gets the maxZ used for shadow according to both the scene and the light.
  11883. *
  11884. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11885. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11886. * @param activeCamera The camera we are returning the max for
  11887. * @returns the depth max z
  11888. */
  11889. getDepthMaxZ(activeCamera: Camera): number;
  11890. /**
  11891. * Prepares the list of defines specific to the light type.
  11892. * @param defines the list of defines
  11893. * @param lightIndex defines the index of the light for the effect
  11894. */
  11895. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11896. }
  11897. }
  11898. declare module BABYLON {
  11899. /**
  11900. * The HemisphericLight simulates the ambient environment light,
  11901. * so the passed direction is the light reflection direction, not the incoming direction.
  11902. */
  11903. class HemisphericLight extends Light {
  11904. /**
  11905. * The groundColor is the light in the opposite direction to the one specified during creation.
  11906. * 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.
  11907. */
  11908. groundColor: Color3;
  11909. /**
  11910. * The light reflection direction, not the incoming direction.
  11911. */
  11912. direction: Vector3;
  11913. private _worldMatrix;
  11914. /**
  11915. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  11916. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  11917. * The HemisphericLight can't cast shadows.
  11918. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11919. * @param name The friendly name of the light
  11920. * @param direction The direction of the light reflection
  11921. * @param scene The scene the light belongs to
  11922. */
  11923. constructor(name: string, direction: Vector3, scene: Scene);
  11924. protected _buildUniformLayout(): void;
  11925. /**
  11926. * Returns the string "HemisphericLight".
  11927. * @return The class name
  11928. */
  11929. getClassName(): string;
  11930. /**
  11931. * Sets the HemisphericLight direction towards the passed target (Vector3).
  11932. * Returns the updated direction.
  11933. * @param target The target the direction should point to
  11934. * @return The computed direction
  11935. */
  11936. setDirectionToTarget(target: Vector3): Vector3;
  11937. /**
  11938. * Returns the shadow generator associated to the light.
  11939. * @returns Always null for hemispheric lights because it does not support shadows.
  11940. */
  11941. getShadowGenerator(): Nullable<ShadowGenerator>;
  11942. /**
  11943. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  11944. * @param effect The effect to update
  11945. * @param lightIndex The index of the light in the effect to update
  11946. * @returns The hemispheric light
  11947. */
  11948. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  11949. /**
  11950. * @hidden internal use only.
  11951. */
  11952. _getWorldMatrix(): Matrix;
  11953. /**
  11954. * Returns the integer 3.
  11955. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11956. */
  11957. getTypeID(): number;
  11958. /**
  11959. * Prepares the list of defines specific to the light type.
  11960. * @param defines the list of defines
  11961. * @param lightIndex defines the index of the light for the effect
  11962. */
  11963. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11964. }
  11965. }
  11966. declare module BABYLON {
  11967. /**
  11968. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11969. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11970. * 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.
  11971. */
  11972. abstract class Light extends Node {
  11973. /**
  11974. * Falloff Default: light is falling off following the material specification:
  11975. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11976. */
  11977. static readonly FALLOFF_DEFAULT: number;
  11978. /**
  11979. * Falloff Physical: light is falling off following the inverse squared distance law.
  11980. */
  11981. static readonly FALLOFF_PHYSICAL: number;
  11982. /**
  11983. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11984. * to enhance interoperability with other engines.
  11985. */
  11986. static readonly FALLOFF_GLTF: number;
  11987. /**
  11988. * Falloff Standard: light is falling off like in the standard material
  11989. * to enhance interoperability with other materials.
  11990. */
  11991. static readonly FALLOFF_STANDARD: number;
  11992. /**
  11993. * If every light affecting the material is in this lightmapMode,
  11994. * material.lightmapTexture adds or multiplies
  11995. * (depends on material.useLightmapAsShadowmap)
  11996. * after every other light calculations.
  11997. */
  11998. static readonly LIGHTMAP_DEFAULT: number;
  11999. /**
  12000. * material.lightmapTexture as only diffuse lighting from this light
  12001. * adds only specular lighting from this light
  12002. * adds dynamic shadows
  12003. */
  12004. static readonly LIGHTMAP_SPECULAR: number;
  12005. /**
  12006. * material.lightmapTexture as only lighting
  12007. * no light calculation from this light
  12008. * only adds dynamic shadows from this light
  12009. */
  12010. static readonly LIGHTMAP_SHADOWSONLY: number;
  12011. /**
  12012. * Each light type uses the default quantity according to its type:
  12013. * point/spot lights use luminous intensity
  12014. * directional lights use illuminance
  12015. */
  12016. static readonly INTENSITYMODE_AUTOMATIC: number;
  12017. /**
  12018. * lumen (lm)
  12019. */
  12020. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  12021. /**
  12022. * candela (lm/sr)
  12023. */
  12024. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  12025. /**
  12026. * lux (lm/m^2)
  12027. */
  12028. static readonly INTENSITYMODE_ILLUMINANCE: number;
  12029. /**
  12030. * nit (cd/m^2)
  12031. */
  12032. static readonly INTENSITYMODE_LUMINANCE: number;
  12033. /**
  12034. * Light type const id of the point light.
  12035. */
  12036. static readonly LIGHTTYPEID_POINTLIGHT: number;
  12037. /**
  12038. * Light type const id of the directional light.
  12039. */
  12040. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  12041. /**
  12042. * Light type const id of the spot light.
  12043. */
  12044. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  12045. /**
  12046. * Light type const id of the hemispheric light.
  12047. */
  12048. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  12049. /**
  12050. * Diffuse gives the basic color to an object.
  12051. */
  12052. diffuse: Color3;
  12053. /**
  12054. * Specular produces a highlight color on an object.
  12055. * Note: This is note affecting PBR materials.
  12056. */
  12057. specular: Color3;
  12058. /**
  12059. * Defines the falloff type for this light. This lets overrriding how punctual light are
  12060. * falling off base on range or angle.
  12061. * This can be set to any values in Light.FALLOFF_x.
  12062. *
  12063. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  12064. * other types of materials.
  12065. */
  12066. falloffType: number;
  12067. /**
  12068. * Strength of the light.
  12069. * Note: By default it is define in the framework own unit.
  12070. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  12071. */
  12072. intensity: number;
  12073. private _range;
  12074. protected _inverseSquaredRange: number;
  12075. /**
  12076. * Defines how far from the source the light is impacting in scene units.
  12077. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12078. */
  12079. /**
  12080. * Defines how far from the source the light is impacting in scene units.
  12081. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12082. */
  12083. range: number;
  12084. /**
  12085. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  12086. * of light.
  12087. */
  12088. private _photometricScale;
  12089. private _intensityMode;
  12090. /**
  12091. * Gets the photometric scale used to interpret the intensity.
  12092. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12093. */
  12094. /**
  12095. * Sets the photometric scale used to interpret the intensity.
  12096. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12097. */
  12098. intensityMode: number;
  12099. private _radius;
  12100. /**
  12101. * Gets the light radius used by PBR Materials to simulate soft area lights.
  12102. */
  12103. /**
  12104. * sets the light radius used by PBR Materials to simulate soft area lights.
  12105. */
  12106. radius: number;
  12107. private _renderPriority;
  12108. /**
  12109. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  12110. * exceeding the number allowed of the materials.
  12111. */
  12112. renderPriority: number;
  12113. private _shadowEnabled;
  12114. /**
  12115. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12116. * the current shadow generator.
  12117. */
  12118. /**
  12119. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12120. * the current shadow generator.
  12121. */
  12122. shadowEnabled: boolean;
  12123. private _includedOnlyMeshes;
  12124. /**
  12125. * Gets the only meshes impacted by this light.
  12126. */
  12127. /**
  12128. * Sets the only meshes impacted by this light.
  12129. */
  12130. includedOnlyMeshes: AbstractMesh[];
  12131. private _excludedMeshes;
  12132. /**
  12133. * Gets the meshes not impacted by this light.
  12134. */
  12135. /**
  12136. * Sets the meshes not impacted by this light.
  12137. */
  12138. excludedMeshes: AbstractMesh[];
  12139. private _excludeWithLayerMask;
  12140. /**
  12141. * Gets the layer id use to find what meshes are not impacted by the light.
  12142. * Inactive if 0
  12143. */
  12144. /**
  12145. * Sets the layer id use to find what meshes are not impacted by the light.
  12146. * Inactive if 0
  12147. */
  12148. excludeWithLayerMask: number;
  12149. private _includeOnlyWithLayerMask;
  12150. /**
  12151. * Gets the layer id use to find what meshes are impacted by the light.
  12152. * Inactive if 0
  12153. */
  12154. /**
  12155. * Sets the layer id use to find what meshes are impacted by the light.
  12156. * Inactive if 0
  12157. */
  12158. includeOnlyWithLayerMask: number;
  12159. private _lightmapMode;
  12160. /**
  12161. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12162. */
  12163. /**
  12164. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12165. */
  12166. lightmapMode: number;
  12167. private _parentedWorldMatrix;
  12168. /**
  12169. * Shadow generator associted to the light.
  12170. * @hidden Internal use only.
  12171. */
  12172. _shadowGenerator: Nullable<IShadowGenerator>;
  12173. /**
  12174. * @hidden Internal use only.
  12175. */
  12176. _excludedMeshesIds: string[];
  12177. /**
  12178. * @hidden Internal use only.
  12179. */
  12180. _includedOnlyMeshesIds: string[];
  12181. /**
  12182. * The current light unifom buffer.
  12183. * @hidden Internal use only.
  12184. */
  12185. _uniformBuffer: UniformBuffer;
  12186. /**
  12187. * Creates a Light object in the scene.
  12188. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12189. * @param name The firendly name of the light
  12190. * @param scene The scene the light belongs too
  12191. */
  12192. constructor(name: string, scene: Scene);
  12193. protected abstract _buildUniformLayout(): void;
  12194. /**
  12195. * Sets the passed Effect "effect" with the Light information.
  12196. * @param effect The effect to update
  12197. * @param lightIndex The index of the light in the effect to update
  12198. * @returns The light
  12199. */
  12200. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12201. /**
  12202. * @hidden internal use only.
  12203. */
  12204. abstract _getWorldMatrix(): Matrix;
  12205. /**
  12206. * Returns the string "Light".
  12207. * @returns the class name
  12208. */
  12209. getClassName(): string;
  12210. /**
  12211. * Converts the light information to a readable string for debug purpose.
  12212. * @param fullDetails Supports for multiple levels of logging within scene loading
  12213. * @returns the human readable light info
  12214. */
  12215. toString(fullDetails?: boolean): string;
  12216. /**
  12217. * Set the enabled state of this node.
  12218. * @param value - the new enabled state
  12219. */
  12220. setEnabled(value: boolean): void;
  12221. /**
  12222. * Returns the Light associated shadow generator if any.
  12223. * @return the associated shadow generator.
  12224. */
  12225. getShadowGenerator(): Nullable<IShadowGenerator>;
  12226. /**
  12227. * Returns a Vector3, the absolute light position in the World.
  12228. * @returns the world space position of the light
  12229. */
  12230. getAbsolutePosition(): Vector3;
  12231. /**
  12232. * Specifies if the light will affect the passed mesh.
  12233. * @param mesh The mesh to test against the light
  12234. * @return true the mesh is affected otherwise, false.
  12235. */
  12236. canAffectMesh(mesh: AbstractMesh): boolean;
  12237. /**
  12238. * Computes and Returns the light World matrix.
  12239. * @returns the world matrix
  12240. */
  12241. getWorldMatrix(): Matrix;
  12242. /**
  12243. * Sort function to order lights for rendering.
  12244. * @param a First Light object to compare to second.
  12245. * @param b Second Light object to compare first.
  12246. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12247. */
  12248. static CompareLightsPriority(a: Light, b: Light): number;
  12249. /**
  12250. * Releases resources associated with this node.
  12251. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12252. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12253. */
  12254. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12255. /**
  12256. * Returns the light type ID (integer).
  12257. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12258. */
  12259. getTypeID(): number;
  12260. /**
  12261. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12262. * @returns the scaled intensity in intensity mode unit
  12263. */
  12264. getScaledIntensity(): number;
  12265. /**
  12266. * Returns a new Light object, named "name", from the current one.
  12267. * @param name The name of the cloned light
  12268. * @returns the new created light
  12269. */
  12270. clone(name: string): Nullable<Light>;
  12271. /**
  12272. * Serializes the current light into a Serialization object.
  12273. * @returns the serialized object.
  12274. */
  12275. serialize(): any;
  12276. /**
  12277. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12278. * This new light is named "name" and added to the passed scene.
  12279. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12280. * @param name The friendly name of the light
  12281. * @param scene The scene the new light will belong to
  12282. * @returns the constructor function
  12283. */
  12284. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12285. /**
  12286. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12287. * @param parsedLight The JSON representation of the light
  12288. * @param scene The scene to create the parsed light in
  12289. * @returns the created light after parsing
  12290. */
  12291. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12292. private _hookArrayForExcluded;
  12293. private _hookArrayForIncludedOnly;
  12294. private _resyncMeshes;
  12295. /**
  12296. * Forces the meshes to update their light related information in their rendering used effects
  12297. * @hidden Internal Use Only
  12298. */
  12299. _markMeshesAsLightDirty(): void;
  12300. /**
  12301. * Recomputes the cached photometric scale if needed.
  12302. */
  12303. private _computePhotometricScale;
  12304. /**
  12305. * Returns the Photometric Scale according to the light type and intensity mode.
  12306. */
  12307. private _getPhotometricScale;
  12308. /**
  12309. * Reorder the light in the scene according to their defined priority.
  12310. * @hidden Internal Use Only
  12311. */
  12312. _reorderLightsInScene(): void;
  12313. /**
  12314. * Prepares the list of defines specific to the light type.
  12315. * @param defines the list of defines
  12316. * @param lightIndex defines the index of the light for the effect
  12317. */
  12318. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12319. }
  12320. }
  12321. declare module BABYLON {
  12322. /**
  12323. * A point light is a light defined by an unique point in world space.
  12324. * The light is emitted in every direction from this point.
  12325. * A good example of a point light is a standard light bulb.
  12326. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12327. */
  12328. class PointLight extends ShadowLight {
  12329. private _shadowAngle;
  12330. /**
  12331. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12332. * This specifies what angle the shadow will use to be created.
  12333. *
  12334. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12335. */
  12336. /**
  12337. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12338. * This specifies what angle the shadow will use to be created.
  12339. *
  12340. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12341. */
  12342. shadowAngle: number;
  12343. /**
  12344. * Gets the direction if it has been set.
  12345. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12346. */
  12347. /**
  12348. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12349. */
  12350. direction: Vector3;
  12351. /**
  12352. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  12353. * A PointLight emits the light in every direction.
  12354. * It can cast shadows.
  12355. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  12356. * ```javascript
  12357. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  12358. * ```
  12359. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12360. * @param name The light friendly name
  12361. * @param position The position of the point light in the scene
  12362. * @param scene The scene the lights belongs to
  12363. */
  12364. constructor(name: string, position: Vector3, scene: Scene);
  12365. /**
  12366. * Returns the string "PointLight"
  12367. * @returns the class name
  12368. */
  12369. getClassName(): string;
  12370. /**
  12371. * Returns the integer 0.
  12372. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12373. */
  12374. getTypeID(): number;
  12375. /**
  12376. * Specifies wether or not the shadowmap should be a cube texture.
  12377. * @returns true if the shadowmap needs to be a cube texture.
  12378. */
  12379. needCube(): boolean;
  12380. /**
  12381. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  12382. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12383. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12384. */
  12385. getShadowDirection(faceIndex?: number): Vector3;
  12386. /**
  12387. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  12388. * - fov = PI / 2
  12389. * - aspect ratio : 1.0
  12390. * - z-near and far equal to the active camera minZ and maxZ.
  12391. * Returns the PointLight.
  12392. */
  12393. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12394. protected _buildUniformLayout(): void;
  12395. /**
  12396. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  12397. * @param effect The effect to update
  12398. * @param lightIndex The index of the light in the effect to update
  12399. * @returns The point light
  12400. */
  12401. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  12402. /**
  12403. * Prepares the list of defines specific to the light type.
  12404. * @param defines the list of defines
  12405. * @param lightIndex defines the index of the light for the effect
  12406. */
  12407. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12408. }
  12409. }
  12410. declare module BABYLON {
  12411. /**
  12412. * Interface describing all the common properties and methods a shadow light needs to implement.
  12413. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  12414. * as well as binding the different shadow properties to the effects.
  12415. */
  12416. interface IShadowLight extends Light {
  12417. /**
  12418. * The light id in the scene (used in scene.findLighById for instance)
  12419. */
  12420. id: string;
  12421. /**
  12422. * The position the shdow will be casted from.
  12423. */
  12424. position: Vector3;
  12425. /**
  12426. * In 2d mode (needCube being false), the direction used to cast the shadow.
  12427. */
  12428. direction: Vector3;
  12429. /**
  12430. * The transformed position. Position of the light in world space taking parenting in account.
  12431. */
  12432. transformedPosition: Vector3;
  12433. /**
  12434. * The transformed direction. Direction of the light in world space taking parenting in account.
  12435. */
  12436. transformedDirection: Vector3;
  12437. /**
  12438. * The friendly name of the light in the scene.
  12439. */
  12440. name: string;
  12441. /**
  12442. * Defines the shadow projection clipping minimum z value.
  12443. */
  12444. shadowMinZ: number;
  12445. /**
  12446. * Defines the shadow projection clipping maximum z value.
  12447. */
  12448. shadowMaxZ: number;
  12449. /**
  12450. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12451. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12452. */
  12453. computeTransformedInformation(): boolean;
  12454. /**
  12455. * Gets the scene the light belongs to.
  12456. * @returns The scene
  12457. */
  12458. getScene(): Scene;
  12459. /**
  12460. * Callback defining a custom Projection Matrix Builder.
  12461. * This can be used to override the default projection matrix computation.
  12462. */
  12463. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12464. /**
  12465. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12466. * @param matrix The materix to updated with the projection information
  12467. * @param viewMatrix The transform matrix of the light
  12468. * @param renderList The list of mesh to render in the map
  12469. * @returns The current light
  12470. */
  12471. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12472. /**
  12473. * Gets the current depth scale used in ESM.
  12474. * @returns The scale
  12475. */
  12476. getDepthScale(): number;
  12477. /**
  12478. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12479. * @returns true if a cube texture needs to be use
  12480. */
  12481. needCube(): boolean;
  12482. /**
  12483. * Detects if the projection matrix requires to be recomputed this frame.
  12484. * @returns true if it requires to be recomputed otherwise, false.
  12485. */
  12486. needProjectionMatrixCompute(): boolean;
  12487. /**
  12488. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12489. */
  12490. forceProjectionMatrixCompute(): void;
  12491. /**
  12492. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12493. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12494. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12495. */
  12496. getShadowDirection(faceIndex?: number): Vector3;
  12497. /**
  12498. * Gets the minZ used for shadow according to both the scene and the light.
  12499. * @param activeCamera The camera we are returning the min for
  12500. * @returns the depth min z
  12501. */
  12502. getDepthMinZ(activeCamera: Camera): number;
  12503. /**
  12504. * Gets the maxZ used for shadow according to both the scene and the light.
  12505. * @param activeCamera The camera we are returning the max for
  12506. * @returns the depth max z
  12507. */
  12508. getDepthMaxZ(activeCamera: Camera): number;
  12509. }
  12510. /**
  12511. * Base implementation IShadowLight
  12512. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  12513. */
  12514. abstract class ShadowLight extends Light implements IShadowLight {
  12515. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12516. protected _position: Vector3;
  12517. protected _setPosition(value: Vector3): void;
  12518. /**
  12519. * Sets the position the shadow will be casted from. Also use as the light position for both
  12520. * point and spot lights.
  12521. */
  12522. /**
  12523. * Sets the position the shadow will be casted from. Also use as the light position for both
  12524. * point and spot lights.
  12525. */
  12526. position: Vector3;
  12527. protected _direction: Vector3;
  12528. protected _setDirection(value: Vector3): void;
  12529. /**
  12530. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  12531. * Also use as the light direction on spot and directional lights.
  12532. */
  12533. /**
  12534. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  12535. * Also use as the light direction on spot and directional lights.
  12536. */
  12537. direction: Vector3;
  12538. private _shadowMinZ;
  12539. /**
  12540. * Gets the shadow projection clipping minimum z value.
  12541. */
  12542. /**
  12543. * Sets the shadow projection clipping minimum z value.
  12544. */
  12545. shadowMinZ: number;
  12546. private _shadowMaxZ;
  12547. /**
  12548. * Sets the shadow projection clipping maximum z value.
  12549. */
  12550. /**
  12551. * Gets the shadow projection clipping maximum z value.
  12552. */
  12553. shadowMaxZ: number;
  12554. /**
  12555. * Callback defining a custom Projection Matrix Builder.
  12556. * This can be used to override the default projection matrix computation.
  12557. */
  12558. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12559. /**
  12560. * The transformed position. Position of the light in world space taking parenting in account.
  12561. */
  12562. transformedPosition: Vector3;
  12563. /**
  12564. * The transformed direction. Direction of the light in world space taking parenting in account.
  12565. */
  12566. transformedDirection: Vector3;
  12567. private _worldMatrix;
  12568. private _needProjectionMatrixCompute;
  12569. /**
  12570. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12571. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12572. */
  12573. computeTransformedInformation(): boolean;
  12574. /**
  12575. * Return the depth scale used for the shadow map.
  12576. * @returns the depth scale.
  12577. */
  12578. getDepthScale(): number;
  12579. /**
  12580. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12581. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12582. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12583. */
  12584. getShadowDirection(faceIndex?: number): Vector3;
  12585. /**
  12586. * Returns the ShadowLight absolute position in the World.
  12587. * @returns the position vector in world space
  12588. */
  12589. getAbsolutePosition(): Vector3;
  12590. /**
  12591. * Sets the ShadowLight direction toward the passed target.
  12592. * @param target The point tot target in local space
  12593. * @returns the updated ShadowLight direction
  12594. */
  12595. setDirectionToTarget(target: Vector3): Vector3;
  12596. /**
  12597. * Returns the light rotation in euler definition.
  12598. * @returns the x y z rotation in local space.
  12599. */
  12600. getRotation(): Vector3;
  12601. /**
  12602. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12603. * @returns true if a cube texture needs to be use
  12604. */
  12605. needCube(): boolean;
  12606. /**
  12607. * Detects if the projection matrix requires to be recomputed this frame.
  12608. * @returns true if it requires to be recomputed otherwise, false.
  12609. */
  12610. needProjectionMatrixCompute(): boolean;
  12611. /**
  12612. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12613. */
  12614. forceProjectionMatrixCompute(): void;
  12615. /**
  12616. * Get the world matrix of the sahdow lights.
  12617. * @hidden Internal Use Only
  12618. */
  12619. _getWorldMatrix(): Matrix;
  12620. /**
  12621. * Gets the minZ used for shadow according to both the scene and the light.
  12622. * @param activeCamera The camera we are returning the min for
  12623. * @returns the depth min z
  12624. */
  12625. getDepthMinZ(activeCamera: Camera): number;
  12626. /**
  12627. * Gets the maxZ used for shadow according to both the scene and the light.
  12628. * @param activeCamera The camera we are returning the max for
  12629. * @returns the depth max z
  12630. */
  12631. getDepthMaxZ(activeCamera: Camera): number;
  12632. /**
  12633. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12634. * @param matrix The materix to updated with the projection information
  12635. * @param viewMatrix The transform matrix of the light
  12636. * @param renderList The list of mesh to render in the map
  12637. * @returns The current light
  12638. */
  12639. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12640. }
  12641. }
  12642. declare module BABYLON {
  12643. /**
  12644. * A spot light is defined by a position, a direction, an angle, and an exponent.
  12645. * These values define a cone of light starting from the position, emitting toward the direction.
  12646. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  12647. * and the exponent defines the speed of the decay of the light with distance (reach).
  12648. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12649. */
  12650. class SpotLight extends ShadowLight {
  12651. private _angle;
  12652. private _innerAngle;
  12653. private _cosHalfAngle;
  12654. private _lightAngleScale;
  12655. private _lightAngleOffset;
  12656. /**
  12657. * Gets the cone angle of the spot light in Radians.
  12658. */
  12659. /**
  12660. * Sets the cone angle of the spot light in Radians.
  12661. */
  12662. angle: number;
  12663. /**
  12664. * Only used in gltf falloff mode, this defines the angle where
  12665. * the directional falloff will start before cutting at angle which could be seen
  12666. * as outer angle.
  12667. */
  12668. /**
  12669. * Only used in gltf falloff mode, this defines the angle where
  12670. * the directional falloff will start before cutting at angle which could be seen
  12671. * as outer angle.
  12672. */
  12673. innerAngle: number;
  12674. private _shadowAngleScale;
  12675. /**
  12676. * Allows scaling the angle of the light for shadow generation only.
  12677. */
  12678. /**
  12679. * Allows scaling the angle of the light for shadow generation only.
  12680. */
  12681. shadowAngleScale: number;
  12682. /**
  12683. * The light decay speed with the distance from the emission spot.
  12684. */
  12685. exponent: number;
  12686. private _projectionTextureMatrix;
  12687. /**
  12688. * Allows reading the projecton texture
  12689. */
  12690. readonly projectionTextureMatrix: Matrix;
  12691. protected _projectionTextureLightNear: number;
  12692. /**
  12693. * Gets the near clip of the Spotlight for texture projection.
  12694. */
  12695. /**
  12696. * Sets the near clip of the Spotlight for texture projection.
  12697. */
  12698. projectionTextureLightNear: number;
  12699. protected _projectionTextureLightFar: number;
  12700. /**
  12701. * Gets the far clip of the Spotlight for texture projection.
  12702. */
  12703. /**
  12704. * Sets the far clip of the Spotlight for texture projection.
  12705. */
  12706. projectionTextureLightFar: number;
  12707. protected _projectionTextureUpDirection: Vector3;
  12708. /**
  12709. * Gets the Up vector of the Spotlight for texture projection.
  12710. */
  12711. /**
  12712. * Sets the Up vector of the Spotlight for texture projection.
  12713. */
  12714. projectionTextureUpDirection: Vector3;
  12715. private _projectionTexture;
  12716. /**
  12717. * Gets the projection texture of the light.
  12718. */
  12719. /**
  12720. * Sets the projection texture of the light.
  12721. */
  12722. projectionTexture: Nullable<BaseTexture>;
  12723. private _projectionTextureViewLightDirty;
  12724. private _projectionTextureProjectionLightDirty;
  12725. private _projectionTextureDirty;
  12726. private _projectionTextureViewTargetVector;
  12727. private _projectionTextureViewLightMatrix;
  12728. private _projectionTextureProjectionLightMatrix;
  12729. private _projectionTextureScalingMatrix;
  12730. /**
  12731. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  12732. * It can cast shadows.
  12733. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12734. * @param name The light friendly name
  12735. * @param position The position of the spot light in the scene
  12736. * @param direction The direction of the light in the scene
  12737. * @param angle The cone angle of the light in Radians
  12738. * @param exponent The light decay speed with the distance from the emission spot
  12739. * @param scene The scene the lights belongs to
  12740. */
  12741. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  12742. /**
  12743. * Returns the string "SpotLight".
  12744. * @returns the class name
  12745. */
  12746. getClassName(): string;
  12747. /**
  12748. * Returns the integer 2.
  12749. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12750. */
  12751. getTypeID(): number;
  12752. /**
  12753. * Overrides the direction setter to recompute the projection texture view light Matrix.
  12754. */
  12755. protected _setDirection(value: Vector3): void;
  12756. /**
  12757. * Overrides the position setter to recompute the projection texture view light Matrix.
  12758. */
  12759. protected _setPosition(value: Vector3): void;
  12760. /**
  12761. * 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.
  12762. * Returns the SpotLight.
  12763. */
  12764. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12765. protected _computeProjectionTextureViewLightMatrix(): void;
  12766. protected _computeProjectionTextureProjectionLightMatrix(): void;
  12767. /**
  12768. * Main function for light texture projection matrix computing.
  12769. */
  12770. protected _computeProjectionTextureMatrix(): void;
  12771. protected _buildUniformLayout(): void;
  12772. private _computeAngleValues;
  12773. /**
  12774. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  12775. * @param effect The effect to update
  12776. * @param lightIndex The index of the light in the effect to update
  12777. * @returns The spot light
  12778. */
  12779. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  12780. /**
  12781. * Disposes the light and the associated resources.
  12782. */
  12783. dispose(): void;
  12784. /**
  12785. * Prepares the list of defines specific to the light type.
  12786. * @param defines the list of defines
  12787. * @param lightIndex defines the index of the light for the effect
  12788. */
  12789. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12790. }
  12791. }
  12792. declare module BABYLON {
  12793. interface ILoadingScreen {
  12794. displayLoadingUI: () => void;
  12795. hideLoadingUI: () => void;
  12796. loadingUIBackgroundColor: string;
  12797. loadingUIText: string;
  12798. }
  12799. class DefaultLoadingScreen implements ILoadingScreen {
  12800. private _renderingCanvas;
  12801. private _loadingText;
  12802. private _loadingDivBackgroundColor;
  12803. private _loadingDiv;
  12804. private _loadingTextDiv;
  12805. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  12806. displayLoadingUI(): void;
  12807. hideLoadingUI(): void;
  12808. loadingUIText: string;
  12809. loadingUIBackgroundColor: string;
  12810. private _resizeLoadingUI;
  12811. }
  12812. }
  12813. declare module BABYLON {
  12814. class SceneLoaderProgressEvent {
  12815. readonly lengthComputable: boolean;
  12816. readonly loaded: number;
  12817. readonly total: number;
  12818. constructor(lengthComputable: boolean, loaded: number, total: number);
  12819. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  12820. }
  12821. interface ISceneLoaderPluginExtensions {
  12822. [extension: string]: {
  12823. isBinary: boolean;
  12824. };
  12825. }
  12826. interface ISceneLoaderPluginFactory {
  12827. name: string;
  12828. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  12829. canDirectLoad?: (data: string) => boolean;
  12830. }
  12831. interface ISceneLoaderPlugin {
  12832. /**
  12833. * The friendly name of this plugin.
  12834. */
  12835. name: string;
  12836. /**
  12837. * The file extensions supported by this plugin.
  12838. */
  12839. extensions: string | ISceneLoaderPluginExtensions;
  12840. /**
  12841. * Import meshes into a scene.
  12842. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12843. * @param scene The scene to import into
  12844. * @param data The data to import
  12845. * @param rootUrl The root url for scene and resources
  12846. * @param meshes The meshes array to import into
  12847. * @param particleSystems The particle systems array to import into
  12848. * @param skeletons The skeletons array to import into
  12849. * @param onError The callback when import fails
  12850. * @returns True if successful or false otherwise
  12851. */
  12852. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  12853. /**
  12854. * Load into a scene.
  12855. * @param scene The scene to load into
  12856. * @param data The data to import
  12857. * @param rootUrl The root url for scene and resources
  12858. * @param onError The callback when import fails
  12859. * @returns true if successful or false otherwise
  12860. */
  12861. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  12862. /**
  12863. * The callback that returns true if the data can be directly loaded.
  12864. */
  12865. canDirectLoad?: (data: string) => boolean;
  12866. /**
  12867. * The callback that allows custom handling of the root url based on the response url.
  12868. */
  12869. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12870. /**
  12871. * Load into an asset container.
  12872. * @param scene The scene to load into
  12873. * @param data The data to import
  12874. * @param rootUrl The root url for scene and resources
  12875. * @param onError The callback when import fails
  12876. * @returns The loaded asset container
  12877. */
  12878. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  12879. }
  12880. interface ISceneLoaderPluginAsync {
  12881. /**
  12882. * The friendly name of this plugin.
  12883. */
  12884. name: string;
  12885. /**
  12886. * The file extensions supported by this plugin.
  12887. */
  12888. extensions: string | ISceneLoaderPluginExtensions;
  12889. /**
  12890. * Import meshes into a scene.
  12891. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12892. * @param scene The scene to import into
  12893. * @param data The data to import
  12894. * @param rootUrl The root url for scene and resources
  12895. * @param onProgress The callback when the load progresses
  12896. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  12897. */
  12898. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  12899. meshes: AbstractMesh[];
  12900. particleSystems: IParticleSystem[];
  12901. skeletons: Skeleton[];
  12902. animationGroups: AnimationGroup[];
  12903. }>;
  12904. /**
  12905. * Load into a scene.
  12906. * @param scene The scene to load into
  12907. * @param data The data to import
  12908. * @param rootUrl The root url for scene and resources
  12909. * @param onProgress The callback when the load progresses
  12910. * @returns Nothing
  12911. */
  12912. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  12913. /**
  12914. * The callback that returns true if the data can be directly loaded.
  12915. */
  12916. canDirectLoad?: (data: string) => boolean;
  12917. /**
  12918. * The callback that allows custom handling of the root url based on the response url.
  12919. */
  12920. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12921. /**
  12922. * Load into an asset container.
  12923. * @param scene The scene to load into
  12924. * @param data The data to import
  12925. * @param rootUrl The root url for scene and resources
  12926. * @param onProgress The callback when the load progresses
  12927. * @returns The loaded asset container
  12928. */
  12929. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  12930. }
  12931. class SceneLoader {
  12932. private static _ForceFullSceneLoadingForIncremental;
  12933. private static _ShowLoadingScreen;
  12934. private static _CleanBoneMatrixWeights;
  12935. static readonly NO_LOGGING: number;
  12936. static readonly MINIMAL_LOGGING: number;
  12937. static readonly SUMMARY_LOGGING: number;
  12938. static readonly DETAILED_LOGGING: number;
  12939. private static _loggingLevel;
  12940. static ForceFullSceneLoadingForIncremental: boolean;
  12941. static ShowLoadingScreen: boolean;
  12942. static loggingLevel: number;
  12943. static CleanBoneMatrixWeights: boolean;
  12944. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12945. private static _registeredPlugins;
  12946. private static _getDefaultPlugin;
  12947. private static _getPluginForExtension;
  12948. private static _getPluginForDirectLoad;
  12949. private static _getPluginForFilename;
  12950. private static _getDirectLoad;
  12951. private static _loadData;
  12952. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  12953. static IsPluginForExtensionAvailable(extension: string): boolean;
  12954. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  12955. /**
  12956. * Import meshes into a scene
  12957. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12958. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12959. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12960. * @param scene the instance of BABYLON.Scene to append to
  12961. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  12962. * @param onProgress a callback with a progress event for each file being loaded
  12963. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12964. * @param pluginExtension the extension used to determine the plugin
  12965. * @returns The loaded plugin
  12966. */
  12967. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: any, 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>;
  12968. /**
  12969. * Import meshes into a scene
  12970. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12971. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12972. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12973. * @param scene the instance of BABYLON.Scene to append to
  12974. * @param onProgress a callback with a progress event for each file being loaded
  12975. * @param pluginExtension the extension used to determine the plugin
  12976. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  12977. */
  12978. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  12979. meshes: AbstractMesh[];
  12980. particleSystems: IParticleSystem[];
  12981. skeletons: Skeleton[];
  12982. animationGroups: AnimationGroup[];
  12983. }>;
  12984. /**
  12985. * Load a scene
  12986. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12987. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  12988. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12989. * @param onSuccess a callback with the scene when import succeeds
  12990. * @param onProgress a callback with a progress event for each file being loaded
  12991. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12992. * @param pluginExtension the extension used to determine the plugin
  12993. * @returns The loaded plugin
  12994. */
  12995. static Load(rootUrl: string, sceneFilename: any, 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>;
  12996. /**
  12997. * Load a scene
  12998. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  12999. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  13000. * @param engine is the instance of BABYLON.Engine to use to create the scene
  13001. * @param onProgress a callback with a progress event for each file being loaded
  13002. * @param pluginExtension the extension used to determine the plugin
  13003. * @returns The loaded scene
  13004. */
  13005. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  13006. /**
  13007. * Append a scene
  13008. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  13009. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  13010. * @param scene is the instance of BABYLON.Scene to append to
  13011. * @param onSuccess a callback with the scene when import succeeds
  13012. * @param onProgress a callback with a progress event for each file being loaded
  13013. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13014. * @param pluginExtension the extension used to determine the plugin
  13015. * @returns The loaded plugin
  13016. */
  13017. static Append(rootUrl: string, sceneFilename?: any, 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>;
  13018. /**
  13019. * Append a scene
  13020. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  13021. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  13022. * @param scene is the instance of BABYLON.Scene to append to
  13023. * @param onProgress a callback with a progress event for each file being loaded
  13024. * @param pluginExtension the extension used to determine the plugin
  13025. * @returns The given scene
  13026. */
  13027. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  13028. /**
  13029. * Load a scene into an asset container
  13030. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  13031. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  13032. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  13033. * @param onSuccess a callback with the scene when import succeeds
  13034. * @param onProgress a callback with a progress event for each file being loaded
  13035. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13036. * @param pluginExtension the extension used to determine the plugin
  13037. * @returns The loaded plugin
  13038. */
  13039. static LoadAssetContainer(rootUrl: string, sceneFilename?: any, 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>;
  13040. /**
  13041. * Load a scene into an asset container
  13042. * @param rootUrl a string that defines the root url for scene and resources OR the concatenation of rootURL and filename (eg. http://example.com/test.glb)
  13043. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene (default: empty string)
  13044. * @param scene is the instance of BABYLON.Scene to append to
  13045. * @param onProgress a callback with a progress event for each file being loaded
  13046. * @param pluginExtension the extension used to determine the plugin
  13047. * @returns The loaded asset container
  13048. */
  13049. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  13050. }
  13051. }
  13052. declare module BABYLON {
  13053. /**
  13054. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  13055. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  13056. * 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;
  13057. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  13058. */
  13059. class ColorCurves {
  13060. private _dirty;
  13061. private _tempColor;
  13062. private _globalCurve;
  13063. private _highlightsCurve;
  13064. private _midtonesCurve;
  13065. private _shadowsCurve;
  13066. private _positiveCurve;
  13067. private _negativeCurve;
  13068. private _globalHue;
  13069. private _globalDensity;
  13070. private _globalSaturation;
  13071. private _globalExposure;
  13072. /**
  13073. * Gets the global Hue value.
  13074. * 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).
  13075. */
  13076. /**
  13077. * Sets the global Hue value.
  13078. * 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).
  13079. */
  13080. globalHue: number;
  13081. /**
  13082. * Gets the global Density value.
  13083. * 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.
  13084. * Values less than zero provide a filter of opposite hue.
  13085. */
  13086. /**
  13087. * Sets the global Density value.
  13088. * 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.
  13089. * Values less than zero provide a filter of opposite hue.
  13090. */
  13091. globalDensity: number;
  13092. /**
  13093. * Gets the global Saturation value.
  13094. * 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.
  13095. */
  13096. /**
  13097. * Sets the global Saturation value.
  13098. * 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.
  13099. */
  13100. globalSaturation: number;
  13101. /**
  13102. * Gets the global Exposure value.
  13103. * 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.
  13104. */
  13105. /**
  13106. * Sets the global Exposure value.
  13107. * 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.
  13108. */
  13109. globalExposure: number;
  13110. private _highlightsHue;
  13111. private _highlightsDensity;
  13112. private _highlightsSaturation;
  13113. private _highlightsExposure;
  13114. /**
  13115. * Gets the highlights Hue value.
  13116. * 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).
  13117. */
  13118. /**
  13119. * Sets the highlights Hue value.
  13120. * 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).
  13121. */
  13122. highlightsHue: number;
  13123. /**
  13124. * Gets the highlights Density value.
  13125. * 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.
  13126. * Values less than zero provide a filter of opposite hue.
  13127. */
  13128. /**
  13129. * Sets the highlights Density value.
  13130. * 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.
  13131. * Values less than zero provide a filter of opposite hue.
  13132. */
  13133. highlightsDensity: number;
  13134. /**
  13135. * Gets the highlights Saturation value.
  13136. * 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.
  13137. */
  13138. /**
  13139. * Sets the highlights Saturation value.
  13140. * 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.
  13141. */
  13142. highlightsSaturation: number;
  13143. /**
  13144. * Gets the highlights Exposure value.
  13145. * 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.
  13146. */
  13147. /**
  13148. * Sets the highlights Exposure value.
  13149. * 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.
  13150. */
  13151. highlightsExposure: number;
  13152. private _midtonesHue;
  13153. private _midtonesDensity;
  13154. private _midtonesSaturation;
  13155. private _midtonesExposure;
  13156. /**
  13157. * Gets the midtones Hue value.
  13158. * 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).
  13159. */
  13160. /**
  13161. * Sets the midtones Hue value.
  13162. * 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).
  13163. */
  13164. midtonesHue: number;
  13165. /**
  13166. * Gets the midtones Density value.
  13167. * 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.
  13168. * Values less than zero provide a filter of opposite hue.
  13169. */
  13170. /**
  13171. * Sets the midtones Density value.
  13172. * 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.
  13173. * Values less than zero provide a filter of opposite hue.
  13174. */
  13175. midtonesDensity: number;
  13176. /**
  13177. * Gets the midtones Saturation value.
  13178. * 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.
  13179. */
  13180. /**
  13181. * Sets the midtones Saturation value.
  13182. * 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.
  13183. */
  13184. midtonesSaturation: number;
  13185. /**
  13186. * Gets the midtones Exposure value.
  13187. * 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.
  13188. */
  13189. /**
  13190. * Sets the midtones Exposure value.
  13191. * 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.
  13192. */
  13193. midtonesExposure: number;
  13194. private _shadowsHue;
  13195. private _shadowsDensity;
  13196. private _shadowsSaturation;
  13197. private _shadowsExposure;
  13198. /**
  13199. * Gets the shadows Hue value.
  13200. * 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).
  13201. */
  13202. /**
  13203. * Sets the shadows Hue value.
  13204. * 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).
  13205. */
  13206. shadowsHue: number;
  13207. /**
  13208. * Gets the shadows Density value.
  13209. * 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.
  13210. * Values less than zero provide a filter of opposite hue.
  13211. */
  13212. /**
  13213. * Sets the shadows Density value.
  13214. * 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.
  13215. * Values less than zero provide a filter of opposite hue.
  13216. */
  13217. shadowsDensity: number;
  13218. /**
  13219. * Gets the shadows Saturation value.
  13220. * 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.
  13221. */
  13222. /**
  13223. * Sets the shadows Saturation value.
  13224. * 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.
  13225. */
  13226. shadowsSaturation: number;
  13227. /**
  13228. * Gets the shadows Exposure value.
  13229. * 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.
  13230. */
  13231. /**
  13232. * Sets the shadows Exposure value.
  13233. * 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.
  13234. */
  13235. shadowsExposure: number;
  13236. getClassName(): string;
  13237. /**
  13238. * Binds the color curves to the shader.
  13239. * @param colorCurves The color curve to bind
  13240. * @param effect The effect to bind to
  13241. */
  13242. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  13243. /**
  13244. * Prepare the list of uniforms associated with the ColorCurves effects.
  13245. * @param uniformsList The list of uniforms used in the effect
  13246. */
  13247. static PrepareUniforms(uniformsList: string[]): void;
  13248. /**
  13249. * Returns color grading data based on a hue, density, saturation and exposure value.
  13250. * @param filterHue The hue of the color filter.
  13251. * @param filterDensity The density of the color filter.
  13252. * @param saturation The saturation.
  13253. * @param exposure The exposure.
  13254. * @param result The result data container.
  13255. */
  13256. private getColorGradingDataToRef;
  13257. /**
  13258. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  13259. * @param value The input slider value in range [-100,100].
  13260. * @returns Adjusted value.
  13261. */
  13262. private static applyColorGradingSliderNonlinear;
  13263. /**
  13264. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  13265. * @param hue The hue (H) input.
  13266. * @param saturation The saturation (S) input.
  13267. * @param brightness The brightness (B) input.
  13268. * @result An RGBA color represented as Vector4.
  13269. */
  13270. private static fromHSBToRef;
  13271. /**
  13272. * Returns a value clamped between min and max
  13273. * @param value The value to clamp
  13274. * @param min The minimum of value
  13275. * @param max The maximum of value
  13276. * @returns The clamped value.
  13277. */
  13278. private static clamp;
  13279. /**
  13280. * Clones the current color curve instance.
  13281. * @return The cloned curves
  13282. */
  13283. clone(): ColorCurves;
  13284. /**
  13285. * Serializes the current color curve instance to a json representation.
  13286. * @return a JSON representation
  13287. */
  13288. serialize(): any;
  13289. /**
  13290. * Parses the color curve from a json representation.
  13291. * @param source the JSON source to parse
  13292. * @return The parsed curves
  13293. */
  13294. static Parse(source: any): ColorCurves;
  13295. }
  13296. }
  13297. declare module BABYLON {
  13298. /**
  13299. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13300. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13301. */
  13302. class EffectFallbacks {
  13303. private _defines;
  13304. private _currentRank;
  13305. private _maxRank;
  13306. private _mesh;
  13307. /**
  13308. * Removes the fallback from the bound mesh.
  13309. */
  13310. unBindMesh(): void;
  13311. /**
  13312. * Adds a fallback on the specified property.
  13313. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13314. * @param define The name of the define in the shader
  13315. */
  13316. addFallback(rank: number, define: string): void;
  13317. /**
  13318. * Sets the mesh to use CPU skinning when needing to fallback.
  13319. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13320. * @param mesh The mesh to use the fallbacks.
  13321. */
  13322. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13323. /**
  13324. * Checks to see if more fallbacks are still availible.
  13325. */
  13326. readonly isMoreFallbacks: boolean;
  13327. /**
  13328. * Removes the defines that shoould be removed when falling back.
  13329. * @param currentDefines defines the current define statements for the shader.
  13330. * @param effect defines the current effect we try to compile
  13331. * @returns The resulting defines with defines of the current rank removed.
  13332. */
  13333. reduce(currentDefines: string, effect: Effect): string;
  13334. }
  13335. /**
  13336. * Options to be used when creating an effect.
  13337. */
  13338. class EffectCreationOptions {
  13339. /**
  13340. * Atrributes that will be used in the shader.
  13341. */
  13342. attributes: string[];
  13343. /**
  13344. * Uniform varible names that will be set in the shader.
  13345. */
  13346. uniformsNames: string[];
  13347. /**
  13348. * Uniform buffer varible names that will be set in the shader.
  13349. */
  13350. uniformBuffersNames: string[];
  13351. /**
  13352. * Sampler texture variable names that will be set in the shader.
  13353. */
  13354. samplers: string[];
  13355. /**
  13356. * Define statements that will be set in the shader.
  13357. */
  13358. defines: any;
  13359. /**
  13360. * Possible fallbacks for this effect to improve performance when needed.
  13361. */
  13362. fallbacks: Nullable<EffectFallbacks>;
  13363. /**
  13364. * Callback that will be called when the shader is compiled.
  13365. */
  13366. onCompiled: Nullable<(effect: Effect) => void>;
  13367. /**
  13368. * Callback that will be called if an error occurs during shader compilation.
  13369. */
  13370. onError: Nullable<(effect: Effect, errors: string) => void>;
  13371. /**
  13372. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13373. */
  13374. indexParameters: any;
  13375. /**
  13376. * Max number of lights that can be used in the shader.
  13377. */
  13378. maxSimultaneousLights: number;
  13379. /**
  13380. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  13381. */
  13382. transformFeedbackVaryings: Nullable<string[]>;
  13383. }
  13384. /**
  13385. * Effect containing vertex and fragment shader that can be executed on an object.
  13386. */
  13387. class Effect {
  13388. /**
  13389. * Name of the effect.
  13390. */
  13391. name: any;
  13392. /**
  13393. * String container all the define statements that should be set on the shader.
  13394. */
  13395. defines: string;
  13396. /**
  13397. * Callback that will be called when the shader is compiled.
  13398. */
  13399. onCompiled: Nullable<(effect: Effect) => void>;
  13400. /**
  13401. * Callback that will be called if an error occurs during shader compilation.
  13402. */
  13403. onError: Nullable<(effect: Effect, errors: string) => void>;
  13404. /**
  13405. * Callback that will be called when effect is bound.
  13406. */
  13407. onBind: Nullable<(effect: Effect) => void>;
  13408. /**
  13409. * Unique ID of the effect.
  13410. */
  13411. uniqueId: number;
  13412. /**
  13413. * Observable that will be called when the shader is compiled.
  13414. */
  13415. onCompileObservable: Observable<Effect>;
  13416. /**
  13417. * Observable that will be called if an error occurs during shader compilation.
  13418. */
  13419. onErrorObservable: Observable<Effect>;
  13420. /** @hidden */
  13421. _onBindObservable: Nullable<Observable<Effect>>;
  13422. /**
  13423. * Observable that will be called when effect is bound.
  13424. */
  13425. readonly onBindObservable: Observable<Effect>;
  13426. /** @hidden */
  13427. _bonesComputationForcedToCPU: boolean;
  13428. private static _uniqueIdSeed;
  13429. private _engine;
  13430. private _uniformBuffersNames;
  13431. private _uniformsNames;
  13432. private _samplers;
  13433. private _isReady;
  13434. private _compilationError;
  13435. private _attributesNames;
  13436. private _attributes;
  13437. private _uniforms;
  13438. /**
  13439. * Key for the effect.
  13440. * @hidden
  13441. */
  13442. _key: string;
  13443. private _indexParameters;
  13444. private _fallbacks;
  13445. private _vertexSourceCode;
  13446. private _fragmentSourceCode;
  13447. private _vertexSourceCodeOverride;
  13448. private _fragmentSourceCodeOverride;
  13449. private _transformFeedbackVaryings;
  13450. /**
  13451. * Compiled shader to webGL program.
  13452. * @hidden
  13453. */
  13454. _program: WebGLProgram;
  13455. private _valueCache;
  13456. private static _baseCache;
  13457. /**
  13458. * Instantiates an effect.
  13459. * An effect can be used to create/manage/execute vertex and fragment shaders.
  13460. * @param baseName Name of the effect.
  13461. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  13462. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  13463. * @param samplers List of sampler variables that will be passed to the shader.
  13464. * @param engine Engine to be used to render the effect
  13465. * @param defines Define statements to be added to the shader.
  13466. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  13467. * @param onCompiled Callback that will be called when the shader is compiled.
  13468. * @param onError Callback that will be called if an error occurs during shader compilation.
  13469. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13470. */
  13471. 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);
  13472. /**
  13473. * Unique key for this effect
  13474. */
  13475. readonly key: string;
  13476. /**
  13477. * If the effect has been compiled and prepared.
  13478. * @returns if the effect is compiled and prepared.
  13479. */
  13480. isReady(): boolean;
  13481. /**
  13482. * The engine the effect was initialized with.
  13483. * @returns the engine.
  13484. */
  13485. getEngine(): Engine;
  13486. /**
  13487. * The compiled webGL program for the effect
  13488. * @returns the webGL program.
  13489. */
  13490. getProgram(): WebGLProgram;
  13491. /**
  13492. * The set of names of attribute variables for the shader.
  13493. * @returns An array of attribute names.
  13494. */
  13495. getAttributesNames(): string[];
  13496. /**
  13497. * Returns the attribute at the given index.
  13498. * @param index The index of the attribute.
  13499. * @returns The location of the attribute.
  13500. */
  13501. getAttributeLocation(index: number): number;
  13502. /**
  13503. * Returns the attribute based on the name of the variable.
  13504. * @param name of the attribute to look up.
  13505. * @returns the attribute location.
  13506. */
  13507. getAttributeLocationByName(name: string): number;
  13508. /**
  13509. * The number of attributes.
  13510. * @returns the numnber of attributes.
  13511. */
  13512. getAttributesCount(): number;
  13513. /**
  13514. * Gets the index of a uniform variable.
  13515. * @param uniformName of the uniform to look up.
  13516. * @returns the index.
  13517. */
  13518. getUniformIndex(uniformName: string): number;
  13519. /**
  13520. * Returns the attribute based on the name of the variable.
  13521. * @param uniformName of the uniform to look up.
  13522. * @returns the location of the uniform.
  13523. */
  13524. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  13525. /**
  13526. * Returns an array of sampler variable names
  13527. * @returns The array of sampler variable neames.
  13528. */
  13529. getSamplers(): string[];
  13530. /**
  13531. * The error from the last compilation.
  13532. * @returns the error string.
  13533. */
  13534. getCompilationError(): string;
  13535. /**
  13536. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  13537. * @param func The callback to be used.
  13538. */
  13539. executeWhenCompiled(func: (effect: Effect) => void): void;
  13540. /** @hidden */
  13541. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  13542. /** @hidden */
  13543. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  13544. /** @hidden */
  13545. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  13546. private _processShaderConversion;
  13547. private _processIncludes;
  13548. private _processPrecision;
  13549. /**
  13550. * Recompiles the webGL program
  13551. * @param vertexSourceCode The source code for the vertex shader.
  13552. * @param fragmentSourceCode The source code for the fragment shader.
  13553. * @param onCompiled Callback called when completed.
  13554. * @param onError Callback called on error.
  13555. * @hidden
  13556. */
  13557. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  13558. /**
  13559. * Gets the uniform locations of the the specified variable names
  13560. * @param names THe names of the variables to lookup.
  13561. * @returns Array of locations in the same order as variable names.
  13562. */
  13563. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  13564. /**
  13565. * Prepares the effect
  13566. * @hidden
  13567. */
  13568. _prepareEffect(): void;
  13569. /**
  13570. * Checks if the effect is supported. (Must be called after compilation)
  13571. */
  13572. readonly isSupported: boolean;
  13573. /**
  13574. * Binds a texture to the engine to be used as output of the shader.
  13575. * @param channel Name of the output variable.
  13576. * @param texture Texture to bind.
  13577. * @hidden
  13578. */
  13579. _bindTexture(channel: string, texture: InternalTexture): void;
  13580. /**
  13581. * Sets a texture on the engine to be used in the shader.
  13582. * @param channel Name of the sampler variable.
  13583. * @param texture Texture to set.
  13584. */
  13585. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  13586. /**
  13587. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  13588. * @param channel Name of the sampler variable.
  13589. * @param texture Texture to set.
  13590. */
  13591. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  13592. /**
  13593. * Sets an array of textures on the engine to be used in the shader.
  13594. * @param channel Name of the variable.
  13595. * @param textures Textures to set.
  13596. */
  13597. setTextureArray(channel: string, textures: BaseTexture[]): void;
  13598. /**
  13599. * 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)
  13600. * @param channel Name of the sampler variable.
  13601. * @param postProcess Post process to get the input texture from.
  13602. */
  13603. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  13604. /**
  13605. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  13606. * 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)
  13607. * @param channel Name of the sampler variable.
  13608. * @param postProcess Post process to get the output texture from.
  13609. */
  13610. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  13611. /** @hidden */
  13612. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  13613. /** @hidden */
  13614. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  13615. /** @hidden */
  13616. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  13617. /** @hidden */
  13618. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  13619. /**
  13620. * Binds a buffer to a uniform.
  13621. * @param buffer Buffer to bind.
  13622. * @param name Name of the uniform variable to bind to.
  13623. */
  13624. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  13625. /**
  13626. * Binds block to a uniform.
  13627. * @param blockName Name of the block to bind.
  13628. * @param index Index to bind.
  13629. */
  13630. bindUniformBlock(blockName: string, index: number): void;
  13631. /**
  13632. * Sets an interger value on a uniform variable.
  13633. * @param uniformName Name of the variable.
  13634. * @param value Value to be set.
  13635. * @returns this effect.
  13636. */
  13637. setInt(uniformName: string, value: number): Effect;
  13638. /**
  13639. * Sets an int array on a uniform variable.
  13640. * @param uniformName Name of the variable.
  13641. * @param array array to be set.
  13642. * @returns this effect.
  13643. */
  13644. setIntArray(uniformName: string, array: Int32Array): Effect;
  13645. /**
  13646. * 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)
  13647. * @param uniformName Name of the variable.
  13648. * @param array array to be set.
  13649. * @returns this effect.
  13650. */
  13651. setIntArray2(uniformName: string, array: Int32Array): Effect;
  13652. /**
  13653. * 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)
  13654. * @param uniformName Name of the variable.
  13655. * @param array array to be set.
  13656. * @returns this effect.
  13657. */
  13658. setIntArray3(uniformName: string, array: Int32Array): Effect;
  13659. /**
  13660. * 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)
  13661. * @param uniformName Name of the variable.
  13662. * @param array array to be set.
  13663. * @returns this effect.
  13664. */
  13665. setIntArray4(uniformName: string, array: Int32Array): Effect;
  13666. /**
  13667. * Sets an float array on a uniform variable.
  13668. * @param uniformName Name of the variable.
  13669. * @param array array to be set.
  13670. * @returns this effect.
  13671. */
  13672. setFloatArray(uniformName: string, array: Float32Array): Effect;
  13673. /**
  13674. * 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)
  13675. * @param uniformName Name of the variable.
  13676. * @param array array to be set.
  13677. * @returns this effect.
  13678. */
  13679. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  13680. /**
  13681. * 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)
  13682. * @param uniformName Name of the variable.
  13683. * @param array array to be set.
  13684. * @returns this effect.
  13685. */
  13686. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  13687. /**
  13688. * 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)
  13689. * @param uniformName Name of the variable.
  13690. * @param array array to be set.
  13691. * @returns this effect.
  13692. */
  13693. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  13694. /**
  13695. * Sets an array on a uniform variable.
  13696. * @param uniformName Name of the variable.
  13697. * @param array array to be set.
  13698. * @returns this effect.
  13699. */
  13700. setArray(uniformName: string, array: number[]): Effect;
  13701. /**
  13702. * 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)
  13703. * @param uniformName Name of the variable.
  13704. * @param array array to be set.
  13705. * @returns this effect.
  13706. */
  13707. setArray2(uniformName: string, array: number[]): Effect;
  13708. /**
  13709. * 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)
  13710. * @param uniformName Name of the variable.
  13711. * @param array array to be set.
  13712. * @returns this effect.
  13713. */
  13714. setArray3(uniformName: string, array: number[]): Effect;
  13715. /**
  13716. * 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)
  13717. * @param uniformName Name of the variable.
  13718. * @param array array to be set.
  13719. * @returns this effect.
  13720. */
  13721. setArray4(uniformName: string, array: number[]): Effect;
  13722. /**
  13723. * Sets matrices on a uniform variable.
  13724. * @param uniformName Name of the variable.
  13725. * @param matrices matrices to be set.
  13726. * @returns this effect.
  13727. */
  13728. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  13729. /**
  13730. * Sets matrix on a uniform variable.
  13731. * @param uniformName Name of the variable.
  13732. * @param matrix matrix to be set.
  13733. * @returns this effect.
  13734. */
  13735. setMatrix(uniformName: string, matrix: Matrix): Effect;
  13736. /**
  13737. * 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)
  13738. * @param uniformName Name of the variable.
  13739. * @param matrix matrix to be set.
  13740. * @returns this effect.
  13741. */
  13742. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  13743. /**
  13744. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  13745. * @param uniformName Name of the variable.
  13746. * @param matrix matrix to be set.
  13747. * @returns this effect.
  13748. */
  13749. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  13750. /**
  13751. * Sets a float on a uniform variable.
  13752. * @param uniformName Name of the variable.
  13753. * @param value value to be set.
  13754. * @returns this effect.
  13755. */
  13756. setFloat(uniformName: string, value: number): Effect;
  13757. /**
  13758. * Sets a boolean on a uniform variable.
  13759. * @param uniformName Name of the variable.
  13760. * @param bool value to be set.
  13761. * @returns this effect.
  13762. */
  13763. setBool(uniformName: string, bool: boolean): Effect;
  13764. /**
  13765. * Sets a Vector2 on a uniform variable.
  13766. * @param uniformName Name of the variable.
  13767. * @param vector2 vector2 to be set.
  13768. * @returns this effect.
  13769. */
  13770. setVector2(uniformName: string, vector2: Vector2): Effect;
  13771. /**
  13772. * Sets a float2 on a uniform variable.
  13773. * @param uniformName Name of the variable.
  13774. * @param x First float in float2.
  13775. * @param y Second float in float2.
  13776. * @returns this effect.
  13777. */
  13778. setFloat2(uniformName: string, x: number, y: number): Effect;
  13779. /**
  13780. * Sets a Vector3 on a uniform variable.
  13781. * @param uniformName Name of the variable.
  13782. * @param vector3 Value to be set.
  13783. * @returns this effect.
  13784. */
  13785. setVector3(uniformName: string, vector3: Vector3): Effect;
  13786. /**
  13787. * Sets a float3 on a uniform variable.
  13788. * @param uniformName Name of the variable.
  13789. * @param x First float in float3.
  13790. * @param y Second float in float3.
  13791. * @param z Third float in float3.
  13792. * @returns this effect.
  13793. */
  13794. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  13795. /**
  13796. * Sets a Vector4 on a uniform variable.
  13797. * @param uniformName Name of the variable.
  13798. * @param vector4 Value to be set.
  13799. * @returns this effect.
  13800. */
  13801. setVector4(uniformName: string, vector4: Vector4): Effect;
  13802. /**
  13803. * Sets a float4 on a uniform variable.
  13804. * @param uniformName Name of the variable.
  13805. * @param x First float in float4.
  13806. * @param y Second float in float4.
  13807. * @param z Third float in float4.
  13808. * @param w Fourth float in float4.
  13809. * @returns this effect.
  13810. */
  13811. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  13812. /**
  13813. * Sets a Color3 on a uniform variable.
  13814. * @param uniformName Name of the variable.
  13815. * @param color3 Value to be set.
  13816. * @returns this effect.
  13817. */
  13818. setColor3(uniformName: string, color3: Color3): Effect;
  13819. /**
  13820. * Sets a Color4 on a uniform variable.
  13821. * @param uniformName Name of the variable.
  13822. * @param color3 Value to be set.
  13823. * @param alpha Alpha value to be set.
  13824. * @returns this effect.
  13825. */
  13826. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  13827. /**
  13828. * Sets a Color4 on a uniform variable
  13829. * @param uniformName defines the name of the variable
  13830. * @param color4 defines the value to be set
  13831. * @returns this effect.
  13832. */
  13833. setDirectColor4(uniformName: string, color4: Color4): Effect;
  13834. /**
  13835. * This function will add a new shader to the shader store
  13836. * @param name the name of the shader
  13837. * @param pixelShader optional pixel shader content
  13838. * @param vertexShader optional vertex shader content
  13839. */
  13840. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  13841. /**
  13842. * Store of each shader (The can be looked up using effect.key)
  13843. */
  13844. static ShadersStore: {
  13845. [key: string]: string;
  13846. };
  13847. /**
  13848. * Store of each included file for a shader (The can be looked up using effect.key)
  13849. */
  13850. static IncludesShadersStore: {
  13851. [key: string]: string;
  13852. };
  13853. /**
  13854. * Resets the cache of effects.
  13855. */
  13856. static ResetCache(): void;
  13857. }
  13858. }
  13859. declare module BABYLON {
  13860. class FresnelParameters {
  13861. private _isEnabled;
  13862. isEnabled: boolean;
  13863. leftColor: Color3;
  13864. rightColor: Color3;
  13865. bias: number;
  13866. power: number;
  13867. clone(): FresnelParameters;
  13868. serialize(): any;
  13869. static Parse(parsedFresnelParameters: any): FresnelParameters;
  13870. }
  13871. }
  13872. declare module BABYLON {
  13873. /**
  13874. * Interface to follow in your material defines to integrate easily the
  13875. * Image proccessing functions.
  13876. * @hidden
  13877. */
  13878. interface IImageProcessingConfigurationDefines {
  13879. IMAGEPROCESSING: boolean;
  13880. VIGNETTE: boolean;
  13881. VIGNETTEBLENDMODEMULTIPLY: boolean;
  13882. VIGNETTEBLENDMODEOPAQUE: boolean;
  13883. TONEMAPPING: boolean;
  13884. TONEMAPPING_ACES: boolean;
  13885. CONTRAST: boolean;
  13886. EXPOSURE: boolean;
  13887. COLORCURVES: boolean;
  13888. COLORGRADING: boolean;
  13889. COLORGRADING3D: boolean;
  13890. SAMPLER3DGREENDEPTH: boolean;
  13891. SAMPLER3DBGRMAP: boolean;
  13892. IMAGEPROCESSINGPOSTPROCESS: boolean;
  13893. }
  13894. /**
  13895. * @hidden
  13896. */
  13897. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  13898. IMAGEPROCESSING: boolean;
  13899. VIGNETTE: boolean;
  13900. VIGNETTEBLENDMODEMULTIPLY: boolean;
  13901. VIGNETTEBLENDMODEOPAQUE: boolean;
  13902. TONEMAPPING: boolean;
  13903. TONEMAPPING_ACES: boolean;
  13904. CONTRAST: boolean;
  13905. COLORCURVES: boolean;
  13906. COLORGRADING: boolean;
  13907. COLORGRADING3D: boolean;
  13908. SAMPLER3DGREENDEPTH: boolean;
  13909. SAMPLER3DBGRMAP: boolean;
  13910. IMAGEPROCESSINGPOSTPROCESS: boolean;
  13911. EXPOSURE: boolean;
  13912. constructor();
  13913. }
  13914. /**
  13915. * This groups together the common properties used for image processing either in direct forward pass
  13916. * or through post processing effect depending on the use of the image processing pipeline in your scene
  13917. * or not.
  13918. */
  13919. class ImageProcessingConfiguration {
  13920. /**
  13921. * Default tone mapping applied in BabylonJS.
  13922. */
  13923. static readonly TONEMAPPING_STANDARD: number;
  13924. /**
  13925. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  13926. * to other engines rendering to increase portability.
  13927. */
  13928. static readonly TONEMAPPING_ACES: number;
  13929. /**
  13930. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  13931. */
  13932. colorCurves: Nullable<ColorCurves>;
  13933. private _colorCurvesEnabled;
  13934. /**
  13935. * Gets wether the color curves effect is enabled.
  13936. */
  13937. /**
  13938. * Sets wether the color curves effect is enabled.
  13939. */
  13940. colorCurvesEnabled: boolean;
  13941. /**
  13942. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  13943. */
  13944. colorGradingTexture: Nullable<BaseTexture>;
  13945. private _colorGradingEnabled;
  13946. /**
  13947. * Gets wether the color grading effect is enabled.
  13948. */
  13949. /**
  13950. * Sets wether the color grading effect is enabled.
  13951. */
  13952. colorGradingEnabled: boolean;
  13953. private _colorGradingWithGreenDepth;
  13954. /**
  13955. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  13956. */
  13957. /**
  13958. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  13959. */
  13960. colorGradingWithGreenDepth: boolean;
  13961. private _colorGradingBGR;
  13962. /**
  13963. * Gets wether the color grading texture contains BGR values.
  13964. */
  13965. /**
  13966. * Sets wether the color grading texture contains BGR values.
  13967. */
  13968. colorGradingBGR: boolean;
  13969. /** @hidden */
  13970. _exposure: number;
  13971. /**
  13972. * Gets the Exposure used in the effect.
  13973. */
  13974. /**
  13975. * Sets the Exposure used in the effect.
  13976. */
  13977. exposure: number;
  13978. private _toneMappingEnabled;
  13979. /**
  13980. * Gets wether the tone mapping effect is enabled.
  13981. */
  13982. /**
  13983. * Sets wether the tone mapping effect is enabled.
  13984. */
  13985. toneMappingEnabled: boolean;
  13986. private _toneMappingType;
  13987. /**
  13988. * Gets the type of tone mapping effect.
  13989. */
  13990. /**
  13991. * Sets the type of tone mapping effect used in BabylonJS.
  13992. */
  13993. toneMappingType: number;
  13994. protected _contrast: number;
  13995. /**
  13996. * Gets the contrast used in the effect.
  13997. */
  13998. /**
  13999. * Sets the contrast used in the effect.
  14000. */
  14001. contrast: number;
  14002. /**
  14003. * Vignette stretch size.
  14004. */
  14005. vignetteStretch: number;
  14006. /**
  14007. * Vignette centre X Offset.
  14008. */
  14009. vignetteCentreX: number;
  14010. /**
  14011. * Vignette centre Y Offset.
  14012. */
  14013. vignetteCentreY: number;
  14014. /**
  14015. * Vignette weight or intensity of the vignette effect.
  14016. */
  14017. vignetteWeight: number;
  14018. /**
  14019. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  14020. * if vignetteEnabled is set to true.
  14021. */
  14022. vignetteColor: Color4;
  14023. /**
  14024. * Camera field of view used by the Vignette effect.
  14025. */
  14026. vignetteCameraFov: number;
  14027. private _vignetteBlendMode;
  14028. /**
  14029. * Gets the vignette blend mode allowing different kind of effect.
  14030. */
  14031. /**
  14032. * Sets the vignette blend mode allowing different kind of effect.
  14033. */
  14034. vignetteBlendMode: number;
  14035. private _vignetteEnabled;
  14036. /**
  14037. * Gets wether the vignette effect is enabled.
  14038. */
  14039. /**
  14040. * Sets wether the vignette effect is enabled.
  14041. */
  14042. vignetteEnabled: boolean;
  14043. private _applyByPostProcess;
  14044. /**
  14045. * Gets wether the image processing is applied through a post process or not.
  14046. */
  14047. /**
  14048. * Sets wether the image processing is applied through a post process or not.
  14049. */
  14050. applyByPostProcess: boolean;
  14051. private _isEnabled;
  14052. /**
  14053. * Gets wether the image processing is enabled or not.
  14054. */
  14055. /**
  14056. * Sets wether the image processing is enabled or not.
  14057. */
  14058. isEnabled: boolean;
  14059. /**
  14060. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  14061. */
  14062. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  14063. /**
  14064. * Method called each time the image processing information changes requires to recompile the effect.
  14065. */
  14066. protected _updateParameters(): void;
  14067. getClassName(): string;
  14068. /**
  14069. * Prepare the list of uniforms associated with the Image Processing effects.
  14070. * @param uniformsList The list of uniforms used in the effect
  14071. * @param defines the list of defines currently in use
  14072. */
  14073. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  14074. /**
  14075. * Prepare the list of samplers associated with the Image Processing effects.
  14076. * @param uniformsList The list of uniforms used in the effect
  14077. * @param defines the list of defines currently in use
  14078. */
  14079. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  14080. /**
  14081. * Prepare the list of defines associated to the shader.
  14082. * @param defines the list of defines to complete
  14083. */
  14084. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  14085. /**
  14086. * Returns true if all the image processing information are ready.
  14087. */
  14088. isReady(): boolean;
  14089. /**
  14090. * Binds the image processing to the shader.
  14091. * @param effect The effect to bind to
  14092. */
  14093. bind(effect: Effect, aspectRatio?: number): void;
  14094. /**
  14095. * Clones the current image processing instance.
  14096. * @return The cloned image processing
  14097. */
  14098. clone(): ImageProcessingConfiguration;
  14099. /**
  14100. * Serializes the current image processing instance to a json representation.
  14101. * @return a JSON representation
  14102. */
  14103. serialize(): any;
  14104. /**
  14105. * Parses the image processing from a json representation.
  14106. * @param source the JSON source to parse
  14107. * @return The parsed image processing
  14108. */
  14109. static Parse(source: any): ImageProcessingConfiguration;
  14110. private static _VIGNETTEMODE_MULTIPLY;
  14111. private static _VIGNETTEMODE_OPAQUE;
  14112. /**
  14113. * Used to apply the vignette as a mix with the pixel color.
  14114. */
  14115. static readonly VIGNETTEMODE_MULTIPLY: number;
  14116. /**
  14117. * Used to apply the vignette as a replacement of the pixel color.
  14118. */
  14119. static readonly VIGNETTEMODE_OPAQUE: number;
  14120. }
  14121. }
  14122. declare module BABYLON {
  14123. /**
  14124. * Manages the defines for the Material
  14125. */
  14126. class MaterialDefines {
  14127. private _keys;
  14128. private _isDirty;
  14129. /** @hidden */
  14130. _renderId: number;
  14131. /** @hidden */
  14132. _areLightsDirty: boolean;
  14133. /** @hidden */
  14134. _areAttributesDirty: boolean;
  14135. /** @hidden */
  14136. _areTexturesDirty: boolean;
  14137. /** @hidden */
  14138. _areFresnelDirty: boolean;
  14139. /** @hidden */
  14140. _areMiscDirty: boolean;
  14141. /** @hidden */
  14142. _areImageProcessingDirty: boolean;
  14143. /** @hidden */
  14144. _normals: boolean;
  14145. /** @hidden */
  14146. _uvs: boolean;
  14147. /** @hidden */
  14148. _needNormals: boolean;
  14149. /** @hidden */
  14150. _needUVs: boolean;
  14151. /**
  14152. * Specifies if the material needs to be re-calculated
  14153. */
  14154. readonly isDirty: boolean;
  14155. /**
  14156. * Marks the material to indicate that it has been re-calculated
  14157. */
  14158. markAsProcessed(): void;
  14159. /**
  14160. * Marks the material to indicate that it needs to be re-calculated
  14161. */
  14162. markAsUnprocessed(): void;
  14163. /**
  14164. * Marks the material to indicate all of its defines need to be re-calculated
  14165. */
  14166. markAllAsDirty(): void;
  14167. /**
  14168. * Marks the material to indicate that image processing needs to be re-calculated
  14169. */
  14170. markAsImageProcessingDirty(): void;
  14171. /**
  14172. * Marks the material to indicate the lights need to be re-calculated
  14173. */
  14174. markAsLightDirty(): void;
  14175. /**
  14176. * Marks the attribute state as changed
  14177. */
  14178. markAsAttributesDirty(): void;
  14179. /**
  14180. * Marks the texture state as changed
  14181. */
  14182. markAsTexturesDirty(): void;
  14183. /**
  14184. * Marks the fresnel state as changed
  14185. */
  14186. markAsFresnelDirty(): void;
  14187. /**
  14188. * Marks the misc state as changed
  14189. */
  14190. markAsMiscDirty(): void;
  14191. /**
  14192. * Rebuilds the material defines
  14193. */
  14194. rebuild(): void;
  14195. /**
  14196. * Specifies if two material defines are equal
  14197. * @param other - A material define instance to compare to
  14198. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  14199. */
  14200. isEqual(other: MaterialDefines): boolean;
  14201. /**
  14202. * Clones this instance's defines to another instance
  14203. * @param other - material defines to clone values to
  14204. */
  14205. cloneTo(other: MaterialDefines): void;
  14206. /**
  14207. * Resets the material define values
  14208. */
  14209. reset(): void;
  14210. /**
  14211. * Converts the material define values to a string
  14212. * @returns - String of material define information
  14213. */
  14214. toString(): string;
  14215. }
  14216. /**
  14217. * Base class for the main features of a material in Babylon.js
  14218. */
  14219. class Material implements IAnimatable {
  14220. private static _TriangleFillMode;
  14221. private static _WireFrameFillMode;
  14222. private static _PointFillMode;
  14223. private static _PointListDrawMode;
  14224. private static _LineListDrawMode;
  14225. private static _LineLoopDrawMode;
  14226. private static _LineStripDrawMode;
  14227. private static _TriangleStripDrawMode;
  14228. private static _TriangleFanDrawMode;
  14229. /**
  14230. * Returns the triangle fill mode
  14231. */
  14232. static readonly TriangleFillMode: number;
  14233. /**
  14234. * Returns the wireframe mode
  14235. */
  14236. static readonly WireFrameFillMode: number;
  14237. /**
  14238. * Returns the point fill mode
  14239. */
  14240. static readonly PointFillMode: number;
  14241. /**
  14242. * Returns the point list draw mode
  14243. */
  14244. static readonly PointListDrawMode: number;
  14245. /**
  14246. * Returns the line list draw mode
  14247. */
  14248. static readonly LineListDrawMode: number;
  14249. /**
  14250. * Returns the line loop draw mode
  14251. */
  14252. static readonly LineLoopDrawMode: number;
  14253. /**
  14254. * Returns the line strip draw mode
  14255. */
  14256. static readonly LineStripDrawMode: number;
  14257. /**
  14258. * Returns the triangle strip draw mode
  14259. */
  14260. static readonly TriangleStripDrawMode: number;
  14261. /**
  14262. * Returns the triangle fan draw mode
  14263. */
  14264. static readonly TriangleFanDrawMode: number;
  14265. /**
  14266. * Stores the clock-wise side orientation
  14267. */
  14268. private static _ClockWiseSideOrientation;
  14269. /**
  14270. * Stores the counter clock-wise side orientation
  14271. */
  14272. private static _CounterClockWiseSideOrientation;
  14273. /**
  14274. * Returns the clock-wise side orientation
  14275. */
  14276. static readonly ClockWiseSideOrientation: number;
  14277. /**
  14278. * Returns the counter clock-wise side orientation
  14279. */
  14280. static readonly CounterClockWiseSideOrientation: number;
  14281. /**
  14282. * The dirty texture flag value
  14283. */
  14284. private static _TextureDirtyFlag;
  14285. /**
  14286. * The dirty light flag value
  14287. */
  14288. private static _LightDirtyFlag;
  14289. /**
  14290. * The dirty fresnel flag value
  14291. */
  14292. private static _FresnelDirtyFlag;
  14293. /**
  14294. * The dirty attribute flag value
  14295. */
  14296. private static _AttributesDirtyFlag;
  14297. /**
  14298. * The dirty misc flag value
  14299. */
  14300. private static _MiscDirtyFlag;
  14301. /**
  14302. * Returns the dirty texture flag value
  14303. */
  14304. static readonly TextureDirtyFlag: number;
  14305. /**
  14306. * Returns the dirty light flag value
  14307. */
  14308. static readonly LightDirtyFlag: number;
  14309. /**
  14310. * Returns the dirty fresnel flag value
  14311. */
  14312. static readonly FresnelDirtyFlag: number;
  14313. /**
  14314. * Returns the dirty attributes flag value
  14315. */
  14316. static readonly AttributesDirtyFlag: number;
  14317. /**
  14318. * Returns the dirty misc flag value
  14319. */
  14320. static readonly MiscDirtyFlag: number;
  14321. /**
  14322. * The ID of the material
  14323. */
  14324. id: string;
  14325. /**
  14326. * Gets or sets the unique id of the material
  14327. */
  14328. uniqueId: number;
  14329. /**
  14330. * The name of the material
  14331. */
  14332. name: string;
  14333. /**
  14334. * Specifies if the ready state should be checked on each call
  14335. */
  14336. checkReadyOnEveryCall: boolean;
  14337. /**
  14338. * Specifies if the ready state should be checked once
  14339. */
  14340. checkReadyOnlyOnce: boolean;
  14341. /**
  14342. * The state of the material
  14343. */
  14344. state: string;
  14345. /**
  14346. * The alpha value of the material
  14347. */
  14348. protected _alpha: number;
  14349. /**
  14350. * Sets the alpha value of the material
  14351. */
  14352. /**
  14353. * Gets the alpha value of the material
  14354. */
  14355. alpha: number;
  14356. /**
  14357. * Specifies if back face culling is enabled
  14358. */
  14359. protected _backFaceCulling: boolean;
  14360. /**
  14361. * Sets the back-face culling state
  14362. */
  14363. /**
  14364. * Gets the back-face culling state
  14365. */
  14366. backFaceCulling: boolean;
  14367. /**
  14368. * Stores the value for side orientation
  14369. */
  14370. sideOrientation: number;
  14371. /**
  14372. * Callback triggered when the material is compiled
  14373. */
  14374. onCompiled: (effect: Effect) => void;
  14375. /**
  14376. * Callback triggered when an error occurs
  14377. */
  14378. onError: (effect: Effect, errors: string) => void;
  14379. /**
  14380. * Callback triggered to get the render target textures
  14381. */
  14382. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  14383. /**
  14384. * Specifies if the material should be serialized
  14385. */
  14386. doNotSerialize: boolean;
  14387. /**
  14388. * Specifies if the effect should be stored on sub meshes
  14389. */
  14390. storeEffectOnSubMeshes: boolean;
  14391. /**
  14392. * Stores the animations for the material
  14393. */
  14394. animations: Array<Animation>;
  14395. /**
  14396. * An event triggered when the material is disposed
  14397. */
  14398. onDisposeObservable: Observable<Material>;
  14399. /**
  14400. * An observer which watches for dispose events
  14401. */
  14402. private _onDisposeObserver;
  14403. private _onUnBindObservable;
  14404. /**
  14405. * Called during a dispose event
  14406. */
  14407. onDispose: () => void;
  14408. private _onBindObservable;
  14409. /**
  14410. * An event triggered when the material is bound
  14411. */
  14412. readonly onBindObservable: Observable<AbstractMesh>;
  14413. /**
  14414. * An observer which watches for bind events
  14415. */
  14416. private _onBindObserver;
  14417. /**
  14418. * Called during a bind event
  14419. */
  14420. onBind: (Mesh: AbstractMesh) => void;
  14421. /**
  14422. * An event triggered when the material is unbound
  14423. */
  14424. readonly onUnBindObservable: Observable<Material>;
  14425. /**
  14426. * Stores the value of the alpha mode
  14427. */
  14428. private _alphaMode;
  14429. /**
  14430. * Sets the value of the alpha mode.
  14431. *
  14432. * | Value | Type | Description |
  14433. * | --- | --- | --- |
  14434. * | 0 | ALPHA_DISABLE | |
  14435. * | 1 | ALPHA_ADD | |
  14436. * | 2 | ALPHA_COMBINE | |
  14437. * | 3 | ALPHA_SUBTRACT | |
  14438. * | 4 | ALPHA_MULTIPLY | |
  14439. * | 5 | ALPHA_MAXIMIZED | |
  14440. * | 6 | ALPHA_ONEONE | |
  14441. * | 7 | ALPHA_PREMULTIPLIED | |
  14442. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  14443. * | 9 | ALPHA_INTERPOLATE | |
  14444. * | 10 | ALPHA_SCREENMODE | |
  14445. *
  14446. */
  14447. /**
  14448. * Gets the value of the alpha mode
  14449. */
  14450. alphaMode: number;
  14451. /**
  14452. * Stores the state of the need depth pre-pass value
  14453. */
  14454. private _needDepthPrePass;
  14455. /**
  14456. * Sets the need depth pre-pass value
  14457. */
  14458. /**
  14459. * Gets the depth pre-pass value
  14460. */
  14461. needDepthPrePass: boolean;
  14462. /**
  14463. * Specifies if depth writing should be disabled
  14464. */
  14465. disableDepthWrite: boolean;
  14466. /**
  14467. * Specifies if depth writing should be forced
  14468. */
  14469. forceDepthWrite: boolean;
  14470. /**
  14471. * Specifies if there should be a separate pass for culling
  14472. */
  14473. separateCullingPass: boolean;
  14474. /**
  14475. * Stores the state specifing if fog should be enabled
  14476. */
  14477. private _fogEnabled;
  14478. /**
  14479. * Sets the state for enabling fog
  14480. */
  14481. /**
  14482. * Gets the value of the fog enabled state
  14483. */
  14484. fogEnabled: boolean;
  14485. /**
  14486. * Stores the size of points
  14487. */
  14488. pointSize: number;
  14489. /**
  14490. * Stores the z offset value
  14491. */
  14492. zOffset: number;
  14493. /**
  14494. * Gets a value specifying if wireframe mode is enabled
  14495. */
  14496. /**
  14497. * Sets the state of wireframe mode
  14498. */
  14499. wireframe: boolean;
  14500. /**
  14501. * Gets the value specifying if point clouds are enabled
  14502. */
  14503. /**
  14504. * Sets the state of point cloud mode
  14505. */
  14506. pointsCloud: boolean;
  14507. /**
  14508. * Gets the material fill mode
  14509. */
  14510. /**
  14511. * Sets the material fill mode
  14512. */
  14513. fillMode: number;
  14514. /**
  14515. * @hidden
  14516. * Stores the effects for the material
  14517. */
  14518. _effect: Nullable<Effect>;
  14519. /**
  14520. * @hidden
  14521. * Specifies if the material was previously ready
  14522. */
  14523. _wasPreviouslyReady: boolean;
  14524. /**
  14525. * Specifies if uniform buffers should be used
  14526. */
  14527. private _useUBO;
  14528. /**
  14529. * Stores a reference to the scene
  14530. */
  14531. private _scene;
  14532. /**
  14533. * Stores the fill mode state
  14534. */
  14535. private _fillMode;
  14536. /**
  14537. * Specifies if the depth write state should be cached
  14538. */
  14539. private _cachedDepthWriteState;
  14540. /**
  14541. * Stores the uniform buffer
  14542. */
  14543. protected _uniformBuffer: UniformBuffer;
  14544. /**
  14545. * Creates a material instance
  14546. * @param name defines the name of the material
  14547. * @param scene defines the scene to reference
  14548. * @param doNotAdd specifies if the material should be added to the scene
  14549. */
  14550. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  14551. /**
  14552. * Returns a string representation of the current material
  14553. * @param fullDetails defines a boolean indicating which levels of logging is desired
  14554. * @returns a string with material information
  14555. */
  14556. toString(fullDetails?: boolean): string;
  14557. /**
  14558. * Gets the class name of the material
  14559. * @returns a string with the class name of the material
  14560. */
  14561. getClassName(): string;
  14562. /**
  14563. * Specifies if updates for the material been locked
  14564. */
  14565. readonly isFrozen: boolean;
  14566. /**
  14567. * Locks updates for the material
  14568. */
  14569. freeze(): void;
  14570. /**
  14571. * Unlocks updates for the material
  14572. */
  14573. unfreeze(): void;
  14574. /**
  14575. * Specifies if the material is ready to be used
  14576. * @param mesh defines the mesh to check
  14577. * @param useInstances specifies if instances should be used
  14578. * @returns a boolean indicating if the material is ready to be used
  14579. */
  14580. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14581. /**
  14582. * Specifies that the submesh is ready to be used
  14583. * @param mesh defines the mesh to check
  14584. * @param subMesh defines which submesh to check
  14585. * @param useInstances specifies that instances should be used
  14586. * @returns a boolean indicating that the submesh is ready or not
  14587. */
  14588. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14589. /**
  14590. * Returns the material effect
  14591. * @returns the effect associated with the material
  14592. */
  14593. getEffect(): Nullable<Effect>;
  14594. /**
  14595. * Returns the current scene
  14596. * @returns a Scene
  14597. */
  14598. getScene(): Scene;
  14599. /**
  14600. * Specifies if the material will require alpha blending
  14601. * @returns a boolean specifying if alpha blending is needed
  14602. */
  14603. needAlphaBlending(): boolean;
  14604. /**
  14605. * Specifies if the mesh will require alpha blending
  14606. * @param mesh defines the mesh to check
  14607. * @returns a boolean specifying if alpha blending is needed for the mesh
  14608. */
  14609. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  14610. /**
  14611. * Specifies if this material should be rendered in alpha test mode
  14612. * @returns a boolean specifying if an alpha test is needed.
  14613. */
  14614. needAlphaTesting(): boolean;
  14615. /**
  14616. * Gets the texture used for the alpha test
  14617. * @returns the texture to use for alpha testing
  14618. */
  14619. getAlphaTestTexture(): Nullable<BaseTexture>;
  14620. /**
  14621. * Marks the material to indicate that it needs to be re-calculated
  14622. */
  14623. markDirty(): void;
  14624. /** @hidden */
  14625. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  14626. /**
  14627. * Binds the material to the mesh
  14628. * @param world defines the world transformation matrix
  14629. * @param mesh defines the mesh to bind the material to
  14630. */
  14631. bind(world: Matrix, mesh?: Mesh): void;
  14632. /**
  14633. * Binds the submesh to the material
  14634. * @param world defines the world transformation matrix
  14635. * @param mesh defines the mesh containing the submesh
  14636. * @param subMesh defines the submesh to bind the material to
  14637. */
  14638. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14639. /**
  14640. * Binds the world matrix to the material
  14641. * @param world defines the world transformation matrix
  14642. */
  14643. bindOnlyWorldMatrix(world: Matrix): void;
  14644. /**
  14645. * Binds the scene's uniform buffer to the effect.
  14646. * @param effect defines the effect to bind to the scene uniform buffer
  14647. * @param sceneUbo defines the uniform buffer storing scene data
  14648. */
  14649. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  14650. /**
  14651. * Binds the view matrix to the effect
  14652. * @param effect defines the effect to bind the view matrix to
  14653. */
  14654. bindView(effect: Effect): void;
  14655. /**
  14656. * Binds the view projection matrix to the effect
  14657. * @param effect defines the effect to bind the view projection matrix to
  14658. */
  14659. bindViewProjection(effect: Effect): void;
  14660. /**
  14661. * Specifies if material alpha testing should be turned on for the mesh
  14662. * @param mesh defines the mesh to check
  14663. */
  14664. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  14665. /**
  14666. * Processes to execute after binding the material to a mesh
  14667. * @param mesh defines the rendered mesh
  14668. */
  14669. protected _afterBind(mesh?: Mesh): void;
  14670. /**
  14671. * Unbinds the material from the mesh
  14672. */
  14673. unbind(): void;
  14674. /**
  14675. * Gets the active textures from the material
  14676. * @returns an array of textures
  14677. */
  14678. getActiveTextures(): BaseTexture[];
  14679. /**
  14680. * Specifies if the material uses a texture
  14681. * @param texture defines the texture to check against the material
  14682. * @returns a boolean specifying if the material uses the texture
  14683. */
  14684. hasTexture(texture: BaseTexture): boolean;
  14685. /**
  14686. * Makes a duplicate of the material, and gives it a new name
  14687. * @param name defines the new name for the duplicated material
  14688. * @returns the cloned material
  14689. */
  14690. clone(name: string): Nullable<Material>;
  14691. /**
  14692. * Gets the meshes bound to the material
  14693. * @returns an array of meshes bound to the material
  14694. */
  14695. getBindedMeshes(): AbstractMesh[];
  14696. /**
  14697. * Force shader compilation
  14698. * @param mesh defines the mesh associated with this material
  14699. * @param onCompiled defines a function to execute once the material is compiled
  14700. * @param options defines the options to configure the compilation
  14701. */
  14702. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  14703. clipPlane: boolean;
  14704. }>): void;
  14705. /**
  14706. * Force shader compilation
  14707. * @param mesh defines the mesh that will use this material
  14708. * @param options defines additional options for compiling the shaders
  14709. * @returns a promise that resolves when the compilation completes
  14710. */
  14711. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  14712. clipPlane: boolean;
  14713. }>): Promise<void>;
  14714. /**
  14715. * Marks a define in the material to indicate that it needs to be re-computed
  14716. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  14717. */
  14718. markAsDirty(flag: number): void;
  14719. /**
  14720. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  14721. * @param func defines a function which checks material defines against the submeshes
  14722. */
  14723. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  14724. /**
  14725. * Indicates that image processing needs to be re-calculated for all submeshes
  14726. */
  14727. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  14728. /**
  14729. * Indicates that textures need to be re-calculated for all submeshes
  14730. */
  14731. protected _markAllSubMeshesAsTexturesDirty(): void;
  14732. /**
  14733. * Indicates that fresnel needs to be re-calculated for all submeshes
  14734. */
  14735. protected _markAllSubMeshesAsFresnelDirty(): void;
  14736. /**
  14737. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  14738. */
  14739. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  14740. /**
  14741. * Indicates that lights need to be re-calculated for all submeshes
  14742. */
  14743. protected _markAllSubMeshesAsLightsDirty(): void;
  14744. /**
  14745. * Indicates that attributes need to be re-calculated for all submeshes
  14746. */
  14747. protected _markAllSubMeshesAsAttributesDirty(): void;
  14748. /**
  14749. * Indicates that misc needs to be re-calculated for all submeshes
  14750. */
  14751. protected _markAllSubMeshesAsMiscDirty(): void;
  14752. /**
  14753. * Indicates that textures and misc need to be re-calculated for all submeshes
  14754. */
  14755. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  14756. /**
  14757. * Disposes the material
  14758. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  14759. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  14760. */
  14761. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14762. /**
  14763. * Serializes this material
  14764. * @returns the serialized material object
  14765. */
  14766. serialize(): any;
  14767. /**
  14768. * Creates a MultiMaterial from parsed MultiMaterial data.
  14769. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  14770. * @param scene defines the hosting scene
  14771. * @returns a new MultiMaterial
  14772. */
  14773. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  14774. /**
  14775. * Creates a material from parsed material data
  14776. * @param parsedMaterial defines parsed material data
  14777. * @param scene defines the hosting scene
  14778. * @param rootUrl defines the root URL to use to load textures
  14779. * @returns a new material
  14780. */
  14781. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  14782. }
  14783. }
  14784. declare module BABYLON {
  14785. /**
  14786. * "Static Class" containing the most commonly used helper while dealing with material for
  14787. * rendering purpose.
  14788. *
  14789. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  14790. *
  14791. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14792. */
  14793. class MaterialHelper {
  14794. /**
  14795. * Bind the current view position to an effect.
  14796. * @param effect The effect to be bound
  14797. * @param scene The scene the eyes position is used from
  14798. */
  14799. static BindEyePosition(effect: Effect, scene: Scene): void;
  14800. /**
  14801. * Helps preparing the defines values about the UVs in used in the effect.
  14802. * UVs are shared as much as we can accross chanels in the shaders.
  14803. * @param texture The texture we are preparing the UVs for
  14804. * @param defines The defines to update
  14805. * @param key The chanel key "diffuse", "specular"... used in the shader
  14806. */
  14807. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  14808. /**
  14809. * Binds a texture matrix value to its corrsponding uniform
  14810. * @param texture The texture to bind the matrix for
  14811. * @param uniformBuffer The uniform buffer receivin the data
  14812. * @param key The chanel key "diffuse", "specular"... used in the shader
  14813. */
  14814. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  14815. /**
  14816. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  14817. * @param mesh defines the current mesh
  14818. * @param scene defines the current scene
  14819. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  14820. * @param pointsCloud defines if point cloud rendering has to be turned on
  14821. * @param fogEnabled defines if fog has to be turned on
  14822. * @param alphaTest defines if alpha testing has to be turned on
  14823. * @param defines defines the current list of defines
  14824. */
  14825. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  14826. /**
  14827. * Helper used to prepare the list of defines associated with frame values for shader compilation
  14828. * @param scene defines the current scene
  14829. * @param engine defines the current engine
  14830. * @param defines specifies the list of active defines
  14831. * @param useInstances defines if instances have to be turned on
  14832. * @param useClipPlane defines if clip plane have to be turned on
  14833. */
  14834. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  14835. /**
  14836. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  14837. * @param mesh The mesh containing the geometry data we will draw
  14838. * @param defines The defines to update
  14839. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  14840. * @param useBones Precise whether bones should be used or not (override mesh info)
  14841. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  14842. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  14843. * @returns false if defines are considered not dirty and have not been checked
  14844. */
  14845. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  14846. /**
  14847. * Prepares the defines related to the light information passed in parameter
  14848. * @param scene The scene we are intending to draw
  14849. * @param mesh The mesh the effect is compiling for
  14850. * @param defines The defines to update
  14851. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  14852. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  14853. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  14854. * @returns true if normals will be required for the rest of the effect
  14855. */
  14856. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  14857. /**
  14858. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  14859. * that won t be acctive due to defines being turned off.
  14860. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  14861. * @param samplersList The samplers list
  14862. * @param defines The defines helping in the list generation
  14863. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  14864. */
  14865. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  14866. /**
  14867. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  14868. * @param defines The defines to update while falling back
  14869. * @param fallbacks The authorized effect fallbacks
  14870. * @param maxSimultaneousLights The maximum number of lights allowed
  14871. * @param rank the current rank of the Effect
  14872. * @returns The newly affected rank
  14873. */
  14874. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  14875. /**
  14876. * Prepares the list of attributes required for morph targets according to the effect defines.
  14877. * @param attribs The current list of supported attribs
  14878. * @param mesh The mesh to prepare the morph targets attributes for
  14879. * @param defines The current Defines of the effect
  14880. */
  14881. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  14882. /**
  14883. * Prepares the list of attributes required for bones according to the effect defines.
  14884. * @param attribs The current list of supported attribs
  14885. * @param mesh The mesh to prepare the bones attributes for
  14886. * @param defines The current Defines of the effect
  14887. * @param fallbacks The current efffect fallback strategy
  14888. */
  14889. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  14890. /**
  14891. * Prepares the list of attributes required for instances according to the effect defines.
  14892. * @param attribs The current list of supported attribs
  14893. * @param defines The current Defines of the effect
  14894. */
  14895. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  14896. /**
  14897. * Binds the light shadow information to the effect for the given mesh.
  14898. * @param light The light containing the generator
  14899. * @param scene The scene the lights belongs to
  14900. * @param mesh The mesh we are binding the information to render
  14901. * @param lightIndex The light index in the effect used to render the mesh
  14902. * @param effect The effect we are binding the data to
  14903. */
  14904. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  14905. /**
  14906. * Binds the light information to the effect.
  14907. * @param light The light containing the generator
  14908. * @param effect The effect we are binding the data to
  14909. * @param lightIndex The light index in the effect used to render
  14910. */
  14911. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  14912. /**
  14913. * Binds the lights information from the scene to the effect for the given mesh.
  14914. * @param scene The scene the lights belongs to
  14915. * @param mesh The mesh we are binding the information to render
  14916. * @param effect The effect we are binding the data to
  14917. * @param defines The generated defines for the effect
  14918. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  14919. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  14920. */
  14921. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  14922. /**
  14923. * Binds the fog information from the scene to the effect for the given mesh.
  14924. * @param scene The scene the lights belongs to
  14925. * @param mesh The mesh we are binding the information to render
  14926. * @param effect The effect we are binding the data to
  14927. */
  14928. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  14929. /**
  14930. * Binds the bones information from the mesh to the effect.
  14931. * @param mesh The mesh we are binding the information to render
  14932. * @param effect The effect we are binding the data to
  14933. */
  14934. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  14935. /**
  14936. * Binds the morph targets information from the mesh to the effect.
  14937. * @param abstractMesh The mesh we are binding the information to render
  14938. * @param effect The effect we are binding the data to
  14939. */
  14940. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  14941. /**
  14942. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  14943. * @param defines The generated defines used in the effect
  14944. * @param effect The effect we are binding the data to
  14945. * @param scene The scene we are willing to render with logarithmic scale for
  14946. */
  14947. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  14948. /**
  14949. * Binds the clip plane information from the scene to the effect.
  14950. * @param scene The scene the clip plane information are extracted from
  14951. * @param effect The effect we are binding the data to
  14952. */
  14953. static BindClipPlane(effect: Effect, scene: Scene): void;
  14954. }
  14955. }
  14956. declare module BABYLON {
  14957. class MultiMaterial extends Material {
  14958. private _subMaterials;
  14959. subMaterials: Nullable<Material>[];
  14960. constructor(name: string, scene: Scene);
  14961. private _hookArray;
  14962. getSubMaterial(index: number): Nullable<Material>;
  14963. getActiveTextures(): BaseTexture[];
  14964. getClassName(): string;
  14965. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14966. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  14967. serialize(): any;
  14968. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14969. }
  14970. }
  14971. declare module BABYLON {
  14972. class PushMaterial extends Material {
  14973. protected _activeEffect: Effect;
  14974. protected _normalMatrix: Matrix;
  14975. constructor(name: string, scene: Scene);
  14976. getEffect(): Effect;
  14977. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14978. /**
  14979. * Binds the given world matrix to the active effect
  14980. *
  14981. * @param world the matrix to bind
  14982. */
  14983. bindOnlyWorldMatrix(world: Matrix): void;
  14984. /**
  14985. * Binds the given normal matrix to the active effect
  14986. *
  14987. * @param normalMatrix the matrix to bind
  14988. */
  14989. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  14990. bind(world: Matrix, mesh?: Mesh): void;
  14991. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  14992. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  14993. }
  14994. }
  14995. declare module BABYLON {
  14996. class ShaderMaterial extends Material {
  14997. private _shaderPath;
  14998. private _options;
  14999. private _textures;
  15000. private _textureArrays;
  15001. private _floats;
  15002. private _ints;
  15003. private _floatsArrays;
  15004. private _colors3;
  15005. private _colors3Arrays;
  15006. private _colors4;
  15007. private _vectors2;
  15008. private _vectors3;
  15009. private _vectors4;
  15010. private _matrices;
  15011. private _matrices3x3;
  15012. private _matrices2x2;
  15013. private _vectors2Arrays;
  15014. private _vectors3Arrays;
  15015. private _cachedWorldViewMatrix;
  15016. private _renderId;
  15017. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  15018. getClassName(): string;
  15019. needAlphaBlending(): boolean;
  15020. needAlphaTesting(): boolean;
  15021. private _checkUniform;
  15022. setTexture(name: string, texture: Texture): ShaderMaterial;
  15023. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15024. setFloat(name: string, value: number): ShaderMaterial;
  15025. setInt(name: string, value: number): ShaderMaterial;
  15026. setFloats(name: string, value: number[]): ShaderMaterial;
  15027. setColor3(name: string, value: Color3): ShaderMaterial;
  15028. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15029. setColor4(name: string, value: Color4): ShaderMaterial;
  15030. setVector2(name: string, value: Vector2): ShaderMaterial;
  15031. setVector3(name: string, value: Vector3): ShaderMaterial;
  15032. setVector4(name: string, value: Vector4): ShaderMaterial;
  15033. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15034. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15035. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15036. setArray2(name: string, value: number[]): ShaderMaterial;
  15037. setArray3(name: string, value: number[]): ShaderMaterial;
  15038. private _checkCache;
  15039. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15040. bindOnlyWorldMatrix(world: Matrix): void;
  15041. bind(world: Matrix, mesh?: Mesh): void;
  15042. getActiveTextures(): BaseTexture[];
  15043. hasTexture(texture: BaseTexture): boolean;
  15044. clone(name: string): ShaderMaterial;
  15045. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  15046. serialize(): any;
  15047. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15048. }
  15049. }
  15050. declare module BABYLON {
  15051. /** @hidden */
  15052. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  15053. MAINUV1: boolean;
  15054. MAINUV2: boolean;
  15055. DIFFUSE: boolean;
  15056. DIFFUSEDIRECTUV: number;
  15057. AMBIENT: boolean;
  15058. AMBIENTDIRECTUV: number;
  15059. OPACITY: boolean;
  15060. OPACITYDIRECTUV: number;
  15061. OPACITYRGB: boolean;
  15062. REFLECTION: boolean;
  15063. EMISSIVE: boolean;
  15064. EMISSIVEDIRECTUV: number;
  15065. SPECULAR: boolean;
  15066. SPECULARDIRECTUV: number;
  15067. BUMP: boolean;
  15068. BUMPDIRECTUV: number;
  15069. PARALLAX: boolean;
  15070. PARALLAXOCCLUSION: boolean;
  15071. SPECULAROVERALPHA: boolean;
  15072. CLIPPLANE: boolean;
  15073. ALPHATEST: boolean;
  15074. DEPTHPREPASS: boolean;
  15075. ALPHAFROMDIFFUSE: boolean;
  15076. POINTSIZE: boolean;
  15077. FOG: boolean;
  15078. SPECULARTERM: boolean;
  15079. DIFFUSEFRESNEL: boolean;
  15080. OPACITYFRESNEL: boolean;
  15081. REFLECTIONFRESNEL: boolean;
  15082. REFRACTIONFRESNEL: boolean;
  15083. EMISSIVEFRESNEL: boolean;
  15084. FRESNEL: boolean;
  15085. NORMAL: boolean;
  15086. UV1: boolean;
  15087. UV2: boolean;
  15088. VERTEXCOLOR: boolean;
  15089. VERTEXALPHA: boolean;
  15090. NUM_BONE_INFLUENCERS: number;
  15091. BonesPerMesh: number;
  15092. INSTANCES: boolean;
  15093. GLOSSINESS: boolean;
  15094. ROUGHNESS: boolean;
  15095. EMISSIVEASILLUMINATION: boolean;
  15096. LINKEMISSIVEWITHDIFFUSE: boolean;
  15097. REFLECTIONFRESNELFROMSPECULAR: boolean;
  15098. LIGHTMAP: boolean;
  15099. LIGHTMAPDIRECTUV: number;
  15100. OBJECTSPACE_NORMALMAP: boolean;
  15101. USELIGHTMAPASSHADOWMAP: boolean;
  15102. REFLECTIONMAP_3D: boolean;
  15103. REFLECTIONMAP_SPHERICAL: boolean;
  15104. REFLECTIONMAP_PLANAR: boolean;
  15105. REFLECTIONMAP_CUBIC: boolean;
  15106. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  15107. REFLECTIONMAP_PROJECTION: boolean;
  15108. REFLECTIONMAP_SKYBOX: boolean;
  15109. REFLECTIONMAP_EXPLICIT: boolean;
  15110. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  15111. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  15112. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  15113. INVERTCUBICMAP: boolean;
  15114. LOGARITHMICDEPTH: boolean;
  15115. REFRACTION: boolean;
  15116. REFRACTIONMAP_3D: boolean;
  15117. REFLECTIONOVERALPHA: boolean;
  15118. TWOSIDEDLIGHTING: boolean;
  15119. SHADOWFLOAT: boolean;
  15120. MORPHTARGETS: boolean;
  15121. MORPHTARGETS_NORMAL: boolean;
  15122. MORPHTARGETS_TANGENT: boolean;
  15123. NUM_MORPH_INFLUENCERS: number;
  15124. NONUNIFORMSCALING: boolean;
  15125. PREMULTIPLYALPHA: boolean;
  15126. IMAGEPROCESSING: boolean;
  15127. VIGNETTE: boolean;
  15128. VIGNETTEBLENDMODEMULTIPLY: boolean;
  15129. VIGNETTEBLENDMODEOPAQUE: boolean;
  15130. TONEMAPPING: boolean;
  15131. TONEMAPPING_ACES: boolean;
  15132. CONTRAST: boolean;
  15133. COLORCURVES: boolean;
  15134. COLORGRADING: boolean;
  15135. COLORGRADING3D: boolean;
  15136. SAMPLER3DGREENDEPTH: boolean;
  15137. SAMPLER3DBGRMAP: boolean;
  15138. IMAGEPROCESSINGPOSTPROCESS: boolean;
  15139. /**
  15140. * If the reflection texture on this material is in linear color space
  15141. * @hidden
  15142. */
  15143. IS_REFLECTION_LINEAR: boolean;
  15144. /**
  15145. * If the refraction texture on this material is in linear color space
  15146. * @hidden
  15147. */
  15148. IS_REFRACTION_LINEAR: boolean;
  15149. EXPOSURE: boolean;
  15150. constructor();
  15151. setReflectionMode(modeToEnable: string): void;
  15152. }
  15153. class StandardMaterial extends PushMaterial {
  15154. private _diffuseTexture;
  15155. diffuseTexture: Nullable<BaseTexture>;
  15156. private _ambientTexture;
  15157. ambientTexture: Nullable<BaseTexture>;
  15158. private _opacityTexture;
  15159. opacityTexture: Nullable<BaseTexture>;
  15160. private _reflectionTexture;
  15161. reflectionTexture: Nullable<BaseTexture>;
  15162. private _emissiveTexture;
  15163. emissiveTexture: Nullable<BaseTexture>;
  15164. private _specularTexture;
  15165. specularTexture: Nullable<BaseTexture>;
  15166. private _bumpTexture;
  15167. bumpTexture: Nullable<BaseTexture>;
  15168. private _lightmapTexture;
  15169. lightmapTexture: Nullable<BaseTexture>;
  15170. private _refractionTexture;
  15171. refractionTexture: Nullable<BaseTexture>;
  15172. ambientColor: Color3;
  15173. diffuseColor: Color3;
  15174. specularColor: Color3;
  15175. emissiveColor: Color3;
  15176. specularPower: number;
  15177. private _useAlphaFromDiffuseTexture;
  15178. useAlphaFromDiffuseTexture: boolean;
  15179. private _useEmissiveAsIllumination;
  15180. useEmissiveAsIllumination: boolean;
  15181. private _linkEmissiveWithDiffuse;
  15182. linkEmissiveWithDiffuse: boolean;
  15183. private _useSpecularOverAlpha;
  15184. useSpecularOverAlpha: boolean;
  15185. private _useReflectionOverAlpha;
  15186. useReflectionOverAlpha: boolean;
  15187. private _disableLighting;
  15188. disableLighting: boolean;
  15189. private _useObjectSpaceNormalMap;
  15190. /**
  15191. * Allows using an object space normal map (instead of tangent space).
  15192. */
  15193. useObjectSpaceNormalMap: boolean;
  15194. private _useParallax;
  15195. useParallax: boolean;
  15196. private _useParallaxOcclusion;
  15197. useParallaxOcclusion: boolean;
  15198. parallaxScaleBias: number;
  15199. private _roughness;
  15200. roughness: number;
  15201. indexOfRefraction: number;
  15202. invertRefractionY: boolean;
  15203. /**
  15204. * Defines the alpha limits in alpha test mode
  15205. */
  15206. alphaCutOff: number;
  15207. private _useLightmapAsShadowmap;
  15208. useLightmapAsShadowmap: boolean;
  15209. private _diffuseFresnelParameters;
  15210. diffuseFresnelParameters: FresnelParameters;
  15211. private _opacityFresnelParameters;
  15212. opacityFresnelParameters: FresnelParameters;
  15213. private _reflectionFresnelParameters;
  15214. reflectionFresnelParameters: FresnelParameters;
  15215. private _refractionFresnelParameters;
  15216. refractionFresnelParameters: FresnelParameters;
  15217. private _emissiveFresnelParameters;
  15218. emissiveFresnelParameters: FresnelParameters;
  15219. private _useReflectionFresnelFromSpecular;
  15220. useReflectionFresnelFromSpecular: boolean;
  15221. private _useGlossinessFromSpecularMapAlpha;
  15222. useGlossinessFromSpecularMapAlpha: boolean;
  15223. private _maxSimultaneousLights;
  15224. maxSimultaneousLights: number;
  15225. /**
  15226. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  15227. */
  15228. private _invertNormalMapX;
  15229. invertNormalMapX: boolean;
  15230. /**
  15231. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  15232. */
  15233. private _invertNormalMapY;
  15234. invertNormalMapY: boolean;
  15235. /**
  15236. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  15237. */
  15238. private _twoSidedLighting;
  15239. twoSidedLighting: boolean;
  15240. /**
  15241. * Default configuration related to image processing available in the standard Material.
  15242. */
  15243. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15244. /**
  15245. * Gets the image processing configuration used either in this material.
  15246. */
  15247. /**
  15248. * Sets the Default image processing configuration used either in the this material.
  15249. *
  15250. * If sets to null, the scene one is in use.
  15251. */
  15252. imageProcessingConfiguration: ImageProcessingConfiguration;
  15253. /**
  15254. * Keep track of the image processing observer to allow dispose and replace.
  15255. */
  15256. private _imageProcessingObserver;
  15257. /**
  15258. * Attaches a new image processing configuration to the Standard Material.
  15259. * @param configuration
  15260. */
  15261. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15262. /**
  15263. * Gets wether the color curves effect is enabled.
  15264. */
  15265. /**
  15266. * Sets wether the color curves effect is enabled.
  15267. */
  15268. cameraColorCurvesEnabled: boolean;
  15269. /**
  15270. * Gets wether the color grading effect is enabled.
  15271. */
  15272. /**
  15273. * Gets wether the color grading effect is enabled.
  15274. */
  15275. cameraColorGradingEnabled: boolean;
  15276. /**
  15277. * Gets wether tonemapping is enabled or not.
  15278. */
  15279. /**
  15280. * Sets wether tonemapping is enabled or not
  15281. */
  15282. cameraToneMappingEnabled: boolean;
  15283. /**
  15284. * The camera exposure used on this material.
  15285. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  15286. * This corresponds to a photographic exposure.
  15287. */
  15288. /**
  15289. * The camera exposure used on this material.
  15290. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  15291. * This corresponds to a photographic exposure.
  15292. */
  15293. cameraExposure: number;
  15294. /**
  15295. * Gets The camera contrast used on this material.
  15296. */
  15297. /**
  15298. * Sets The camera contrast used on this material.
  15299. */
  15300. cameraContrast: number;
  15301. /**
  15302. * Gets the Color Grading 2D Lookup Texture.
  15303. */
  15304. /**
  15305. * Sets the Color Grading 2D Lookup Texture.
  15306. */
  15307. cameraColorGradingTexture: Nullable<BaseTexture>;
  15308. /**
  15309. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15310. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15311. * 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;
  15312. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15313. */
  15314. /**
  15315. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15316. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15317. * 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;
  15318. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15319. */
  15320. cameraColorCurves: Nullable<ColorCurves>;
  15321. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  15322. protected _renderTargets: SmartArray<RenderTargetTexture>;
  15323. protected _worldViewProjectionMatrix: Matrix;
  15324. protected _globalAmbientColor: Color3;
  15325. protected _useLogarithmicDepth: boolean;
  15326. constructor(name: string, scene: Scene);
  15327. getClassName(): string;
  15328. useLogarithmicDepth: boolean;
  15329. needAlphaBlending(): boolean;
  15330. needAlphaTesting(): boolean;
  15331. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  15332. getAlphaTestTexture(): Nullable<BaseTexture>;
  15333. /**
  15334. * Child classes can use it to update shaders
  15335. */
  15336. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  15337. buildUniformLayout(): void;
  15338. unbind(): void;
  15339. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  15340. getAnimatables(): IAnimatable[];
  15341. getActiveTextures(): BaseTexture[];
  15342. hasTexture(texture: BaseTexture): boolean;
  15343. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  15344. clone(name: string): StandardMaterial;
  15345. serialize(): any;
  15346. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  15347. static _DiffuseTextureEnabled: boolean;
  15348. static DiffuseTextureEnabled: boolean;
  15349. static _AmbientTextureEnabled: boolean;
  15350. static AmbientTextureEnabled: boolean;
  15351. static _OpacityTextureEnabled: boolean;
  15352. static OpacityTextureEnabled: boolean;
  15353. static _ReflectionTextureEnabled: boolean;
  15354. static ReflectionTextureEnabled: boolean;
  15355. static _EmissiveTextureEnabled: boolean;
  15356. static EmissiveTextureEnabled: boolean;
  15357. static _SpecularTextureEnabled: boolean;
  15358. static SpecularTextureEnabled: boolean;
  15359. static _BumpTextureEnabled: boolean;
  15360. static BumpTextureEnabled: boolean;
  15361. static _LightmapTextureEnabled: boolean;
  15362. static LightmapTextureEnabled: boolean;
  15363. static _RefractionTextureEnabled: boolean;
  15364. static RefractionTextureEnabled: boolean;
  15365. static _ColorGradingTextureEnabled: boolean;
  15366. static ColorGradingTextureEnabled: boolean;
  15367. static _FresnelEnabled: boolean;
  15368. static FresnelEnabled: boolean;
  15369. }
  15370. }
  15371. declare module BABYLON {
  15372. class UniformBuffer {
  15373. private _engine;
  15374. private _buffer;
  15375. private _data;
  15376. private _bufferData;
  15377. private _dynamic?;
  15378. private _uniformLocations;
  15379. private _uniformSizes;
  15380. private _uniformLocationPointer;
  15381. private _needSync;
  15382. private _noUBO;
  15383. private _currentEffect;
  15384. private static _MAX_UNIFORM_SIZE;
  15385. private static _tempBuffer;
  15386. /**
  15387. * Wrapper for updateUniform.
  15388. * @method updateMatrix3x3
  15389. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15390. * @param {Float32Array} matrix
  15391. */
  15392. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  15393. /**
  15394. * Wrapper for updateUniform.
  15395. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15396. * @param {Float32Array} matrix
  15397. */
  15398. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  15399. /**
  15400. * Wrapper for updateUniform.
  15401. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15402. * @param {number} x
  15403. */
  15404. updateFloat: (name: string, x: number) => void;
  15405. /**
  15406. * Wrapper for updateUniform.
  15407. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15408. * @param {number} x
  15409. * @param {number} y
  15410. * @param {string} [suffix] Suffix to add to the uniform name.
  15411. */
  15412. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  15413. /**
  15414. * Wrapper for updateUniform.
  15415. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15416. * @param {number} x
  15417. * @param {number} y
  15418. * @param {number} z
  15419. * @param {string} [suffix] Suffix to add to the uniform name.
  15420. */
  15421. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  15422. /**
  15423. * Wrapper for updateUniform.
  15424. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15425. * @param {number} x
  15426. * @param {number} y
  15427. * @param {number} z
  15428. * @param {number} w
  15429. * @param {string} [suffix] Suffix to add to the uniform name.
  15430. */
  15431. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  15432. /**
  15433. * Wrapper for updateUniform.
  15434. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15435. * @param {Matrix} A 4x4 matrix.
  15436. */
  15437. updateMatrix: (name: string, mat: Matrix) => void;
  15438. /**
  15439. * Wrapper for updateUniform.
  15440. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15441. * @param {Vector3} vector
  15442. */
  15443. updateVector3: (name: string, vector: Vector3) => void;
  15444. /**
  15445. * Wrapper for updateUniform.
  15446. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15447. * @param {Vector4} vector
  15448. */
  15449. updateVector4: (name: string, vector: Vector4) => void;
  15450. /**
  15451. * Wrapper for updateUniform.
  15452. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15453. * @param {Color3} color
  15454. * @param {string} [suffix] Suffix to add to the uniform name.
  15455. */
  15456. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  15457. /**
  15458. * Wrapper for updateUniform.
  15459. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15460. * @param {Color3} color
  15461. * @param {number} alpha
  15462. * @param {string} [suffix] Suffix to add to the uniform name.
  15463. */
  15464. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  15465. /**
  15466. * Uniform buffer objects.
  15467. *
  15468. * Handles blocks of uniform on the GPU.
  15469. *
  15470. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  15471. *
  15472. * For more information, please refer to :
  15473. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  15474. */
  15475. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  15476. /**
  15477. * Indicates if the buffer is using the WebGL2 UBO implementation,
  15478. * or just falling back on setUniformXXX calls.
  15479. */
  15480. readonly useUbo: boolean;
  15481. /**
  15482. * Indicates if the WebGL underlying uniform buffer is in sync
  15483. * with the javascript cache data.
  15484. */
  15485. readonly isSync: boolean;
  15486. /**
  15487. * Indicates if the WebGL underlying uniform buffer is dynamic.
  15488. * Also, a dynamic UniformBuffer will disable cache verification and always
  15489. * update the underlying WebGL uniform buffer to the GPU.
  15490. */
  15491. isDynamic(): boolean;
  15492. /**
  15493. * The data cache on JS side.
  15494. */
  15495. getData(): Float32Array;
  15496. /**
  15497. * The underlying WebGL Uniform buffer.
  15498. */
  15499. getBuffer(): Nullable<WebGLBuffer>;
  15500. /**
  15501. * std140 layout specifies how to align data within an UBO structure.
  15502. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  15503. * for specs.
  15504. */
  15505. private _fillAlignment;
  15506. /**
  15507. * Adds an uniform in the buffer.
  15508. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  15509. * for the layout to be correct !
  15510. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15511. * @param {number|number[]} size Data size, or data directly.
  15512. */
  15513. addUniform(name: string, size: number | number[]): void;
  15514. /**
  15515. * Wrapper for addUniform.
  15516. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15517. * @param {Matrix} mat A 4x4 matrix.
  15518. */
  15519. addMatrix(name: string, mat: Matrix): void;
  15520. /**
  15521. * Wrapper for addUniform.
  15522. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15523. * @param {number} x
  15524. * @param {number} y
  15525. */
  15526. addFloat2(name: string, x: number, y: number): void;
  15527. /**
  15528. * Wrapper for addUniform.
  15529. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15530. * @param {number} x
  15531. * @param {number} y
  15532. * @param {number} z
  15533. */
  15534. addFloat3(name: string, x: number, y: number, z: number): void;
  15535. /**
  15536. * Wrapper for addUniform.
  15537. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15538. * @param {Color3} color
  15539. */
  15540. addColor3(name: string, color: Color3): void;
  15541. /**
  15542. * Wrapper for addUniform.
  15543. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15544. * @param {Color3} color
  15545. * @param {number} alpha
  15546. */
  15547. addColor4(name: string, color: Color3, alpha: number): void;
  15548. /**
  15549. * Wrapper for addUniform.
  15550. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15551. * @param {Vector3} vector
  15552. */
  15553. addVector3(name: string, vector: Vector3): void;
  15554. /**
  15555. * Wrapper for addUniform.
  15556. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15557. */
  15558. addMatrix3x3(name: string): void;
  15559. /**
  15560. * Wrapper for addUniform.
  15561. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15562. */
  15563. addMatrix2x2(name: string): void;
  15564. /**
  15565. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  15566. */
  15567. create(): void;
  15568. /** @hidden */
  15569. _rebuild(): void;
  15570. /**
  15571. * Updates the WebGL Uniform Buffer on the GPU.
  15572. * If the `dynamic` flag is set to true, no cache comparison is done.
  15573. * Otherwise, the buffer will be updated only if the cache differs.
  15574. */
  15575. update(): void;
  15576. /**
  15577. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  15578. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15579. * @param {number[]|Float32Array} data Flattened data
  15580. * @param {number} size Size of the data.
  15581. */
  15582. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  15583. private _updateMatrix3x3ForUniform;
  15584. private _updateMatrix3x3ForEffect;
  15585. private _updateMatrix2x2ForEffect;
  15586. private _updateMatrix2x2ForUniform;
  15587. private _updateFloatForEffect;
  15588. private _updateFloatForUniform;
  15589. private _updateFloat2ForEffect;
  15590. private _updateFloat2ForUniform;
  15591. private _updateFloat3ForEffect;
  15592. private _updateFloat3ForUniform;
  15593. private _updateFloat4ForEffect;
  15594. private _updateFloat4ForUniform;
  15595. private _updateMatrixForEffect;
  15596. private _updateMatrixForUniform;
  15597. private _updateVector3ForEffect;
  15598. private _updateVector3ForUniform;
  15599. private _updateVector4ForEffect;
  15600. private _updateVector4ForUniform;
  15601. private _updateColor3ForEffect;
  15602. private _updateColor3ForUniform;
  15603. private _updateColor4ForEffect;
  15604. private _updateColor4ForUniform;
  15605. /**
  15606. * Sets a sampler uniform on the effect.
  15607. * @param {string} name Name of the sampler.
  15608. * @param {Texture} texture
  15609. */
  15610. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  15611. /**
  15612. * Directly updates the value of the uniform in the cache AND on the GPU.
  15613. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15614. * @param {number[]|Float32Array} data Flattened data
  15615. */
  15616. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  15617. /**
  15618. * Binds this uniform buffer to an effect.
  15619. * @param {Effect} effect
  15620. * @param {string} name Name of the uniform block in the shader.
  15621. */
  15622. bindToEffect(effect: Effect, name: string): void;
  15623. /**
  15624. * Disposes the uniform buffer.
  15625. */
  15626. dispose(): void;
  15627. }
  15628. }
  15629. declare module BABYLON {
  15630. /**
  15631. * Class used to store all common mesh properties
  15632. */
  15633. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  15634. /** No occlusion */
  15635. static OCCLUSION_TYPE_NONE: number;
  15636. /** Occlusion set to optimisitic */
  15637. static OCCLUSION_TYPE_OPTIMISTIC: number;
  15638. /** Occlusion set to strict */
  15639. static OCCLUSION_TYPE_STRICT: number;
  15640. /** Use an accurante occlusion algorithm */
  15641. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  15642. /** Use a conservative occlusion algorithm */
  15643. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  15644. /**
  15645. * No billboard
  15646. */
  15647. static readonly BILLBOARDMODE_NONE: number;
  15648. /** Billboard on X axis */
  15649. static readonly BILLBOARDMODE_X: number;
  15650. /** Billboard on Y axis */
  15651. static readonly BILLBOARDMODE_Y: number;
  15652. /** Billboard on Z axis */
  15653. static readonly BILLBOARDMODE_Z: number;
  15654. /** Billboard on all axes */
  15655. static readonly BILLBOARDMODE_ALL: number;
  15656. private _facetPositions;
  15657. private _facetNormals;
  15658. private _facetPartitioning;
  15659. private _facetNb;
  15660. private _partitioningSubdivisions;
  15661. private _partitioningBBoxRatio;
  15662. private _facetDataEnabled;
  15663. private _facetParameters;
  15664. private _bbSize;
  15665. private _subDiv;
  15666. private _facetDepthSort;
  15667. private _facetDepthSortEnabled;
  15668. private _depthSortedIndices;
  15669. private _depthSortedFacets;
  15670. private _facetDepthSortFunction;
  15671. private _facetDepthSortFrom;
  15672. private _facetDepthSortOrigin;
  15673. private _invertedMatrix;
  15674. /**
  15675. * Gets the number of facets in the mesh
  15676. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  15677. */
  15678. readonly facetNb: number;
  15679. /**
  15680. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  15681. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  15682. */
  15683. partitioningSubdivisions: number;
  15684. /**
  15685. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  15686. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  15687. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  15688. */
  15689. partitioningBBoxRatio: number;
  15690. /**
  15691. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  15692. * Works only for updatable meshes.
  15693. * Doesn't work with multi-materials
  15694. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  15695. */
  15696. mustDepthSortFacets: boolean;
  15697. /**
  15698. * The location (Vector3) where the facet depth sort must be computed from.
  15699. * By default, the active camera position.
  15700. * Used only when facet depth sort is enabled
  15701. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  15702. */
  15703. facetDepthSortFrom: Vector3;
  15704. /**
  15705. * gets a boolean indicating if facetData is enabled
  15706. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  15707. */
  15708. readonly isFacetDataEnabled: boolean;
  15709. /** @hidden */
  15710. _updateNonUniformScalingState(value: boolean): boolean;
  15711. /**
  15712. * An event triggered when this mesh collides with another one
  15713. */
  15714. onCollideObservable: Observable<AbstractMesh>;
  15715. private _onCollideObserver;
  15716. /** Set a function to call when this mesh collides with another one */
  15717. onCollide: () => void;
  15718. /**
  15719. * An event triggered when the collision's position changes
  15720. */
  15721. onCollisionPositionChangeObservable: Observable<Vector3>;
  15722. private _onCollisionPositionChangeObserver;
  15723. /** Set a function to call when the collision's position changes */
  15724. onCollisionPositionChange: () => void;
  15725. /**
  15726. * An event triggered when material is changed
  15727. */
  15728. onMaterialChangedObservable: Observable<AbstractMesh>;
  15729. /**
  15730. * Gets or sets the orientation for POV movement & rotation
  15731. */
  15732. definedFacingForward: boolean;
  15733. /**
  15734. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  15735. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  15736. * * 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.
  15737. * @see http://doc.babylonjs.com/features/occlusionquery
  15738. */
  15739. occlusionQueryAlgorithmType: number;
  15740. /**
  15741. * 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:
  15742. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  15743. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  15744. * * 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.
  15745. * @see http://doc.babylonjs.com/features/occlusionquery
  15746. */
  15747. occlusionType: number;
  15748. /**
  15749. * 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.
  15750. * The default value is -1 which means don't break the query and wait till the result
  15751. * @see http://doc.babylonjs.com/features/occlusionquery
  15752. */
  15753. occlusionRetryCount: number;
  15754. /** @hidden */
  15755. _occlusionInternalRetryCounter: number;
  15756. /** @hidden */
  15757. _isOccluded: boolean;
  15758. /**
  15759. * 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
  15760. * @see http://doc.babylonjs.com/features/occlusionquery
  15761. */
  15762. isOccluded: boolean;
  15763. /** @hidden */
  15764. _isOcclusionQueryInProgress: boolean;
  15765. /**
  15766. * Flag to check the progress status of the query
  15767. * @see http://doc.babylonjs.com/features/occlusionquery
  15768. */
  15769. readonly isOcclusionQueryInProgress: boolean;
  15770. /** @hidden */
  15771. _occlusionQuery: Nullable<WebGLQuery>;
  15772. private _visibility;
  15773. /**
  15774. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  15775. */
  15776. /**
  15777. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  15778. */
  15779. visibility: number;
  15780. /** Gets or sets the alpha index used to sort transparent meshes
  15781. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  15782. */
  15783. alphaIndex: number;
  15784. /**
  15785. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  15786. */
  15787. isVisible: boolean;
  15788. /**
  15789. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  15790. */
  15791. isPickable: boolean;
  15792. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  15793. showSubMeshesBoundingBox: boolean;
  15794. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  15795. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15796. */
  15797. isBlocker: boolean;
  15798. /**
  15799. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  15800. */
  15801. enablePointerMoveEvents: boolean;
  15802. /**
  15803. * Specifies the rendering group id for this mesh (0 by default)
  15804. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  15805. */
  15806. renderingGroupId: number;
  15807. private _material;
  15808. /** Gets or sets current material */
  15809. material: Nullable<Material>;
  15810. private _receiveShadows;
  15811. /**
  15812. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  15813. * @see http://doc.babylonjs.com/babylon101/shadows
  15814. */
  15815. receiveShadows: boolean;
  15816. /**
  15817. * Gets or sets a boolean indicating if the outline must be rendered as well
  15818. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  15819. */
  15820. renderOutline: boolean;
  15821. /** Defines color to use when rendering outline */
  15822. outlineColor: Color3;
  15823. /** Define width to use when rendering outline */
  15824. outlineWidth: number;
  15825. /**
  15826. * Gets or sets a boolean indicating if the overlay must be rendered as well
  15827. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  15828. */
  15829. renderOverlay: boolean;
  15830. /** Defines color to use when rendering overlay */
  15831. overlayColor: Color3;
  15832. /** Defines alpha to use when rendering overlay */
  15833. overlayAlpha: number;
  15834. private _hasVertexAlpha;
  15835. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  15836. hasVertexAlpha: boolean;
  15837. private _useVertexColors;
  15838. /** 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) */
  15839. useVertexColors: boolean;
  15840. private _computeBonesUsingShaders;
  15841. /**
  15842. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  15843. */
  15844. computeBonesUsingShaders: boolean;
  15845. private _numBoneInfluencers;
  15846. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  15847. numBoneInfluencers: number;
  15848. private _applyFog;
  15849. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  15850. applyFog: boolean;
  15851. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  15852. useOctreeForRenderingSelection: boolean;
  15853. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  15854. useOctreeForPicking: boolean;
  15855. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  15856. useOctreeForCollisions: boolean;
  15857. private _layerMask;
  15858. /**
  15859. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  15860. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  15861. */
  15862. layerMask: number;
  15863. /**
  15864. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  15865. */
  15866. alwaysSelectAsActiveMesh: boolean;
  15867. /**
  15868. * Gets or sets the current action manager
  15869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15870. */
  15871. actionManager: Nullable<ActionManager>;
  15872. /**
  15873. * Gets or sets impostor used for physic simulation
  15874. * @see http://doc.babylonjs.com/features/physics_engine
  15875. */
  15876. physicsImpostor: Nullable<PhysicsImpostor>;
  15877. private _checkCollisions;
  15878. private _collisionMask;
  15879. private _collisionGroup;
  15880. /**
  15881. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  15882. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  15883. */
  15884. ellipsoid: Vector3;
  15885. /**
  15886. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  15887. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  15888. */
  15889. ellipsoidOffset: Vector3;
  15890. private _collider;
  15891. private _oldPositionForCollisions;
  15892. private _diffPositionForCollisions;
  15893. /**
  15894. * Gets or sets a collision mask used to mask collisions (default is -1).
  15895. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  15896. */
  15897. collisionMask: number;
  15898. /**
  15899. * Gets or sets the current collision group mask (-1 by default).
  15900. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  15901. */
  15902. collisionGroup: number;
  15903. /**
  15904. * Defines edge width used when edgesRenderer is enabled
  15905. * @see https://www.babylonjs-playground.com/#10OJSG#13
  15906. */
  15907. edgesWidth: number;
  15908. /**
  15909. * Defines edge color used when edgesRenderer is enabled
  15910. * @see https://www.babylonjs-playground.com/#10OJSG#13
  15911. */
  15912. edgesColor: Color4;
  15913. /** @hidden */
  15914. _edgesRenderer: Nullable<EdgesRenderer>;
  15915. private _collisionsTransformMatrix;
  15916. private _collisionsScalingMatrix;
  15917. /** @hidden */
  15918. _masterMesh: Nullable<AbstractMesh>;
  15919. /** @hidden */
  15920. _boundingInfo: Nullable<BoundingInfo>;
  15921. /** @hidden */
  15922. _renderId: number;
  15923. /**
  15924. * Gets or sets the list of subMeshes
  15925. * @see http://doc.babylonjs.com/how_to/multi_materials
  15926. */
  15927. subMeshes: SubMesh[];
  15928. /** @hidden */
  15929. _submeshesOctree: Octree<SubMesh>;
  15930. /** @hidden */
  15931. _intersectionsInProgress: AbstractMesh[];
  15932. /** @hidden */
  15933. _unIndexed: boolean;
  15934. /** @hidden */
  15935. _lightSources: Light[];
  15936. /** @hidden */
  15937. readonly _positions: Nullable<Vector3[]>;
  15938. /** @hidden */
  15939. _waitingActions: any;
  15940. /** @hidden */
  15941. _waitingFreezeWorldMatrix: Nullable<boolean>;
  15942. private _skeleton;
  15943. /** @hidden */
  15944. _bonesTransformMatrices: Nullable<Float32Array>;
  15945. /**
  15946. * Gets or sets a skeleton to apply skining transformations
  15947. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15948. */
  15949. skeleton: Nullable<Skeleton>;
  15950. /**
  15951. * Creates a new AbstractMesh
  15952. * @param name defines the name of the mesh
  15953. * @param scene defines the hosting scene
  15954. */
  15955. constructor(name: string, scene?: Nullable<Scene>);
  15956. /**
  15957. * Returns the string "AbstractMesh"
  15958. * @returns "AbstractMesh"
  15959. */
  15960. getClassName(): string;
  15961. /**
  15962. * Gets a string representation of the current mesh
  15963. * @param fullDetails defines a boolean indicating if full details must be included
  15964. * @returns a string representation of the current mesh
  15965. */
  15966. toString(fullDetails?: boolean): string;
  15967. /** @hidden */
  15968. _rebuild(): void;
  15969. /** @hidden */
  15970. _resyncLightSources(): void;
  15971. /** @hidden */
  15972. _resyncLighSource(light: Light): void;
  15973. /** @hidden */
  15974. _unBindEffect(): void;
  15975. /** @hidden */
  15976. _removeLightSource(light: Light): void;
  15977. private _markSubMeshesAsDirty;
  15978. /** @hidden */
  15979. _markSubMeshesAsLightDirty(): void;
  15980. /** @hidden */
  15981. _markSubMeshesAsAttributesDirty(): void;
  15982. /** @hidden */
  15983. _markSubMeshesAsMiscDirty(): void;
  15984. /**
  15985. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  15986. */
  15987. scaling: Vector3;
  15988. /**
  15989. * Disables the mesh edge rendering mode
  15990. * @returns the currentAbstractMesh
  15991. */
  15992. disableEdgesRendering(): AbstractMesh;
  15993. /**
  15994. * Enables the edge rendering mode on the mesh.
  15995. * This mode makes the mesh edges visible
  15996. * @param epsilon defines the maximal distance between two angles to detect a face
  15997. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15998. * @returns the currentAbstractMesh
  15999. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16000. */
  16001. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16002. /**
  16003. * Gets the edgesRenderer associated with the mesh
  16004. */
  16005. readonly edgesRenderer: Nullable<EdgesRenderer>;
  16006. /**
  16007. * Returns true if the mesh is blocked. Implemented by child classes
  16008. */
  16009. readonly isBlocked: boolean;
  16010. /**
  16011. * Returns the mesh itself by default. Implemented by child classes
  16012. * @param camera defines the camera to use to pick the right LOD level
  16013. * @returns the currentAbstractMesh
  16014. */
  16015. getLOD(camera: Camera): Nullable<AbstractMesh>;
  16016. /**
  16017. * Returns 0 by default. Implemented by child classes
  16018. * @returns an integer
  16019. */
  16020. getTotalVertices(): number;
  16021. /**
  16022. * Returns null by default. Implemented by child classes
  16023. * @returns null
  16024. */
  16025. getIndices(): Nullable<IndicesArray>;
  16026. /**
  16027. * Returns the array of the requested vertex data kind. Implemented by child classes
  16028. * @param kind defines the vertex data kind to use
  16029. * @returns null
  16030. */
  16031. getVerticesData(kind: string): Nullable<FloatArray>;
  16032. /**
  16033. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16034. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16035. * Note that a new underlying VertexBuffer object is created each call.
  16036. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16037. * @param kind defines vertex data kind:
  16038. * * BABYLON.VertexBuffer.PositionKind
  16039. * * BABYLON.VertexBuffer.UVKind
  16040. * * BABYLON.VertexBuffer.UV2Kind
  16041. * * BABYLON.VertexBuffer.UV3Kind
  16042. * * BABYLON.VertexBuffer.UV4Kind
  16043. * * BABYLON.VertexBuffer.UV5Kind
  16044. * * BABYLON.VertexBuffer.UV6Kind
  16045. * * BABYLON.VertexBuffer.ColorKind
  16046. * * BABYLON.VertexBuffer.MatricesIndicesKind
  16047. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16048. * * BABYLON.VertexBuffer.MatricesWeightsKind
  16049. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16050. * @param data defines the data source
  16051. * @param updatable defines if the data must be flagged as updatable (or static)
  16052. * @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
  16053. * @returns the current mesh
  16054. */
  16055. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16056. /**
  16057. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16058. * If the mesh has no geometry, it is simply returned as it is.
  16059. * @param kind defines vertex data kind:
  16060. * * BABYLON.VertexBuffer.PositionKind
  16061. * * BABYLON.VertexBuffer.UVKind
  16062. * * BABYLON.VertexBuffer.UV2Kind
  16063. * * BABYLON.VertexBuffer.UV3Kind
  16064. * * BABYLON.VertexBuffer.UV4Kind
  16065. * * BABYLON.VertexBuffer.UV5Kind
  16066. * * BABYLON.VertexBuffer.UV6Kind
  16067. * * BABYLON.VertexBuffer.ColorKind
  16068. * * BABYLON.VertexBuffer.MatricesIndicesKind
  16069. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16070. * * BABYLON.VertexBuffer.MatricesWeightsKind
  16071. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16072. * @param data defines the data source
  16073. * @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
  16074. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  16075. * @returns the current mesh
  16076. */
  16077. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  16078. /**
  16079. * Sets the mesh indices,
  16080. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16081. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  16082. * @param totalVertices Defines the total number of vertices
  16083. * @returns the current mesh
  16084. */
  16085. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  16086. /**
  16087. * Gets a boolean indicating if specific vertex data is present
  16088. * @param kind defines the vertex data kind to use
  16089. * @returns true is data kind is present
  16090. */
  16091. isVerticesDataPresent(kind: string): boolean;
  16092. /**
  16093. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  16094. * @returns a BoundingInfo
  16095. */
  16096. getBoundingInfo(): BoundingInfo;
  16097. /**
  16098. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  16099. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  16100. * @returns the current mesh
  16101. */
  16102. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  16103. /**
  16104. * Overwrite the current bounding info
  16105. * @param boundingInfo defines the new bounding info
  16106. * @returns the current mesh
  16107. */
  16108. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  16109. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  16110. readonly useBones: boolean;
  16111. /** @hidden */
  16112. _preActivate(): void;
  16113. /** @hidden */
  16114. _preActivateForIntermediateRendering(renderId: number): void;
  16115. /** @hidden */
  16116. _activate(renderId: number): void;
  16117. /**
  16118. * Gets the current world matrix
  16119. * @returns a Matrix
  16120. */
  16121. getWorldMatrix(): Matrix;
  16122. /** @hidden */
  16123. _getWorldMatrixDeterminant(): number;
  16124. /**
  16125. * Perform relative position change from the point of view of behind the front of the mesh.
  16126. * This is performed taking into account the meshes current rotation, so you do not have to care.
  16127. * Supports definition of mesh facing forward or backward
  16128. * @param amountRight defines the distance on the right axis
  16129. * @param amountUp defines the distance on the up axis
  16130. * @param amountForward defines the distance on the forward axis
  16131. * @returns the current mesh
  16132. */
  16133. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  16134. /**
  16135. * Calculate relative position change from the point of view of behind the front of the mesh.
  16136. * This is performed taking into account the meshes current rotation, so you do not have to care.
  16137. * Supports definition of mesh facing forward or backward
  16138. * @param amountRight defines the distance on the right axis
  16139. * @param amountUp defines the distance on the up axis
  16140. * @param amountForward defines the distance on the forward axis
  16141. * @returns the new displacement vector
  16142. */
  16143. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  16144. /**
  16145. * Perform relative rotation change from the point of view of behind the front of the mesh.
  16146. * Supports definition of mesh facing forward or backward
  16147. * @param flipBack defines the flip
  16148. * @param twirlClockwise defines the twirl
  16149. * @param tiltRight defines the tilt
  16150. * @returns the current mesh
  16151. */
  16152. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  16153. /**
  16154. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  16155. * Supports definition of mesh facing forward or backward.
  16156. * @param flipBack defines the flip
  16157. * @param twirlClockwise defines the twirl
  16158. * @param tiltRight defines the tilt
  16159. * @returns the new rotation vector
  16160. */
  16161. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  16162. /**
  16163. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  16164. * @param includeDescendants Include bounding info from descendants as well (true by default)
  16165. * @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
  16166. * @returns the new bounding vectors
  16167. */
  16168. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  16169. min: Vector3;
  16170. max: Vector3;
  16171. };
  16172. /** @hidden */
  16173. _updateBoundingInfo(): AbstractMesh;
  16174. /** @hidden */
  16175. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  16176. /** @hidden */
  16177. protected _afterComputeWorldMatrix(): void;
  16178. /**
  16179. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  16180. * A mesh is in the frustum if its bounding box intersects the frustum
  16181. * @param frustumPlanes defines the frustum to test
  16182. * @returns true if the mesh is in the frustum planes
  16183. */
  16184. isInFrustum(frustumPlanes: Plane[]): boolean;
  16185. /**
  16186. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  16187. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  16188. * @param frustumPlanes defines the frustum to test
  16189. * @returns true if the mesh is completely in the frustum planes
  16190. */
  16191. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  16192. /**
  16193. * True if the mesh intersects another mesh or a SolidParticle object
  16194. * @param mesh defines a target mesh or SolidParticle to test
  16195. * @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)
  16196. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  16197. * @returns true if there is an intersection
  16198. */
  16199. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  16200. /**
  16201. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  16202. * @param point defines the point to test
  16203. * @returns true if there is an intersection
  16204. */
  16205. intersectsPoint(point: Vector3): boolean;
  16206. /**
  16207. * Gets the current physics impostor
  16208. * @see http://doc.babylonjs.com/features/physics_engine
  16209. * @returns a physics impostor or null
  16210. */
  16211. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  16212. /**
  16213. * Gets the position of the current mesh in camera space
  16214. * @param camera defines the camera to use
  16215. * @returns a position
  16216. */
  16217. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  16218. /**
  16219. * Returns the distance from the mesh to the active camera
  16220. * @param camera defines the camera to use
  16221. * @returns the distance
  16222. */
  16223. getDistanceToCamera(camera?: Nullable<Camera>): number;
  16224. /**
  16225. * Apply a physic impulse to the mesh
  16226. * @param force defines the force to apply
  16227. * @param contactPoint defines where to apply the force
  16228. * @returns the current mesh
  16229. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  16230. */
  16231. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  16232. /**
  16233. * Creates a physic joint between two meshes
  16234. * @param otherMesh defines the other mesh to use
  16235. * @param pivot1 defines the pivot to use on this mesh
  16236. * @param pivot2 defines the pivot to use on the other mesh
  16237. * @param options defines additional options (can be plugin dependent)
  16238. * @returns the current mesh
  16239. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  16240. */
  16241. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  16242. /**
  16243. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  16244. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  16245. */
  16246. checkCollisions: boolean;
  16247. /**
  16248. * Gets Collider object used to compute collisions (not physics)
  16249. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  16250. */
  16251. readonly collider: Collider;
  16252. /**
  16253. * Move the mesh using collision engine
  16254. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  16255. * @param displacement defines the requested displacement vector
  16256. * @returns the current mesh
  16257. */
  16258. moveWithCollisions(displacement: Vector3): AbstractMesh;
  16259. private _onCollisionPositionChange;
  16260. /**
  16261. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  16262. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  16263. * @param maxCapacity defines the maximum size of each block (64 by default)
  16264. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  16265. * @returns the new octree
  16266. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  16267. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  16268. */
  16269. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  16270. /** @hidden */
  16271. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  16272. /** @hidden */
  16273. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  16274. /** @hidden */
  16275. _checkCollision(collider: Collider): AbstractMesh;
  16276. /** @hidden */
  16277. _generatePointsArray(): boolean;
  16278. /**
  16279. * Checks if the passed Ray intersects with the mesh
  16280. * @param ray defines the ray to use
  16281. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  16282. * @returns the picking info
  16283. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  16284. */
  16285. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  16286. /**
  16287. * Clones the current mesh
  16288. * @param name defines the mesh name
  16289. * @param newParent defines the new mesh parent
  16290. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  16291. * @returns the new mesh
  16292. */
  16293. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  16294. /**
  16295. * Disposes all the submeshes of the current meshnp
  16296. * @returns the current mesh
  16297. */
  16298. releaseSubMeshes(): AbstractMesh;
  16299. /**
  16300. * Releases resources associated with this abstract mesh.
  16301. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  16302. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  16303. */
  16304. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16305. /**
  16306. * Adds the passed mesh as a child to the current mesh
  16307. * @param mesh defines the child mesh
  16308. * @returns the current mesh
  16309. */
  16310. addChild(mesh: AbstractMesh): AbstractMesh;
  16311. /**
  16312. * Removes the passed mesh from the current mesh children list
  16313. * @param mesh defines the child mesh
  16314. * @returns the current mesh
  16315. */
  16316. removeChild(mesh: AbstractMesh): AbstractMesh;
  16317. /** @hidden */
  16318. private _initFacetData;
  16319. /**
  16320. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  16321. * This method can be called within the render loop.
  16322. * 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
  16323. * @returns the current mesh
  16324. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  16325. */
  16326. updateFacetData(): AbstractMesh;
  16327. /**
  16328. * Returns the facetLocalNormals array.
  16329. * The normals are expressed in the mesh local spac
  16330. * @returns an array of Vector3
  16331. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  16332. */
  16333. getFacetLocalNormals(): Vector3[];
  16334. /**
  16335. * Returns the facetLocalPositions array.
  16336. * The facet positions are expressed in the mesh local space
  16337. * @returns an array of Vector3
  16338. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  16339. */
  16340. getFacetLocalPositions(): Vector3[];
  16341. /**
  16342. * Returns the facetLocalPartioning array
  16343. * @returns an array of array of numbers
  16344. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  16345. */
  16346. getFacetLocalPartitioning(): number[][];
  16347. /**
  16348. * Returns the i-th facet position in the world system.
  16349. * This method allocates a new Vector3 per call
  16350. * @param i defines the facet index
  16351. * @returns a new Vector3
  16352. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  16353. */
  16354. getFacetPosition(i: number): Vector3;
  16355. /**
  16356. * Sets the reference Vector3 with the i-th facet position in the world system
  16357. * @param i defines the facet index
  16358. * @param ref defines the target vector
  16359. * @returns the current mesh
  16360. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  16361. */
  16362. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  16363. /**
  16364. * Returns the i-th facet normal in the world system.
  16365. * This method allocates a new Vector3 per call
  16366. * @param i defines the facet index
  16367. * @returns a new Vector3
  16368. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  16369. */
  16370. getFacetNormal(i: number): Vector3;
  16371. /**
  16372. * Sets the reference Vector3 with the i-th facet normal in the world system
  16373. * @param i defines the facet index
  16374. * @param ref defines the target vector
  16375. * @returns the current mesh
  16376. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  16377. */
  16378. getFacetNormalToRef(i: number, ref: Vector3): this;
  16379. /**
  16380. * 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)
  16381. * @param x defines x coordinate
  16382. * @param y defines y coordinate
  16383. * @param z defines z coordinate
  16384. * @returns the array of facet indexes
  16385. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  16386. */
  16387. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  16388. /**
  16389. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  16390. * @param projected sets as the (x,y,z) world projection on the facet
  16391. * @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
  16392. * @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
  16393. * @param x defines x coordinate
  16394. * @param y defines y coordinate
  16395. * @param z defines z coordinate
  16396. * @returns the face index if found (or null instead)
  16397. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  16398. */
  16399. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  16400. /**
  16401. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  16402. * @param projected sets as the (x,y,z) local projection on the facet
  16403. * @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
  16404. * @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
  16405. * @param x defines x coordinate
  16406. * @param y defines y coordinate
  16407. * @param z defines z coordinate
  16408. * @returns the face index if found (or null instead)
  16409. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  16410. */
  16411. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  16412. /**
  16413. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  16414. * @returns the parameters
  16415. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  16416. */
  16417. getFacetDataParameters(): any;
  16418. /**
  16419. * Disables the feature FacetData and frees the related memory
  16420. * @returns the current mesh
  16421. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  16422. */
  16423. disableFacetData(): AbstractMesh;
  16424. /**
  16425. * Updates the AbstractMesh indices array
  16426. * @param indices defines the data source
  16427. * @returns the current mesh
  16428. */
  16429. updateIndices(indices: IndicesArray): AbstractMesh;
  16430. /**
  16431. * Creates new normals data for the mesh
  16432. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  16433. * @returns the current mesh
  16434. */
  16435. createNormals(updatable: boolean): AbstractMesh;
  16436. /**
  16437. * Align the mesh with a normal
  16438. * @param normal defines the normal to use
  16439. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  16440. * @returns the current mesh
  16441. */
  16442. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  16443. /** @hidden */
  16444. _checkOcclusionQuery(): void;
  16445. }
  16446. }
  16447. declare module BABYLON {
  16448. class Buffer {
  16449. private _engine;
  16450. private _buffer;
  16451. /** @hidden */
  16452. _data: Nullable<DataArray>;
  16453. private _updatable;
  16454. private _instanced;
  16455. /**
  16456. * Gets the byte stride.
  16457. */
  16458. readonly byteStride: number;
  16459. /**
  16460. * Constructor
  16461. * @param engine the engine
  16462. * @param data the data to use for this buffer
  16463. * @param updatable whether the data is updatable
  16464. * @param stride the stride (optional)
  16465. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  16466. * @param instanced whether the buffer is instanced (optional)
  16467. * @param useBytes set to true if the stride in in bytes (optional)
  16468. */
  16469. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  16470. /**
  16471. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  16472. * @param kind defines the vertex buffer kind (position, normal, etc.)
  16473. * @param offset defines offset in the buffer (0 by default)
  16474. * @param size defines the size in floats of attributes (position is 3 for instance)
  16475. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  16476. * @param instanced defines if the vertex buffer contains indexed data
  16477. * @param useBytes defines if the offset and stride are in bytes
  16478. * @returns the new vertex buffer
  16479. */
  16480. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  16481. isUpdatable(): boolean;
  16482. getData(): Nullable<DataArray>;
  16483. getBuffer(): Nullable<WebGLBuffer>;
  16484. /**
  16485. * Gets the stride in float32 units (i.e. byte stride / 4).
  16486. * May not be an integer if the byte stride is not divisible by 4.
  16487. * DEPRECATED. Use byteStride instead.
  16488. * @returns the stride in float32 units
  16489. */
  16490. getStrideSize(): number;
  16491. create(data?: Nullable<DataArray>): void;
  16492. /** @hidden */
  16493. _rebuild(): void;
  16494. update(data: DataArray): void;
  16495. /**
  16496. * Updates the data directly.
  16497. * @param data the new data
  16498. * @param offset the new offset
  16499. * @param vertexCount the vertex count (optional)
  16500. * @param useBytes set to true if the offset is in bytes
  16501. */
  16502. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  16503. dispose(): void;
  16504. }
  16505. }
  16506. declare module BABYLON {
  16507. class CSG {
  16508. private polygons;
  16509. matrix: Matrix;
  16510. position: Vector3;
  16511. rotation: Vector3;
  16512. rotationQuaternion: Nullable<Quaternion>;
  16513. scaling: Vector3;
  16514. static FromMesh(mesh: Mesh): CSG;
  16515. private static FromPolygons;
  16516. clone(): CSG;
  16517. union(csg: CSG): CSG;
  16518. unionInPlace(csg: CSG): void;
  16519. subtract(csg: CSG): CSG;
  16520. subtractInPlace(csg: CSG): void;
  16521. intersect(csg: CSG): CSG;
  16522. intersectInPlace(csg: CSG): void;
  16523. inverse(): CSG;
  16524. inverseInPlace(): void;
  16525. copyTransformAttributes(csg: CSG): CSG;
  16526. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  16527. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  16528. }
  16529. }
  16530. declare module BABYLON {
  16531. /**
  16532. * Class used to store geometry data (vertex buffers + index buffer)
  16533. */
  16534. class Geometry implements IGetSetVerticesData {
  16535. /**
  16536. * Gets or sets the unique ID of the geometry
  16537. */
  16538. id: string;
  16539. /**
  16540. * Gets the delay loading state of the geometry (none by default which means not delayed)
  16541. */
  16542. delayLoadState: number;
  16543. /**
  16544. * Gets the file containing the data to load when running in delay load state
  16545. */
  16546. delayLoadingFile: Nullable<string>;
  16547. /**
  16548. * Callback called when the geometry is updated
  16549. */
  16550. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  16551. private _scene;
  16552. private _engine;
  16553. private _meshes;
  16554. private _totalVertices;
  16555. /** @hidden */
  16556. _indices: IndicesArray;
  16557. /** @hidden */
  16558. _vertexBuffers: {
  16559. [key: string]: VertexBuffer;
  16560. };
  16561. private _isDisposed;
  16562. private _extend;
  16563. private _boundingBias;
  16564. /** @hidden */
  16565. _delayInfo: Array<string>;
  16566. private _indexBuffer;
  16567. private _indexBufferIsUpdatable;
  16568. /** @hidden */
  16569. _boundingInfo: Nullable<BoundingInfo>;
  16570. /** @hidden */
  16571. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  16572. /** @hidden */
  16573. _softwareSkinningRenderId: number;
  16574. private _vertexArrayObjects;
  16575. private _updatable;
  16576. /** @hidden */
  16577. _positions: Nullable<Vector3[]>;
  16578. /**
  16579. * 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
  16580. */
  16581. /**
  16582. * 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
  16583. */
  16584. boundingBias: Vector2;
  16585. /**
  16586. * Static function used to attach a new empty geometry to a mesh
  16587. * @param mesh defines the mesh to attach the geometry to
  16588. * @returns the new {BABYLON.Geometry}
  16589. */
  16590. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  16591. /**
  16592. * Creates a new geometry
  16593. * @param id defines the unique ID
  16594. * @param scene defines the hosting scene
  16595. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  16596. * @param updatable defines if geometry must be updatable (false by default)
  16597. * @param mesh defines the mesh that will be associated with the geometry
  16598. */
  16599. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  16600. /**
  16601. * Gets the current extend of the geometry
  16602. */
  16603. readonly extend: {
  16604. minimum: Vector3;
  16605. maximum: Vector3;
  16606. };
  16607. /**
  16608. * Gets the hosting scene
  16609. * @returns the hosting {BABYLON.Scene}
  16610. */
  16611. getScene(): Scene;
  16612. /**
  16613. * Gets the hosting engine
  16614. * @returns the hosting {BABYLON.Engine}
  16615. */
  16616. getEngine(): Engine;
  16617. /**
  16618. * Defines if the geometry is ready to use
  16619. * @returns true if the geometry is ready to be used
  16620. */
  16621. isReady(): boolean;
  16622. /**
  16623. * Gets a value indicating that the geometry should not be serialized
  16624. */
  16625. readonly doNotSerialize: boolean;
  16626. /** @hidden */
  16627. _rebuild(): void;
  16628. /**
  16629. * Affects all geometry data in one call
  16630. * @param vertexData defines the geometry data
  16631. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  16632. */
  16633. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  16634. /**
  16635. * Set specific vertex data
  16636. * @param kind defines the data kind (Position, normal, etc...)
  16637. * @param data defines the vertex data to use
  16638. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  16639. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  16640. */
  16641. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  16642. /**
  16643. * Removes a specific vertex data
  16644. * @param kind defines the data kind (Position, normal, etc...)
  16645. */
  16646. removeVerticesData(kind: string): void;
  16647. /**
  16648. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  16649. * @param buffer defines the vertex buffer to use
  16650. * @param totalVertices defines the total number of vertices for position kind (could be null)
  16651. */
  16652. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  16653. /**
  16654. * Update a specific vertex buffer
  16655. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  16656. * It will do nothing if the buffer is not updatable
  16657. * @param kind defines the data kind (Position, normal, etc...)
  16658. * @param data defines the data to use
  16659. * @param offset defines the offset in the target buffer where to store the data
  16660. * @param useBytes set to true if the offset is in bytes
  16661. */
  16662. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  16663. /**
  16664. * Update a specific vertex buffer
  16665. * This function will create a new buffer if the current one is not updatable
  16666. * @param kind defines the data kind (Position, normal, etc...)
  16667. * @param data defines the data to use
  16668. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  16669. */
  16670. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  16671. private _updateBoundingInfo;
  16672. /** @hidden */
  16673. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  16674. /**
  16675. * Gets total number of vertices
  16676. * @returns the total number of vertices
  16677. */
  16678. getTotalVertices(): number;
  16679. /**
  16680. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  16681. * @param kind defines the data kind (Position, normal, etc...)
  16682. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  16683. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  16684. * @returns a float array containing vertex data
  16685. */
  16686. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  16687. /**
  16688. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  16689. * @param kind defines the data kind (Position, normal, etc...)
  16690. * @returns true if the vertex buffer with the specified kind is updatable
  16691. */
  16692. isVertexBufferUpdatable(kind: string): boolean;
  16693. /**
  16694. * Gets a specific vertex buffer
  16695. * @param kind defines the data kind (Position, normal, etc...)
  16696. * @returns a {BABYLON.VertexBuffer}
  16697. */
  16698. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  16699. /**
  16700. * Returns all vertex buffers
  16701. * @return an object holding all vertex buffers indexed by kind
  16702. */
  16703. getVertexBuffers(): Nullable<{
  16704. [key: string]: VertexBuffer;
  16705. }>;
  16706. /**
  16707. * Gets a boolean indicating if specific vertex buffer is present
  16708. * @param kind defines the data kind (Position, normal, etc...)
  16709. * @returns true if data is present
  16710. */
  16711. isVerticesDataPresent(kind: string): boolean;
  16712. /**
  16713. * Gets a list of all attached data kinds (Position, normal, etc...)
  16714. * @returns a list of string containing all kinds
  16715. */
  16716. getVerticesDataKinds(): string[];
  16717. /**
  16718. * Update index buffer
  16719. * @param indices defines the indices to store in the index buffer
  16720. * @param offset defines the offset in the target buffer where to store the data
  16721. */
  16722. updateIndices(indices: IndicesArray, offset?: number): void;
  16723. /**
  16724. * Creates a new index buffer
  16725. * @param indices defines the indices to store in the index buffer
  16726. * @param totalVertices defines the total number of vertices (could be null)
  16727. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  16728. */
  16729. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  16730. /**
  16731. * Return the total number of indices
  16732. * @returns the total number of indices
  16733. */
  16734. getTotalIndices(): number;
  16735. /**
  16736. * Gets the index buffer array
  16737. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  16738. * @returns the index buffer array
  16739. */
  16740. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  16741. /**
  16742. * Gets the index buffer
  16743. * @return the index buffer
  16744. */
  16745. getIndexBuffer(): Nullable<WebGLBuffer>;
  16746. /** @hidden */
  16747. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  16748. /**
  16749. * Release the associated resources for a specific mesh
  16750. * @param mesh defines the source mesh
  16751. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  16752. */
  16753. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  16754. /**
  16755. * Apply current geometry to a given mesh
  16756. * @param mesh defines the mesh to apply geometry to
  16757. */
  16758. applyToMesh(mesh: Mesh): void;
  16759. private _updateExtend;
  16760. private _applyToMesh;
  16761. private notifyUpdate;
  16762. /**
  16763. * Load the geometry if it was flagged as delay loaded
  16764. * @param scene defines the hosting scene
  16765. * @param onLoaded defines a callback called when the geometry is loaded
  16766. */
  16767. load(scene: Scene, onLoaded?: () => void): void;
  16768. private _queueLoad;
  16769. /**
  16770. * Invert the geometry to move from a right handed system to a left handed one.
  16771. */
  16772. toLeftHanded(): void;
  16773. /** @hidden */
  16774. _resetPointsArrayCache(): void;
  16775. /** @hidden */
  16776. _generatePointsArray(): boolean;
  16777. /**
  16778. * Gets a value indicating if the geometry is disposed
  16779. * @returns true if the geometry was disposed
  16780. */
  16781. isDisposed(): boolean;
  16782. private _disposeVertexArrayObjects;
  16783. /**
  16784. * Free all associated resources
  16785. */
  16786. dispose(): void;
  16787. /**
  16788. * Clone the current geometry into a new geometry
  16789. * @param id defines the unique ID of the new geometry
  16790. * @returns a new geometry object
  16791. */
  16792. copy(id: string): Geometry;
  16793. /**
  16794. * Serialize the current geometry info (and not the vertices data) into a JSON object
  16795. * @return a JSON representation of the current geometry data (without the vertices data)
  16796. */
  16797. serialize(): any;
  16798. private toNumberArray;
  16799. /**
  16800. * Serialize all vertices data into a JSON oject
  16801. * @returns a JSON representation of the current geometry data
  16802. */
  16803. serializeVerticeData(): any;
  16804. /**
  16805. * Extracts a clone of a mesh geometry
  16806. * @param mesh defines the source mesh
  16807. * @param id defines the unique ID of the new geometry object
  16808. * @returns the new geometry object
  16809. */
  16810. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  16811. /**
  16812. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  16813. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  16814. * Be aware Math.random() could cause collisions, but:
  16815. * "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"
  16816. * @returns a string containing a new GUID
  16817. */
  16818. static RandomId(): string;
  16819. /** @hidden */
  16820. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  16821. private static _CleanMatricesWeights;
  16822. /**
  16823. * Create a new geometry from persisted data (Using .babylon file format)
  16824. * @param parsedVertexData defines the persisted data
  16825. * @param scene defines the hosting scene
  16826. * @param rootUrl defines the root url to use to load assets (like delayed data)
  16827. * @returns the new geometry object
  16828. */
  16829. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  16830. }
  16831. /**
  16832. * Abstract class used to provide common services for all typed geometries
  16833. * @hidden
  16834. */
  16835. class _PrimitiveGeometry extends Geometry {
  16836. private _canBeRegenerated;
  16837. private _beingRegenerated;
  16838. /**
  16839. * Creates a new typed geometry
  16840. * @param id defines the unique ID of the geometry
  16841. * @param scene defines the hosting scene
  16842. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16843. * @param mesh defines the hosting mesh (can be null)
  16844. */
  16845. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  16846. /**
  16847. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  16848. * @returns true if the geometry can be regenerated
  16849. */
  16850. canBeRegenerated(): boolean;
  16851. /**
  16852. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  16853. */
  16854. regenerate(): void;
  16855. /**
  16856. * Clone the geometry
  16857. * @param id defines the unique ID of the new geometry
  16858. * @returns the new geometry
  16859. */
  16860. asNewGeometry(id: string): Geometry;
  16861. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  16862. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  16863. /** @hidden */
  16864. _regenerateVertexData(): VertexData;
  16865. copy(id: string): Geometry;
  16866. serialize(): any;
  16867. }
  16868. /**
  16869. * Creates a ribbon geometry
  16870. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  16871. */
  16872. class RibbonGeometry extends _PrimitiveGeometry {
  16873. /**
  16874. * Defines the array of paths to use
  16875. */
  16876. pathArray: Vector3[][];
  16877. /**
  16878. * Defines if the last and first points of each path in your pathArray must be joined
  16879. */
  16880. closeArray: boolean;
  16881. /**
  16882. * Defines if the last and first points of each path in your pathArray must be joined
  16883. */
  16884. closePath: boolean;
  16885. /**
  16886. * Defines the offset between points
  16887. */
  16888. offset: number;
  16889. /**
  16890. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16891. */
  16892. side: number;
  16893. /**
  16894. * Creates a ribbon geometry
  16895. * @param id defines the unique ID of the geometry
  16896. * @param scene defines the hosting scene
  16897. * @param pathArray defines the array of paths to use
  16898. * @param closeArray defines if the last path and the first path must be joined
  16899. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  16900. * @param offset defines the offset between points
  16901. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16902. * @param mesh defines the hosting mesh (can be null)
  16903. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16904. */
  16905. constructor(id: string, scene: Scene,
  16906. /**
  16907. * Defines the array of paths to use
  16908. */
  16909. pathArray: Vector3[][],
  16910. /**
  16911. * Defines if the last and first points of each path in your pathArray must be joined
  16912. */
  16913. closeArray: boolean,
  16914. /**
  16915. * Defines if the last and first points of each path in your pathArray must be joined
  16916. */
  16917. closePath: boolean,
  16918. /**
  16919. * Defines the offset between points
  16920. */
  16921. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  16922. /**
  16923. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16924. */
  16925. side?: number);
  16926. /** @hidden */
  16927. _regenerateVertexData(): VertexData;
  16928. copy(id: string): Geometry;
  16929. }
  16930. /**
  16931. * Creates a box geometry
  16932. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  16933. */
  16934. class BoxGeometry extends _PrimitiveGeometry {
  16935. /**
  16936. * Defines the zise of the box (width, height and depth are the same)
  16937. */
  16938. size: number;
  16939. /**
  16940. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16941. */
  16942. side: number;
  16943. /**
  16944. * Creates a box geometry
  16945. * @param id defines the unique ID of the geometry
  16946. * @param scene defines the hosting scene
  16947. * @param size defines the zise of the box (width, height and depth are the same)
  16948. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16949. * @param mesh defines the hosting mesh (can be null)
  16950. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16951. */
  16952. constructor(id: string, scene: Scene,
  16953. /**
  16954. * Defines the zise of the box (width, height and depth are the same)
  16955. */
  16956. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  16957. /**
  16958. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16959. */
  16960. side?: number);
  16961. /** @hidden */
  16962. _regenerateVertexData(): VertexData;
  16963. copy(id: string): Geometry;
  16964. serialize(): any;
  16965. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  16966. }
  16967. /**
  16968. * Creates a sphere geometry
  16969. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  16970. */
  16971. class SphereGeometry extends _PrimitiveGeometry {
  16972. /**
  16973. * Defines the number of segments to use to create the sphere
  16974. */
  16975. segments: number;
  16976. /**
  16977. * Defines the diameter of the sphere
  16978. */
  16979. diameter: number;
  16980. /**
  16981. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16982. */
  16983. side: number;
  16984. /**
  16985. * Create a new sphere geometry
  16986. * @param id defines the unique ID of the geometry
  16987. * @param scene defines the hosting scene
  16988. * @param segments defines the number of segments to use to create the sphere
  16989. * @param diameter defines the diameter of the sphere
  16990. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16991. * @param mesh defines the hosting mesh (can be null)
  16992. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16993. */
  16994. constructor(id: string, scene: Scene,
  16995. /**
  16996. * Defines the number of segments to use to create the sphere
  16997. */
  16998. segments: number,
  16999. /**
  17000. * Defines the diameter of the sphere
  17001. */
  17002. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  17003. /**
  17004. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17005. */
  17006. side?: number);
  17007. /** @hidden */
  17008. _regenerateVertexData(): VertexData;
  17009. copy(id: string): Geometry;
  17010. serialize(): any;
  17011. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  17012. }
  17013. /**
  17014. * Creates a disc geometry
  17015. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  17016. */
  17017. class DiscGeometry extends _PrimitiveGeometry {
  17018. /**
  17019. * Defines the radius of the disc
  17020. */
  17021. radius: number;
  17022. /**
  17023. * Defines the tesselation factor to apply to the disc
  17024. */
  17025. tessellation: number;
  17026. /**
  17027. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17028. */
  17029. side: number;
  17030. /**
  17031. * Creates a new disc geometry
  17032. * @param id defines the unique ID of the geometry
  17033. * @param scene defines the hosting scene
  17034. * @param radius defines the radius of the disc
  17035. * @param tessellation defines the tesselation factor to apply to the disc
  17036. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  17037. * @param mesh defines the hosting mesh (can be null)
  17038. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17039. */
  17040. constructor(id: string, scene: Scene,
  17041. /**
  17042. * Defines the radius of the disc
  17043. */
  17044. radius: number,
  17045. /**
  17046. * Defines the tesselation factor to apply to the disc
  17047. */
  17048. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  17049. /**
  17050. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17051. */
  17052. side?: number);
  17053. /** @hidden */
  17054. _regenerateVertexData(): VertexData;
  17055. copy(id: string): Geometry;
  17056. }
  17057. /**
  17058. * Creates a new cylinder geometry
  17059. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  17060. */
  17061. class CylinderGeometry extends _PrimitiveGeometry {
  17062. /**
  17063. * Defines the height of the cylinder
  17064. */
  17065. height: number;
  17066. /**
  17067. * Defines the diameter of the cylinder's top cap
  17068. */
  17069. diameterTop: number;
  17070. /**
  17071. * Defines the diameter of the cylinder's bottom cap
  17072. */
  17073. diameterBottom: number;
  17074. /**
  17075. * Defines the tessellation factor to apply to the cylinder
  17076. */
  17077. tessellation: number;
  17078. /**
  17079. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  17080. */
  17081. subdivisions: number;
  17082. /**
  17083. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17084. */
  17085. side: number;
  17086. /**
  17087. * Creates a new cylinder geometry
  17088. * @param id defines the unique ID of the geometry
  17089. * @param scene defines the hosting scene
  17090. * @param height defines the height of the cylinder
  17091. * @param diameterTop defines the diameter of the cylinder's top cap
  17092. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  17093. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  17094. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  17095. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  17096. * @param mesh defines the hosting mesh (can be null)
  17097. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17098. */
  17099. constructor(id: string, scene: Scene,
  17100. /**
  17101. * Defines the height of the cylinder
  17102. */
  17103. height: number,
  17104. /**
  17105. * Defines the diameter of the cylinder's top cap
  17106. */
  17107. diameterTop: number,
  17108. /**
  17109. * Defines the diameter of the cylinder's bottom cap
  17110. */
  17111. diameterBottom: number,
  17112. /**
  17113. * Defines the tessellation factor to apply to the cylinder
  17114. */
  17115. tessellation: number,
  17116. /**
  17117. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  17118. */
  17119. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  17120. /**
  17121. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17122. */
  17123. side?: number);
  17124. /** @hidden */
  17125. _regenerateVertexData(): VertexData;
  17126. copy(id: string): Geometry;
  17127. serialize(): any;
  17128. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  17129. }
  17130. /**
  17131. * Creates a new torus geometry
  17132. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  17133. */
  17134. class TorusGeometry extends _PrimitiveGeometry {
  17135. /**
  17136. * Defines the diameter of the torus
  17137. */
  17138. diameter: number;
  17139. /**
  17140. * Defines the thickness of the torus (ie. internal diameter)
  17141. */
  17142. thickness: number;
  17143. /**
  17144. * Defines the tesselation factor to apply to the torus
  17145. */
  17146. tessellation: number;
  17147. /**
  17148. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17149. */
  17150. side: number;
  17151. /**
  17152. * Creates a new torus geometry
  17153. * @param id defines the unique ID of the geometry
  17154. * @param scene defines the hosting scene
  17155. * @param diameter defines the diameter of the torus
  17156. * @param thickness defines the thickness of the torus (ie. internal diameter)
  17157. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  17158. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  17159. * @param mesh defines the hosting mesh (can be null)
  17160. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17161. */
  17162. constructor(id: string, scene: Scene,
  17163. /**
  17164. * Defines the diameter of the torus
  17165. */
  17166. diameter: number,
  17167. /**
  17168. * Defines the thickness of the torus (ie. internal diameter)
  17169. */
  17170. thickness: number,
  17171. /**
  17172. * Defines the tesselation factor to apply to the torus
  17173. */
  17174. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  17175. /**
  17176. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17177. */
  17178. side?: number);
  17179. /** @hidden */
  17180. _regenerateVertexData(): VertexData;
  17181. copy(id: string): Geometry;
  17182. serialize(): any;
  17183. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  17184. }
  17185. /**
  17186. * Creates a new ground geometry
  17187. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  17188. */
  17189. class GroundGeometry extends _PrimitiveGeometry {
  17190. /**
  17191. * Defines the width of the ground
  17192. */
  17193. width: number;
  17194. /**
  17195. * Defines the height of the ground
  17196. */
  17197. height: number;
  17198. /**
  17199. * Defines the subdivisions to apply to the ground
  17200. */
  17201. subdivisions: number;
  17202. /**
  17203. * Creates a new ground geometry
  17204. * @param id defines the unique ID of the geometry
  17205. * @param scene defines the hosting scene
  17206. * @param width defines the width of the ground
  17207. * @param height defines the height of the ground
  17208. * @param subdivisions defines the subdivisions to apply to the ground
  17209. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  17210. * @param mesh defines the hosting mesh (can be null)
  17211. */
  17212. constructor(id: string, scene: Scene,
  17213. /**
  17214. * Defines the width of the ground
  17215. */
  17216. width: number,
  17217. /**
  17218. * Defines the height of the ground
  17219. */
  17220. height: number,
  17221. /**
  17222. * Defines the subdivisions to apply to the ground
  17223. */
  17224. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  17225. /** @hidden */
  17226. _regenerateVertexData(): VertexData;
  17227. copy(id: string): Geometry;
  17228. serialize(): any;
  17229. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  17230. }
  17231. /**
  17232. * Creates a tiled ground geometry
  17233. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  17234. */
  17235. class TiledGroundGeometry extends _PrimitiveGeometry {
  17236. /**
  17237. * Defines the minimum value on X axis
  17238. */
  17239. xmin: number;
  17240. /**
  17241. * Defines the minimum value on Z axis
  17242. */
  17243. zmin: number;
  17244. /**
  17245. * Defines the maximum value on X axis
  17246. */
  17247. xmax: number;
  17248. /**
  17249. * Defines the maximum value on Z axis
  17250. */
  17251. zmax: number;
  17252. /**
  17253. * Defines the subdivisions to apply to the ground
  17254. */
  17255. subdivisions: {
  17256. w: number;
  17257. h: number;
  17258. };
  17259. /**
  17260. * Defines the precision to use when computing the tiles
  17261. */
  17262. precision: {
  17263. w: number;
  17264. h: number;
  17265. };
  17266. /**
  17267. * Creates a tiled ground geometry
  17268. * @param id defines the unique ID of the geometry
  17269. * @param scene defines the hosting scene
  17270. * @param xmin defines the minimum value on X axis
  17271. * @param zmin defines the minimum value on Z axis
  17272. * @param xmax defines the maximum value on X axis
  17273. * @param zmax defines the maximum value on Z axis
  17274. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  17275. * @param precision defines the precision to use when computing the tiles
  17276. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  17277. * @param mesh defines the hosting mesh (can be null)
  17278. */
  17279. constructor(id: string, scene: Scene,
  17280. /**
  17281. * Defines the minimum value on X axis
  17282. */
  17283. xmin: number,
  17284. /**
  17285. * Defines the minimum value on Z axis
  17286. */
  17287. zmin: number,
  17288. /**
  17289. * Defines the maximum value on X axis
  17290. */
  17291. xmax: number,
  17292. /**
  17293. * Defines the maximum value on Z axis
  17294. */
  17295. zmax: number,
  17296. /**
  17297. * Defines the subdivisions to apply to the ground
  17298. */
  17299. subdivisions: {
  17300. w: number;
  17301. h: number;
  17302. },
  17303. /**
  17304. * Defines the precision to use when computing the tiles
  17305. */
  17306. precision: {
  17307. w: number;
  17308. h: number;
  17309. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  17310. /** @hidden */
  17311. _regenerateVertexData(): VertexData;
  17312. copy(id: string): Geometry;
  17313. }
  17314. /**
  17315. * Creates a plane geometry
  17316. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  17317. */
  17318. class PlaneGeometry extends _PrimitiveGeometry {
  17319. /**
  17320. * Defines the size of the plane (width === height)
  17321. */
  17322. size: number;
  17323. /**
  17324. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17325. */
  17326. side: number;
  17327. /**
  17328. * Creates a plane geometry
  17329. * @param id defines the unique ID of the geometry
  17330. * @param scene defines the hosting scene
  17331. * @param size defines the size of the plane (width === height)
  17332. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  17333. * @param mesh defines the hosting mesh (can be null)
  17334. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17335. */
  17336. constructor(id: string, scene: Scene,
  17337. /**
  17338. * Defines the size of the plane (width === height)
  17339. */
  17340. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  17341. /**
  17342. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17343. */
  17344. side?: number);
  17345. /** @hidden */
  17346. _regenerateVertexData(): VertexData;
  17347. copy(id: string): Geometry;
  17348. serialize(): any;
  17349. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  17350. }
  17351. /**
  17352. * Creates a torus knot geometry
  17353. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  17354. */
  17355. class TorusKnotGeometry extends _PrimitiveGeometry {
  17356. /**
  17357. * Defines the radius of the torus knot
  17358. */
  17359. radius: number;
  17360. /**
  17361. * Defines the thickness of the torus knot tube
  17362. */
  17363. tube: number;
  17364. /**
  17365. * Defines the number of radial segments
  17366. */
  17367. radialSegments: number;
  17368. /**
  17369. * Defines the number of tubular segments
  17370. */
  17371. tubularSegments: number;
  17372. /**
  17373. * Defines the first number of windings
  17374. */
  17375. p: number;
  17376. /**
  17377. * Defines the second number of windings
  17378. */
  17379. q: number;
  17380. /**
  17381. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17382. */
  17383. side: number;
  17384. /**
  17385. * Creates a torus knot geometry
  17386. * @param id defines the unique ID of the geometry
  17387. * @param scene defines the hosting scene
  17388. * @param radius defines the radius of the torus knot
  17389. * @param tube defines the thickness of the torus knot tube
  17390. * @param radialSegments defines the number of radial segments
  17391. * @param tubularSegments defines the number of tubular segments
  17392. * @param p defines the first number of windings
  17393. * @param q defines the second number of windings
  17394. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  17395. * @param mesh defines the hosting mesh (can be null)
  17396. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17397. */
  17398. constructor(id: string, scene: Scene,
  17399. /**
  17400. * Defines the radius of the torus knot
  17401. */
  17402. radius: number,
  17403. /**
  17404. * Defines the thickness of the torus knot tube
  17405. */
  17406. tube: number,
  17407. /**
  17408. * Defines the number of radial segments
  17409. */
  17410. radialSegments: number,
  17411. /**
  17412. * Defines the number of tubular segments
  17413. */
  17414. tubularSegments: number,
  17415. /**
  17416. * Defines the first number of windings
  17417. */
  17418. p: number,
  17419. /**
  17420. * Defines the second number of windings
  17421. */
  17422. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  17423. /**
  17424. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  17425. */
  17426. side?: number);
  17427. /** @hidden */
  17428. _regenerateVertexData(): VertexData;
  17429. copy(id: string): Geometry;
  17430. serialize(): any;
  17431. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  17432. }
  17433. }
  17434. declare module BABYLON {
  17435. class GroundMesh extends Mesh {
  17436. generateOctree: boolean;
  17437. private _heightQuads;
  17438. /** @hidden */
  17439. _subdivisionsX: number;
  17440. /** @hidden */
  17441. _subdivisionsY: number;
  17442. /** @hidden */
  17443. _width: number;
  17444. /** @hidden */
  17445. _height: number;
  17446. /** @hidden */
  17447. _minX: number;
  17448. /** @hidden */
  17449. _maxX: number;
  17450. /** @hidden */
  17451. _minZ: number;
  17452. /** @hidden */
  17453. _maxZ: number;
  17454. constructor(name: string, scene: Scene);
  17455. getClassName(): string;
  17456. readonly subdivisions: number;
  17457. readonly subdivisionsX: number;
  17458. readonly subdivisionsY: number;
  17459. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  17460. /**
  17461. * Returns a height (y) value in the Worl system :
  17462. * the ground altitude at the coordinates (x, z) expressed in the World system.
  17463. * Returns the ground y position if (x, z) are outside the ground surface.
  17464. */
  17465. getHeightAtCoordinates(x: number, z: number): number;
  17466. /**
  17467. * Returns a normalized vector (Vector3) orthogonal to the ground
  17468. * at the ground coordinates (x, z) expressed in the World system.
  17469. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  17470. */
  17471. getNormalAtCoordinates(x: number, z: number): Vector3;
  17472. /**
  17473. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  17474. * at the ground coordinates (x, z) expressed in the World system.
  17475. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  17476. * Returns the GroundMesh.
  17477. */
  17478. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  17479. /**
  17480. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  17481. * if the ground has been updated.
  17482. * This can be used in the render loop.
  17483. * Returns the GroundMesh.
  17484. */
  17485. updateCoordinateHeights(): GroundMesh;
  17486. private _getFacetAt;
  17487. private _initHeightQuads;
  17488. private _computeHeightQuads;
  17489. serialize(serializationObject: any): void;
  17490. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  17491. }
  17492. }
  17493. declare module BABYLON {
  17494. /**
  17495. * Creates an instance based on a source mesh.
  17496. */
  17497. class InstancedMesh extends AbstractMesh {
  17498. private _sourceMesh;
  17499. private _currentLOD;
  17500. constructor(name: string, source: Mesh);
  17501. /**
  17502. * Returns the string "InstancedMesh".
  17503. */
  17504. getClassName(): string;
  17505. readonly receiveShadows: boolean;
  17506. readonly material: Nullable<Material>;
  17507. readonly visibility: number;
  17508. readonly skeleton: Nullable<Skeleton>;
  17509. renderingGroupId: number;
  17510. /**
  17511. * Returns the total number of vertices (integer).
  17512. */
  17513. getTotalVertices(): number;
  17514. readonly sourceMesh: Mesh;
  17515. /**
  17516. * Is this node ready to be used/rendered
  17517. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17518. * @return {boolean} is it ready
  17519. */
  17520. isReady(completeCheck?: boolean): boolean;
  17521. /**
  17522. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  17523. */
  17524. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  17525. /**
  17526. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17527. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17528. * The `data` are either a numeric array either a Float32Array.
  17529. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17530. * 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).
  17531. * Note that a new underlying VertexBuffer object is created each call.
  17532. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17533. *
  17534. * Possible `kind` values :
  17535. * - BABYLON.VertexBuffer.PositionKind
  17536. * - BABYLON.VertexBuffer.UVKind
  17537. * - BABYLON.VertexBuffer.UV2Kind
  17538. * - BABYLON.VertexBuffer.UV3Kind
  17539. * - BABYLON.VertexBuffer.UV4Kind
  17540. * - BABYLON.VertexBuffer.UV5Kind
  17541. * - BABYLON.VertexBuffer.UV6Kind
  17542. * - BABYLON.VertexBuffer.ColorKind
  17543. * - BABYLON.VertexBuffer.MatricesIndicesKind
  17544. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  17545. * - BABYLON.VertexBuffer.MatricesWeightsKind
  17546. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  17547. *
  17548. * Returns the Mesh.
  17549. */
  17550. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17551. /**
  17552. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17553. * If the mesh has no geometry, it is simply returned as it is.
  17554. * The `data` are either a numeric array either a Float32Array.
  17555. * No new underlying VertexBuffer object is created.
  17556. * 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.
  17557. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17558. *
  17559. * Possible `kind` values :
  17560. * - BABYLON.VertexBuffer.PositionKind
  17561. * - BABYLON.VertexBuffer.UVKind
  17562. * - BABYLON.VertexBuffer.UV2Kind
  17563. * - BABYLON.VertexBuffer.UV3Kind
  17564. * - BABYLON.VertexBuffer.UV4Kind
  17565. * - BABYLON.VertexBuffer.UV5Kind
  17566. * - BABYLON.VertexBuffer.UV6Kind
  17567. * - BABYLON.VertexBuffer.ColorKind
  17568. * - BABYLON.VertexBuffer.MatricesIndicesKind
  17569. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  17570. * - BABYLON.VertexBuffer.MatricesWeightsKind
  17571. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  17572. *
  17573. * Returns the Mesh.
  17574. */
  17575. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17576. /**
  17577. * Sets the mesh indices.
  17578. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17579. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17580. * This method creates a new index buffer each call.
  17581. * Returns the Mesh.
  17582. */
  17583. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  17584. /**
  17585. * Boolean : True if the mesh owns the requested kind of data.
  17586. */
  17587. isVerticesDataPresent(kind: string): boolean;
  17588. /**
  17589. * Returns an array of indices (IndicesArray).
  17590. */
  17591. getIndices(): Nullable<IndicesArray>;
  17592. readonly _positions: Nullable<Vector3[]>;
  17593. /**
  17594. * Sets a new updated BoundingInfo to the mesh.
  17595. * Returns the mesh.
  17596. */
  17597. refreshBoundingInfo(): InstancedMesh;
  17598. /** @hidden */
  17599. _preActivate(): InstancedMesh;
  17600. /** @hidden */
  17601. _activate(renderId: number): InstancedMesh;
  17602. /**
  17603. * Returns the current associated LOD AbstractMesh.
  17604. */
  17605. getLOD(camera: Camera): AbstractMesh;
  17606. /** @hidden */
  17607. _syncSubMeshes(): InstancedMesh;
  17608. /** @hidden */
  17609. _generatePointsArray(): boolean;
  17610. /**
  17611. * Creates a new InstancedMesh from the current mesh.
  17612. * - name (string) : the cloned mesh name
  17613. * - newParent (optional Node) : the optional Node to parent the clone to.
  17614. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17615. *
  17616. * Returns the clone.
  17617. */
  17618. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17619. /**
  17620. * Disposes the InstancedMesh.
  17621. * Returns nothing.
  17622. */
  17623. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17624. }
  17625. }
  17626. declare module BABYLON {
  17627. class LinesMesh extends Mesh {
  17628. useVertexColor?: boolean | undefined;
  17629. useVertexAlpha?: boolean | undefined;
  17630. color: Color3;
  17631. alpha: number;
  17632. /**
  17633. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17634. * This margin is expressed in world space coordinates, so its value may vary.
  17635. * Default value is 0.1
  17636. * @returns the intersection Threshold value.
  17637. */
  17638. /**
  17639. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17640. * This margin is expressed in world space coordinates, so its value may vary.
  17641. * @param value the new threshold to apply
  17642. */
  17643. intersectionThreshold: number;
  17644. private _intersectionThreshold;
  17645. private _colorShader;
  17646. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  17647. /**
  17648. * Returns the string "LineMesh"
  17649. */
  17650. getClassName(): string;
  17651. /**
  17652. * @hidden
  17653. */
  17654. /**
  17655. * @hidden
  17656. */
  17657. material: Material;
  17658. /**
  17659. * @hidden
  17660. */
  17661. readonly checkCollisions: boolean;
  17662. createInstance(name: string): InstancedMesh;
  17663. /** @hidden */
  17664. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17665. /** @hidden */
  17666. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17667. dispose(doNotRecurse?: boolean): void;
  17668. /**
  17669. * Returns a new LineMesh object cloned from the current one.
  17670. */
  17671. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17672. }
  17673. }
  17674. declare module BABYLON {
  17675. /**
  17676. * @hidden
  17677. **/
  17678. class _InstancesBatch {
  17679. mustReturn: boolean;
  17680. visibleInstances: Nullable<InstancedMesh[]>[];
  17681. renderSelf: boolean[];
  17682. }
  17683. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  17684. static _FRONTSIDE: number;
  17685. static _BACKSIDE: number;
  17686. static _DOUBLESIDE: number;
  17687. static _DEFAULTSIDE: number;
  17688. static _NO_CAP: number;
  17689. static _CAP_START: number;
  17690. static _CAP_END: number;
  17691. static _CAP_ALL: number;
  17692. /**
  17693. * Mesh side orientation : usually the external or front surface
  17694. */
  17695. static readonly FRONTSIDE: number;
  17696. /**
  17697. * Mesh side orientation : usually the internal or back surface
  17698. */
  17699. static readonly BACKSIDE: number;
  17700. /**
  17701. * Mesh side orientation : both internal and external or front and back surfaces
  17702. */
  17703. static readonly DOUBLESIDE: number;
  17704. /**
  17705. * Mesh side orientation : by default, `FRONTSIDE`
  17706. */
  17707. static readonly DEFAULTSIDE: number;
  17708. /**
  17709. * Mesh cap setting : no cap
  17710. */
  17711. static readonly NO_CAP: number;
  17712. /**
  17713. * Mesh cap setting : one cap at the beginning of the mesh
  17714. */
  17715. static readonly CAP_START: number;
  17716. /**
  17717. * Mesh cap setting : one cap at the end of the mesh
  17718. */
  17719. static readonly CAP_END: number;
  17720. /**
  17721. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  17722. */
  17723. static readonly CAP_ALL: number;
  17724. private _onBeforeRenderObservable;
  17725. private _onAfterRenderObservable;
  17726. private _onBeforeDrawObservable;
  17727. /**
  17728. * An event triggered before rendering the mesh
  17729. */
  17730. readonly onBeforeRenderObservable: Observable<Mesh>;
  17731. /**
  17732. * An event triggered after rendering the mesh
  17733. */
  17734. readonly onAfterRenderObservable: Observable<Mesh>;
  17735. /**
  17736. * An event triggered before drawing the mesh
  17737. */
  17738. readonly onBeforeDrawObservable: Observable<Mesh>;
  17739. private _onBeforeDrawObserver;
  17740. onBeforeDraw: () => void;
  17741. delayLoadState: number;
  17742. instances: InstancedMesh[];
  17743. delayLoadingFile: string;
  17744. /** @hidden */
  17745. _binaryInfo: any;
  17746. private _LODLevels;
  17747. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  17748. private _morphTargetManager;
  17749. morphTargetManager: Nullable<MorphTargetManager>;
  17750. /** @hidden */
  17751. _geometry: Nullable<Geometry>;
  17752. /** @hidden */
  17753. _delayInfo: Array<string>;
  17754. /** @hidden */
  17755. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  17756. /** @hidden */
  17757. _visibleInstances: any;
  17758. private _renderIdForInstances;
  17759. private _batchCache;
  17760. private _instancesBufferSize;
  17761. private _instancesBuffer;
  17762. private _instancesData;
  17763. private _overridenInstanceCount;
  17764. private _effectiveMaterial;
  17765. /** @hidden */
  17766. _shouldGenerateFlatShading: boolean;
  17767. private _preActivateId;
  17768. /** @hidden */
  17769. _originalBuilderSideOrientation: number;
  17770. overrideMaterialSideOrientation: Nullable<number>;
  17771. private _areNormalsFrozen;
  17772. private _sourcePositions;
  17773. private _sourceNormals;
  17774. private _source;
  17775. readonly source: Nullable<Mesh>;
  17776. isUnIndexed: boolean;
  17777. /**
  17778. * @constructor
  17779. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  17780. * @param {Scene} scene The scene to add this mesh to.
  17781. * @param {Node} parent The parent of this mesh, if it has one
  17782. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  17783. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17784. * When false, achieved by calling a clone(), also passing False.
  17785. * This will make creation of children, recursive.
  17786. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  17787. */
  17788. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  17789. /**
  17790. * Returns the string "Mesh".
  17791. */
  17792. getClassName(): string;
  17793. /**
  17794. * Returns a string.
  17795. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  17796. */
  17797. toString(fullDetails?: boolean): string;
  17798. /** @hidden */
  17799. _unBindEffect(): void;
  17800. /**
  17801. * True if the mesh has some Levels Of Details (LOD).
  17802. * Returns a boolean.
  17803. */
  17804. readonly hasLODLevels: boolean;
  17805. /**
  17806. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  17807. * @returns an array of {BABYLON.MeshLODLevel}
  17808. */
  17809. getLODLevels(): MeshLODLevel[];
  17810. private _sortLODLevels;
  17811. /**
  17812. * Add a mesh as LOD level triggered at the given distance.
  17813. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  17814. * @param distance The distance from the center of the object to show this level
  17815. * @param mesh The mesh to be added as LOD level (can be null)
  17816. * @return This mesh (for chaining)
  17817. */
  17818. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  17819. /**
  17820. * Returns the LOD level mesh at the passed distance or null if not found.
  17821. * It is related to the method `addLODLevel(distance, mesh)`.
  17822. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  17823. * Returns an object Mesh or `null`.
  17824. */
  17825. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  17826. /**
  17827. * Remove a mesh from the LOD array
  17828. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  17829. * @param {Mesh} mesh The mesh to be removed.
  17830. * @return {Mesh} This mesh (for chaining)
  17831. */
  17832. removeLODLevel(mesh: Mesh): Mesh;
  17833. /**
  17834. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  17835. * tuto : http://doc.babylonjs.com/how_to/how_to_use_lod
  17836. */
  17837. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  17838. /**
  17839. * Returns the mesh internal Geometry object.
  17840. */
  17841. readonly geometry: Nullable<Geometry>;
  17842. /**
  17843. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  17844. */
  17845. getTotalVertices(): number;
  17846. /**
  17847. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  17848. * If `copywhenShared` is true (default false) and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  17849. * You can force the copy with forceCopy === true
  17850. * Returns null if the mesh has no geometry or no vertex buffer.
  17851. * Possible `kind` values :
  17852. * - BABYLON.VertexBuffer.PositionKind
  17853. * - BABYLON.VertexBuffer.UVKind
  17854. * - BABYLON.VertexBuffer.UV2Kind
  17855. * - BABYLON.VertexBuffer.UV3Kind
  17856. * - BABYLON.VertexBuffer.UV4Kind
  17857. * - BABYLON.VertexBuffer.UV5Kind
  17858. * - BABYLON.VertexBuffer.UV6Kind
  17859. * - BABYLON.VertexBuffer.ColorKind
  17860. * - BABYLON.VertexBuffer.MatricesIndicesKind
  17861. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  17862. * - BABYLON.VertexBuffer.MatricesWeightsKind
  17863. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  17864. */
  17865. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  17866. /**
  17867. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  17868. * Returns `null` if the mesh has no geometry.
  17869. * Possible `kind` values :
  17870. * - BABYLON.VertexBuffer.PositionKind
  17871. * - BABYLON.VertexBuffer.UVKind
  17872. * - BABYLON.VertexBuffer.UV2Kind
  17873. * - BABYLON.VertexBuffer.UV3Kind
  17874. * - BABYLON.VertexBuffer.UV4Kind
  17875. * - BABYLON.VertexBuffer.UV5Kind
  17876. * - BABYLON.VertexBuffer.UV6Kind
  17877. * - BABYLON.VertexBuffer.ColorKind
  17878. * - BABYLON.VertexBuffer.MatricesIndicesKind
  17879. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  17880. * - BABYLON.VertexBuffer.MatricesWeightsKind
  17881. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  17882. */
  17883. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  17884. isVerticesDataPresent(kind: string): boolean;
  17885. /**
  17886. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  17887. * Possible `kind` values :
  17888. * - BABYLON.VertexBuffer.PositionKind
  17889. * - BABYLON.VertexBuffer.UVKind
  17890. * - BABYLON.VertexBuffer.UV2Kind
  17891. * - BABYLON.VertexBuffer.UV3Kind
  17892. * - BABYLON.VertexBuffer.UV4Kind
  17893. * - BABYLON.VertexBuffer.UV5Kind
  17894. * - BABYLON.VertexBuffer.UV6Kind
  17895. * - BABYLON.VertexBuffer.ColorKind
  17896. * - BABYLON.VertexBuffer.MatricesIndicesKind
  17897. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  17898. * - BABYLON.VertexBuffer.MatricesWeightsKind
  17899. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  17900. */
  17901. isVertexBufferUpdatable(kind: string): boolean;
  17902. /**
  17903. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  17904. * Possible `kind` values :
  17905. * - BABYLON.VertexBuffer.PositionKind
  17906. * - BABYLON.VertexBuffer.UVKind
  17907. * - BABYLON.VertexBuffer.UV2Kind
  17908. * - BABYLON.VertexBuffer.UV3Kind
  17909. * - BABYLON.VertexBuffer.UV4Kind
  17910. * - BABYLON.VertexBuffer.UV5Kind
  17911. * - BABYLON.VertexBuffer.UV6Kind
  17912. * - BABYLON.VertexBuffer.ColorKind
  17913. * - BABYLON.VertexBuffer.MatricesIndicesKind
  17914. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  17915. * - BABYLON.VertexBuffer.MatricesWeightsKind
  17916. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  17917. */
  17918. getVerticesDataKinds(): string[];
  17919. /**
  17920. * Returns a positive integer : the total number of indices in this mesh geometry.
  17921. * Returns zero if the mesh has no geometry.
  17922. */
  17923. getTotalIndices(): number;
  17924. /**
  17925. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  17926. * If the parameter `copyWhenShared` is 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.
  17927. * Returns an empty array if the mesh has no geometry.
  17928. */
  17929. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  17930. readonly isBlocked: boolean;
  17931. /**
  17932. * Determine if the current mesh is ready to be rendered
  17933. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17934. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  17935. * @returns true if all associated assets are ready (material, textures, shaders)
  17936. */
  17937. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  17938. /**
  17939. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  17940. * This property is pertinent only for updatable parametric shapes.
  17941. */
  17942. readonly areNormalsFrozen: boolean;
  17943. /**
  17944. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  17945. * It has no effect at all on other shapes.
  17946. * It prevents the mesh normals from being recomputed on next `positions` array update.
  17947. * Returns the Mesh.
  17948. */
  17949. freezeNormals(): Mesh;
  17950. /**
  17951. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  17952. * It has no effect at all on other shapes.
  17953. * It reactivates the mesh normals computation if it was previously frozen.
  17954. * Returns the Mesh.
  17955. */
  17956. unfreezeNormals(): Mesh;
  17957. /**
  17958. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  17959. */
  17960. overridenInstanceCount: number;
  17961. /** @hidden */
  17962. _preActivate(): Mesh;
  17963. /** @hidden */
  17964. _preActivateForIntermediateRendering(renderId: number): Mesh;
  17965. /** @hidden */
  17966. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  17967. /**
  17968. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17969. * This means the mesh underlying bounding box and sphere are recomputed.
  17970. * Returns the Mesh.
  17971. */
  17972. refreshBoundingInfo(): Mesh;
  17973. /** @hidden */
  17974. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  17975. private _getPositionData;
  17976. /** @hidden */
  17977. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  17978. subdivide(count: number): void;
  17979. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17980. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  17981. /**
  17982. * Sets the mesh VertexBuffer.
  17983. * Returns the Mesh.
  17984. */
  17985. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  17986. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17987. /**
  17988. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  17989. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  17990. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  17991. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  17992. * Returns the Mesh.
  17993. */
  17994. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  17995. /**
  17996. * Creates a un-shared specific occurence of the geometry for the mesh.
  17997. * Returns the Mesh.
  17998. */
  17999. makeGeometryUnique(): Mesh;
  18000. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  18001. /**
  18002. * Update the current index buffer
  18003. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  18004. * Returns the Mesh.
  18005. */
  18006. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  18007. /**
  18008. * Invert the geometry to move from a right handed system to a left handed one.
  18009. * Returns the Mesh.
  18010. */
  18011. toLeftHanded(): Mesh;
  18012. /** @hidden */
  18013. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  18014. /** @hidden */
  18015. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  18016. /**
  18017. * Registers for this mesh a javascript function called just before the rendering process.
  18018. * This function is passed the current mesh.
  18019. * Return the Mesh.
  18020. */
  18021. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  18022. /**
  18023. * Disposes a previously registered javascript function called before the rendering.
  18024. * This function is passed the current mesh.
  18025. * Returns the Mesh.
  18026. */
  18027. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  18028. /**
  18029. * Registers for this mesh a javascript function called just after the rendering is complete.
  18030. * This function is passed the current mesh.
  18031. * Returns the Mesh.
  18032. */
  18033. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  18034. /**
  18035. * Disposes a previously registered javascript function called after the rendering.
  18036. * This function is passed the current mesh.
  18037. * Return the Mesh.
  18038. */
  18039. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  18040. /** @hidden */
  18041. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  18042. /** @hidden */
  18043. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  18044. /** @hidden */
  18045. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  18046. /**
  18047. * 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
  18048. * @param subMesh defines the subMesh to render
  18049. * @param enableAlphaMode defines if alpha mode can be changed
  18050. * @returns the current mesh
  18051. */
  18052. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  18053. private _onBeforeDraw;
  18054. /**
  18055. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter.
  18056. */
  18057. getEmittedParticleSystems(): IParticleSystem[];
  18058. /**
  18059. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter.
  18060. */
  18061. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  18062. /**
  18063. * Normalize matrix weights so that all vertices have a total weight set to 1
  18064. */
  18065. cleanMatrixWeights(): void;
  18066. /** @hidden */
  18067. _checkDelayState(): Mesh;
  18068. private _queueLoad;
  18069. /**
  18070. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  18071. */
  18072. isInFrustum(frustumPlanes: Plane[]): boolean;
  18073. /**
  18074. * Sets the mesh material by the material or multiMaterial `id` property.
  18075. * The material `id` is a string identifying the material or the multiMaterial.
  18076. * This method returns the Mesh.
  18077. */
  18078. setMaterialByID(id: string): Mesh;
  18079. /**
  18080. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  18081. */
  18082. getAnimatables(): IAnimatable[];
  18083. /**
  18084. * Modifies the mesh geometry according to the passed transformation matrix.
  18085. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  18086. * The mesh normals are modified accordingly the same transformation.
  18087. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  18088. * Note that, under the hood, this method sets a new VertexBuffer each call.
  18089. * Returns the Mesh.
  18090. */
  18091. bakeTransformIntoVertices(transform: Matrix): Mesh;
  18092. /**
  18093. * Modifies the mesh geometry according to its own current World Matrix.
  18094. * The mesh World Matrix is then reset.
  18095. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  18096. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  18097. * Note that, under the hood, this method sets a new VertexBuffer each call.
  18098. * Returns the Mesh.
  18099. */
  18100. bakeCurrentTransformIntoVertices(): Mesh;
  18101. readonly _positions: Nullable<Vector3[]>;
  18102. /** @hidden */
  18103. _resetPointsArrayCache(): Mesh;
  18104. /** @hidden */
  18105. _generatePointsArray(): boolean;
  18106. /**
  18107. * Returns a new Mesh object generated from the current mesh properties.
  18108. * This method must not get confused with createInstance().
  18109. * The parameter `name` is a string, the name given to the new mesh.
  18110. * The optional parameter `newParent` can be any Node object (default `null`).
  18111. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  18112. * The parameter `clonePhysicsImpostor` (default `true`) allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any.
  18113. */
  18114. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  18115. /**
  18116. * Releases resources associated with this mesh.
  18117. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18118. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18119. */
  18120. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18121. /**
  18122. * Modifies the mesh geometry according to a displacement map.
  18123. * 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.
  18124. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  18125. * This method returns nothing.
  18126. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  18127. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  18128. * The parameter `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.
  18129. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  18130. * The parameter `uvScale` is an optional vector2 used to scale UV.
  18131. *
  18132. * Returns the Mesh.
  18133. */
  18134. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  18135. /**
  18136. * Modifies the mesh geometry according to a displacementMap buffer.
  18137. * 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.
  18138. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  18139. * This method returns nothing.
  18140. * The parameter `buffer` is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  18141. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  18142. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  18143. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  18144. * The parameter `uvScale` is an optional vector2 used to scale UV.
  18145. *
  18146. * Returns the Mesh.
  18147. */
  18148. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  18149. /**
  18150. * Modify the mesh to get a flat shading rendering.
  18151. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  18152. * This method returns the Mesh.
  18153. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  18154. */
  18155. convertToFlatShadedMesh(): Mesh;
  18156. /**
  18157. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  18158. * In other words, more vertices, no more indices and a single bigger VBO.
  18159. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  18160. * Returns the Mesh.
  18161. */
  18162. convertToUnIndexedMesh(): Mesh;
  18163. /**
  18164. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  18165. * This method returns the Mesh.
  18166. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  18167. */
  18168. flipFaces(flipNormals?: boolean): Mesh;
  18169. /**
  18170. * Creates a new InstancedMesh object from the mesh model.
  18171. * An instance shares the same properties and the same material than its model.
  18172. * Only these properties of each instance can then be set individually :
  18173. * - position
  18174. * - rotation
  18175. * - rotationQuaternion
  18176. * - setPivotMatrix
  18177. * - scaling
  18178. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  18179. * Warning : this method is not supported for Line mesh and LineSystem
  18180. */
  18181. createInstance(name: string): InstancedMesh;
  18182. /**
  18183. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  18184. * After this call, all the mesh instances have the same submeshes than the current mesh.
  18185. * This method returns the Mesh.
  18186. */
  18187. synchronizeInstances(): Mesh;
  18188. /**
  18189. * Simplify the mesh according to the given array of settings.
  18190. * Function will return immediately and will simplify async. It returns the Mesh.
  18191. * @param settings a collection of simplification settings.
  18192. * @param parallelProcessing should all levels calculate parallel or one after the other.
  18193. * @param type the type of simplification to run.
  18194. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  18195. */
  18196. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  18197. /**
  18198. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  18199. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  18200. * This should be used together with the simplification to avoid disappearing triangles.
  18201. * Returns the Mesh.
  18202. * @param successCallback an optional success callback to be called after the optimization finished.
  18203. */
  18204. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  18205. serialize(serializationObject: any): void;
  18206. /** @hidden */
  18207. _syncGeometryWithMorphTargetManager(): void;
  18208. /**
  18209. * Returns a new Mesh object parsed from the source provided.
  18210. * The parameter `parsedMesh` is the source.
  18211. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  18212. */
  18213. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  18214. /**
  18215. * Creates a ribbon mesh.
  18216. * Please consider using the same method from the MeshBuilder class instead.
  18217. * The ribbon is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  18218. *
  18219. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  18220. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  18221. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  18222. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  18223. * 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.
  18224. * It's the offset to join together the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11.
  18225. * 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
  18226. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18227. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  18228. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18229. */
  18230. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  18231. /**
  18232. * Creates a plane polygonal mesh. By default, this is a disc.
  18233. * Please consider using the same method from the MeshBuilder class instead.
  18234. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  18235. * 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.
  18236. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18237. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  18238. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18239. */
  18240. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  18241. /**
  18242. * Creates a box mesh.
  18243. * Please consider using the same method from the MeshBuilder class instead.
  18244. * The parameter `size` sets the size (float) of each box side (default 1).
  18245. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18246. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  18247. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18248. */
  18249. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  18250. /**
  18251. * Creates a sphere mesh.
  18252. * Please consider using the same method from the MeshBuilder class instead.
  18253. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  18254. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  18255. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18256. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  18257. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18258. */
  18259. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  18260. /**
  18261. * Creates a cylinder or a cone mesh.
  18262. * Please consider using the same method from the MeshBuilder class instead.
  18263. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  18264. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  18265. * 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.
  18266. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  18267. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  18268. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18269. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  18270. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18271. */
  18272. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  18273. /**
  18274. * Creates a torus mesh.
  18275. * Please consider using the same method from the MeshBuilder class instead.
  18276. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  18277. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  18278. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  18279. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18280. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  18281. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18282. */
  18283. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  18284. /**
  18285. * Creates a torus knot mesh.
  18286. * Please consider using the same method from the MeshBuilder class instead.
  18287. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  18288. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  18289. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  18290. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  18291. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18292. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  18293. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18294. */
  18295. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  18296. /**
  18297. * Creates a line mesh.
  18298. * Please consider using the same method from the MeshBuilder class instead.
  18299. * 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.
  18300. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  18301. * The parameter `points` is an array successive Vector3.
  18302. * 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
  18303. * When updating an instance, remember that only point positions can change, not the number of points.
  18304. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18305. */
  18306. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  18307. /**
  18308. * Creates a dashed line mesh.
  18309. * Please consider using the same method from the MeshBuilder class instead.
  18310. * 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.
  18311. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  18312. * The parameter `points` is an array successive Vector3.
  18313. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  18314. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  18315. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  18316. * 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
  18317. * When updating an instance, remember that only point positions can change, not the number of points.
  18318. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18319. */
  18320. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  18321. /**
  18322. * Creates a polygon mesh.
  18323. * Please consider using the same method from the MeshBuilder class instead.
  18324. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  18325. * 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.
  18326. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18327. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18328. * Remember you can only change the shape positions, not their number when updating a polygon.
  18329. */
  18330. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  18331. /**
  18332. * Creates an extruded polygon mesh, with depth in the Y direction.
  18333. * Please consider using the same method from the MeshBuilder class instead.
  18334. */
  18335. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  18336. /**
  18337. * Creates an extruded shape mesh.
  18338. * The extrusion is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  18339. * Please consider using the same method from the MeshBuilder class instead.
  18340. *
  18341. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  18342. * 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
  18343. * extruded along the Z axis.
  18344. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  18345. * 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.
  18346. * The parameter `scale` (float, default 1) is the value to scale the shape.
  18347. * 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
  18348. * 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
  18349. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  18350. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18351. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  18352. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18353. */
  18354. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  18355. /**
  18356. * Creates an custom extruded shape mesh.
  18357. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  18358. * Please consider using the same method from the MeshBuilder class instead.
  18359. *
  18360. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  18361. * 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
  18362. * extruded along the Z axis.
  18363. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  18364. * 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
  18365. * and the distance of this point from the begining of the path :
  18366. * ```javascript
  18367. * var rotationFunction = function(i, distance) {
  18368. * // do things
  18369. * return rotationValue; }
  18370. * ```
  18371. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  18372. * 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
  18373. * and the distance of this point from the begining of the path :
  18374. * ```javascript
  18375. * var scaleFunction = function(i, distance) {
  18376. * // do things
  18377. * return scaleValue;}
  18378. * ```
  18379. * It must returns a float value that will be the scale value applied to the shape on each path point.
  18380. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  18381. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  18382. * 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
  18383. * 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
  18384. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  18385. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18386. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  18387. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18388. */
  18389. 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;
  18390. /**
  18391. * Creates lathe mesh.
  18392. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  18393. * Please consider using the same method from the MeshBuilder class instead.
  18394. * 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
  18395. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  18396. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  18397. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  18398. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18399. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  18400. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18401. */
  18402. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  18403. /**
  18404. * Creates a plane mesh.
  18405. * Please consider using the same method from the MeshBuilder class instead.
  18406. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  18407. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18408. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  18409. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18410. */
  18411. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  18412. /**
  18413. * Creates a ground mesh.
  18414. * Please consider using the same method from the MeshBuilder class instead.
  18415. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  18416. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  18417. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18418. */
  18419. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  18420. /**
  18421. * Creates a tiled ground mesh.
  18422. * Please consider using the same method from the MeshBuilder class instead.
  18423. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  18424. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  18425. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  18426. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  18427. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  18428. * numbers of subdivisions on the ground width and height of each tile.
  18429. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18430. */
  18431. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  18432. w: number;
  18433. h: number;
  18434. }, precision: {
  18435. w: number;
  18436. h: number;
  18437. }, scene: Scene, updatable?: boolean): Mesh;
  18438. /**
  18439. * Creates a ground mesh from a height map.
  18440. * tuto : http://doc.babylonjs.com/babylon101/height_map
  18441. * Please consider using the same method from the MeshBuilder class instead.
  18442. * The parameter `url` sets the URL of the height map image resource.
  18443. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  18444. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  18445. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  18446. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  18447. * 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).
  18448. * This function is passed the newly built mesh :
  18449. * ```javascript
  18450. * function(mesh) { // do things
  18451. * return; }
  18452. * ```
  18453. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18454. */
  18455. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void): GroundMesh;
  18456. /**
  18457. * Creates a tube mesh.
  18458. * The tube is a parametric shape : http://doc.babylonjs.com/how_to/parametric_shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  18459. * Please consider using the same method from the MeshBuilder class instead.
  18460. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  18461. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  18462. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  18463. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  18464. * 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.
  18465. * It must return a radius value (positive float) :
  18466. * ```javascript
  18467. * var radiusFunction = function(i, distance) {
  18468. * // do things
  18469. * return radius; }
  18470. * ```
  18471. * 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
  18472. * 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
  18473. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18474. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  18475. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18476. */
  18477. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  18478. (i: number, distance: number): number;
  18479. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  18480. /**
  18481. * Creates a polyhedron mesh.
  18482. * Please consider using the same method from the MeshBuilder class instead.
  18483. * 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
  18484. * to choose the wanted type.
  18485. * The parameter `size` (positive float, default 1) sets the polygon size.
  18486. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  18487. * 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`.
  18488. * 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
  18489. * 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)`).
  18490. * 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
  18491. * 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.
  18492. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18493. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  18494. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18495. */
  18496. static CreatePolyhedron(name: string, options: {
  18497. type?: number;
  18498. size?: number;
  18499. sizeX?: number;
  18500. sizeY?: number;
  18501. sizeZ?: number;
  18502. custom?: any;
  18503. faceUV?: Vector4[];
  18504. faceColors?: Color4[];
  18505. updatable?: boolean;
  18506. sideOrientation?: number;
  18507. }, scene: Scene): Mesh;
  18508. /**
  18509. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  18510. * Please consider using the same method from the MeshBuilder class instead.
  18511. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  18512. * 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`).
  18513. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  18514. * 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.
  18515. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18516. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  18517. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18518. */
  18519. static CreateIcoSphere(name: string, options: {
  18520. radius?: number;
  18521. flat?: boolean;
  18522. subdivisions?: number;
  18523. sideOrientation?: number;
  18524. updatable?: boolean;
  18525. }, scene: Scene): Mesh;
  18526. /**
  18527. * Creates a decal mesh.
  18528. * Please consider using the same method from the MeshBuilder class instead.
  18529. * 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.
  18530. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  18531. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  18532. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  18533. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  18534. */
  18535. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  18536. /**
  18537. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  18538. */
  18539. setPositionsForCPUSkinning(): Float32Array;
  18540. /**
  18541. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  18542. */
  18543. setNormalsForCPUSkinning(): Float32Array;
  18544. /**
  18545. * Updates the vertex buffer by applying transformation from the bones.
  18546. * Returns the Mesh.
  18547. *
  18548. * @param {skeleton} skeleton to apply
  18549. */
  18550. applySkeleton(skeleton: Skeleton): Mesh;
  18551. /**
  18552. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  18553. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  18554. */
  18555. static MinMax(meshes: AbstractMesh[]): {
  18556. min: Vector3;
  18557. max: Vector3;
  18558. };
  18559. /**
  18560. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  18561. */
  18562. static Center(meshesOrMinMaxVector: {
  18563. min: Vector3;
  18564. max: Vector3;
  18565. } | AbstractMesh[]): Vector3;
  18566. /**
  18567. * Merge the array of meshes into a single mesh for performance reasons.
  18568. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  18569. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  18570. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  18571. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  18572. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  18573. */
  18574. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  18575. }
  18576. }
  18577. declare module BABYLON {
  18578. /**
  18579. * Define an interface for all classes that will get and set the data on vertices
  18580. */
  18581. interface IGetSetVerticesData {
  18582. isVerticesDataPresent(kind: string): boolean;
  18583. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  18584. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  18585. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  18586. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  18587. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  18588. }
  18589. /**
  18590. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  18591. */
  18592. class VertexData {
  18593. /**
  18594. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  18595. */
  18596. positions: Nullable<FloatArray>;
  18597. /**
  18598. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  18599. */
  18600. normals: Nullable<FloatArray>;
  18601. /**
  18602. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  18603. */
  18604. tangents: Nullable<FloatArray>;
  18605. /**
  18606. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  18607. */
  18608. uvs: Nullable<FloatArray>;
  18609. /**
  18610. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  18611. */
  18612. uvs2: Nullable<FloatArray>;
  18613. /**
  18614. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  18615. */
  18616. uvs3: Nullable<FloatArray>;
  18617. /**
  18618. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  18619. */
  18620. uvs4: Nullable<FloatArray>;
  18621. /**
  18622. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  18623. */
  18624. uvs5: Nullable<FloatArray>;
  18625. /**
  18626. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  18627. */
  18628. uvs6: Nullable<FloatArray>;
  18629. /**
  18630. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  18631. */
  18632. colors: Nullable<FloatArray>;
  18633. /**
  18634. * 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).
  18635. */
  18636. matricesIndices: Nullable<FloatArray>;
  18637. /**
  18638. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  18639. */
  18640. matricesWeights: Nullable<FloatArray>;
  18641. /**
  18642. * An array extending the number of possible indices
  18643. */
  18644. matricesIndicesExtra: Nullable<FloatArray>;
  18645. /**
  18646. * An array extending the number of possible weights when the number of indices is extended
  18647. */
  18648. matricesWeightsExtra: Nullable<FloatArray>;
  18649. /**
  18650. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  18651. */
  18652. indices: Nullable<IndicesArray>;
  18653. /**
  18654. * Uses the passed data array to set the set the values for the specified kind of data
  18655. * @param data a linear array of floating numbers
  18656. * @param kind the type of data that is being set, eg positions, colors etc
  18657. */
  18658. set(data: FloatArray, kind: string): void;
  18659. /**
  18660. * Associates the vertexData to the passed Mesh.
  18661. * Sets it as updatable or not (default `false`)
  18662. * @param mesh the mesh the vertexData is applied to
  18663. * @param updatable when used and having the value true allows new data to update the vertexData
  18664. * @returns the VertexData
  18665. */
  18666. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  18667. /**
  18668. * Associates the vertexData to the passed Geometry.
  18669. * Sets it as updatable or not (default `false`)
  18670. * @param geometry the geometry the vertexData is applied to
  18671. * @param updatable when used and having the value true allows new data to update the vertexData
  18672. * @returns VertexData
  18673. */
  18674. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  18675. /**
  18676. * Updates the associated mesh
  18677. * @param mesh the mesh to be updated
  18678. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  18679. * @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
  18680. * @returns VertexData
  18681. */
  18682. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  18683. /**
  18684. * Updates the associated geometry
  18685. * @param geometry the geometry to be updated
  18686. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  18687. * @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
  18688. * @returns VertexData.
  18689. */
  18690. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  18691. private _applyTo;
  18692. private _update;
  18693. /**
  18694. * Transforms each position and each normal of the vertexData according to the passed Matrix
  18695. * @param matrix the transforming matrix
  18696. * @returns the VertexData
  18697. */
  18698. transform(matrix: Matrix): VertexData;
  18699. /**
  18700. * Merges the passed VertexData into the current one
  18701. * @param other the VertexData to be merged into the current one
  18702. * @returns the modified VertexData
  18703. */
  18704. merge(other: VertexData): VertexData;
  18705. private _mergeElement;
  18706. private _validate;
  18707. /**
  18708. * Serializes the VertexData
  18709. * @returns a serialized object
  18710. */
  18711. serialize(): any;
  18712. /**
  18713. * Extracts the vertexData from a mesh
  18714. * @param mesh the mesh from which to extract the VertexData
  18715. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  18716. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  18717. * @returns the object VertexData associated to the passed mesh
  18718. */
  18719. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  18720. /**
  18721. * Extracts the vertexData from the geometry
  18722. * @param geometry the geometry from which to extract the VertexData
  18723. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  18724. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  18725. * @returns the object VertexData associated to the passed mesh
  18726. */
  18727. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  18728. private static _ExtractFrom;
  18729. /**
  18730. * Creates the VertexData for a Ribbon
  18731. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  18732. * * pathArray array of paths, each of which an array of successive Vector3
  18733. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  18734. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  18735. * * 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
  18736. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18737. * * 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)
  18738. * * 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)
  18739. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  18740. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  18741. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  18742. * @returns the VertexData of the ribbon
  18743. */
  18744. static CreateRibbon(options: {
  18745. pathArray: Vector3[][];
  18746. closeArray?: boolean;
  18747. closePath?: boolean;
  18748. offset?: number;
  18749. sideOrientation?: number;
  18750. frontUVs?: Vector4;
  18751. backUVs?: Vector4;
  18752. invertUV?: boolean;
  18753. uvs?: Vector2[];
  18754. colors?: Color4[];
  18755. }): VertexData;
  18756. /**
  18757. * Creates the VertexData for a box
  18758. * @param options an object used to set the following optional parameters for the box, required but can be empty
  18759. * * size sets the width, height and depth of the box to the value of size, optional default 1
  18760. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  18761. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  18762. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  18763. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  18764. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  18765. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18766. * * 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)
  18767. * * 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)
  18768. * @returns the VertexData of the box
  18769. */
  18770. static CreateBox(options: {
  18771. size?: number;
  18772. width?: number;
  18773. height?: number;
  18774. depth?: number;
  18775. faceUV?: Vector4[];
  18776. faceColors?: Color4[];
  18777. sideOrientation?: number;
  18778. frontUVs?: Vector4;
  18779. backUVs?: Vector4;
  18780. }): VertexData;
  18781. /**
  18782. * Creates the VertexData for an ellipsoid, defaults to a sphere
  18783. * @param options an object used to set the following optional parameters for the box, required but can be empty
  18784. * * segments sets the number of horizontal strips optional, default 32
  18785. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  18786. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  18787. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  18788. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  18789. * * 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
  18790. * * 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
  18791. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18792. * * 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)
  18793. * * 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)
  18794. * @returns the VertexData of the ellipsoid
  18795. */
  18796. static CreateSphere(options: {
  18797. segments?: number;
  18798. diameter?: number;
  18799. diameterX?: number;
  18800. diameterY?: number;
  18801. diameterZ?: number;
  18802. arc?: number;
  18803. slice?: number;
  18804. sideOrientation?: number;
  18805. frontUVs?: Vector4;
  18806. backUVs?: Vector4;
  18807. }): VertexData;
  18808. /**
  18809. * Creates the VertexData for a cylinder, cone or prism
  18810. * @param options an object used to set the following optional parameters for the box, required but can be empty
  18811. * * height sets the height (y direction) of the cylinder, optional, default 2
  18812. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  18813. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  18814. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  18815. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  18816. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  18817. * * 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
  18818. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  18819. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  18820. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  18821. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  18822. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18823. * * 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)
  18824. * * 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)
  18825. * @returns the VertexData of the cylinder, cone or prism
  18826. */
  18827. static CreateCylinder(options: {
  18828. height?: number;
  18829. diameterTop?: number;
  18830. diameterBottom?: number;
  18831. diameter?: number;
  18832. tessellation?: number;
  18833. subdivisions?: number;
  18834. arc?: number;
  18835. faceColors?: Color4[];
  18836. faceUV?: Vector4[];
  18837. hasRings?: boolean;
  18838. enclose?: boolean;
  18839. sideOrientation?: number;
  18840. frontUVs?: Vector4;
  18841. backUVs?: Vector4;
  18842. }): VertexData;
  18843. /**
  18844. * Creates the VertexData for a torus
  18845. * @param options an object used to set the following optional parameters for the box, required but can be empty
  18846. * * diameter the diameter of the torus, optional default 1
  18847. * * thickness the diameter of the tube forming the torus, optional default 0.5
  18848. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  18849. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18850. * * 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)
  18851. * * 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)
  18852. * @returns the VertexData of the torus
  18853. */
  18854. static CreateTorus(options: {
  18855. diameter?: number;
  18856. thickness?: number;
  18857. tessellation?: number;
  18858. sideOrientation?: number;
  18859. frontUVs?: Vector4;
  18860. backUVs?: Vector4;
  18861. }): VertexData;
  18862. /**
  18863. * Creates the VertexData of the LineSystem
  18864. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  18865. * - lines an array of lines, each line being an array of successive Vector3
  18866. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  18867. * @returns the VertexData of the LineSystem
  18868. */
  18869. static CreateLineSystem(options: {
  18870. lines: Vector3[][];
  18871. colors?: Nullable<Color4[][]>;
  18872. }): VertexData;
  18873. /**
  18874. * Create the VertexData for a DashedLines
  18875. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  18876. * - points an array successive Vector3
  18877. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  18878. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  18879. * - dashNb the intended total number of dashes, optional, default 200
  18880. * @returns the VertexData for the DashedLines
  18881. */
  18882. static CreateDashedLines(options: {
  18883. points: Vector3[];
  18884. dashSize?: number;
  18885. gapSize?: number;
  18886. dashNb?: number;
  18887. }): VertexData;
  18888. /**
  18889. * Creates the VertexData for a Ground
  18890. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  18891. * - width the width (x direction) of the ground, optional, default 1
  18892. * - height the height (z direction) of the ground, optional, default 1
  18893. * - subdivisions the number of subdivisions per side, optional, default 1
  18894. * @returns the VertexData of the Ground
  18895. */
  18896. static CreateGround(options: {
  18897. width?: number;
  18898. height?: number;
  18899. subdivisions?: number;
  18900. subdivisionsX?: number;
  18901. subdivisionsY?: number;
  18902. }): VertexData;
  18903. /**
  18904. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  18905. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  18906. * * xmin the ground minimum X coordinate, optional, default -1
  18907. * * zmin the ground minimum Z coordinate, optional, default -1
  18908. * * xmax the ground maximum X coordinate, optional, default 1
  18909. * * zmax the ground maximum Z coordinate, optional, default 1
  18910. * * 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}
  18911. * * 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}
  18912. * @returns the VertexData of the TiledGround
  18913. */
  18914. static CreateTiledGround(options: {
  18915. xmin: number;
  18916. zmin: number;
  18917. xmax: number;
  18918. zmax: number;
  18919. subdivisions?: {
  18920. w: number;
  18921. h: number;
  18922. };
  18923. precision?: {
  18924. w: number;
  18925. h: number;
  18926. };
  18927. }): VertexData;
  18928. /**
  18929. * Creates the VertexData of the Ground designed from a heightmap
  18930. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  18931. * * width the width (x direction) of the ground
  18932. * * height the height (z direction) of the ground
  18933. * * subdivisions the number of subdivisions per side
  18934. * * minHeight the minimum altitude on the ground, optional, default 0
  18935. * * maxHeight the maximum altitude on the ground, optional default 1
  18936. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  18937. * * buffer the array holding the image color data
  18938. * * bufferWidth the width of image
  18939. * * bufferHeight the height of image
  18940. * @returns the VertexData of the Ground designed from a heightmap
  18941. */
  18942. static CreateGroundFromHeightMap(options: {
  18943. width: number;
  18944. height: number;
  18945. subdivisions: number;
  18946. minHeight: number;
  18947. maxHeight: number;
  18948. colorFilter: Color3;
  18949. buffer: Uint8Array;
  18950. bufferWidth: number;
  18951. bufferHeight: number;
  18952. }): VertexData;
  18953. /**
  18954. * Creates the VertexData for a Plane
  18955. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  18956. * * size sets the width and height of the plane to the value of size, optional default 1
  18957. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  18958. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  18959. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18960. * * 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)
  18961. * * 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)
  18962. * @returns the VertexData of the box
  18963. */
  18964. static CreatePlane(options: {
  18965. size?: number;
  18966. width?: number;
  18967. height?: number;
  18968. sideOrientation?: number;
  18969. frontUVs?: Vector4;
  18970. backUVs?: Vector4;
  18971. }): VertexData;
  18972. /**
  18973. * Creates the VertexData of the Disc or regular Polygon
  18974. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  18975. * * radius the radius of the disc, optional default 0.5
  18976. * * tessellation the number of polygon sides, optional, default 64
  18977. * * 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
  18978. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18979. * * 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)
  18980. * * 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)
  18981. * @returns the VertexData of the box
  18982. */
  18983. static CreateDisc(options: {
  18984. radius?: number;
  18985. tessellation?: number;
  18986. arc?: number;
  18987. sideOrientation?: number;
  18988. frontUVs?: Vector4;
  18989. backUVs?: Vector4;
  18990. }): VertexData;
  18991. /**
  18992. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  18993. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  18994. * @param polygon a mesh built from polygonTriangulation.build()
  18995. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18996. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  18997. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  18998. * @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)
  18999. * @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)
  19000. * @returns the VertexData of the Polygon
  19001. */
  19002. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  19003. /**
  19004. * Creates the VertexData of the IcoSphere
  19005. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  19006. * * radius the radius of the IcoSphere, optional default 1
  19007. * * radiusX allows stretching in the x direction, optional, default radius
  19008. * * radiusY allows stretching in the y direction, optional, default radius
  19009. * * radiusZ allows stretching in the z direction, optional, default radius
  19010. * * flat when true creates a flat shaded mesh, optional, default true
  19011. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  19012. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19013. * * 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)
  19014. * * 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)
  19015. * @returns the VertexData of the IcoSphere
  19016. */
  19017. static CreateIcoSphere(options: {
  19018. radius?: number;
  19019. radiusX?: number;
  19020. radiusY?: number;
  19021. radiusZ?: number;
  19022. flat?: boolean;
  19023. subdivisions?: number;
  19024. sideOrientation?: number;
  19025. frontUVs?: Vector4;
  19026. backUVs?: Vector4;
  19027. }): VertexData;
  19028. /**
  19029. * Creates the VertexData for a Polyhedron
  19030. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  19031. * * type provided types are:
  19032. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  19033. * * 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)
  19034. * * size the size of the IcoSphere, optional default 1
  19035. * * sizeX allows stretching in the x direction, optional, default size
  19036. * * sizeY allows stretching in the y direction, optional, default size
  19037. * * sizeZ allows stretching in the z direction, optional, default size
  19038. * * 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
  19039. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  19040. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  19041. * * flat when true creates a flat shaded mesh, optional, default true
  19042. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  19043. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19044. * * 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)
  19045. * * 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)
  19046. * @returns the VertexData of the Polyhedron
  19047. */
  19048. static CreatePolyhedron(options: {
  19049. type?: number;
  19050. size?: number;
  19051. sizeX?: number;
  19052. sizeY?: number;
  19053. sizeZ?: number;
  19054. custom?: any;
  19055. faceUV?: Vector4[];
  19056. faceColors?: Color4[];
  19057. flat?: boolean;
  19058. sideOrientation?: number;
  19059. frontUVs?: Vector4;
  19060. backUVs?: Vector4;
  19061. }): VertexData;
  19062. /**
  19063. * Creates the VertexData for a TorusKnot
  19064. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  19065. * * radius the radius of the torus knot, optional, default 2
  19066. * * tube the thickness of the tube, optional, default 0.5
  19067. * * radialSegments the number of sides on each tube segments, optional, default 32
  19068. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  19069. * * p the number of windings around the z axis, optional, default 2
  19070. * * q the number of windings around the x axis, optional, default 3
  19071. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19072. * * 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)
  19073. * * 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)
  19074. * @returns the VertexData of the Torus Knot
  19075. */
  19076. static CreateTorusKnot(options: {
  19077. radius?: number;
  19078. tube?: number;
  19079. radialSegments?: number;
  19080. tubularSegments?: number;
  19081. p?: number;
  19082. q?: number;
  19083. sideOrientation?: number;
  19084. frontUVs?: Vector4;
  19085. backUVs?: Vector4;
  19086. }): VertexData;
  19087. /**
  19088. * Compute normals for given positions and indices
  19089. * @param positions an array of vertex positions, [...., x, y, z, ......]
  19090. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  19091. * @param normals an array of vertex normals, [...., x, y, z, ......]
  19092. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  19093. * * facetNormals : optional array of facet normals (vector3)
  19094. * * facetPositions : optional array of facet positions (vector3)
  19095. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  19096. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  19097. * * bInfo : optional bounding info, required for facetPartitioning computation
  19098. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  19099. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  19100. * * useRightHandedSystem: optional boolean to for right handed system computation
  19101. * * depthSort : optional boolean to enable the facet depth sort computation
  19102. * * distanceTo : optional Vector3 to compute the facet depth from this location
  19103. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  19104. */
  19105. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  19106. facetNormals?: any;
  19107. facetPositions?: any;
  19108. facetPartitioning?: any;
  19109. ratio?: number;
  19110. bInfo?: any;
  19111. bbSize?: Vector3;
  19112. subDiv?: any;
  19113. useRightHandedSystem?: boolean;
  19114. depthSort?: boolean;
  19115. distanceTo?: Vector3;
  19116. depthSortedFacets?: any;
  19117. }): void;
  19118. private static _ComputeSides;
  19119. /**
  19120. * Applies VertexData created from the imported parameters to the geometry
  19121. * @param parsedVertexData the parsed data from an imported file
  19122. * @param geometry the geometry to apply the VertexData to
  19123. */
  19124. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  19125. }
  19126. }
  19127. declare module BABYLON {
  19128. /**
  19129. * Class containing static functions to help procedurally build meshes
  19130. */
  19131. class MeshBuilder {
  19132. private static updateSideOrientation;
  19133. /**
  19134. * Creates a box mesh
  19135. * * The parameter `size` sets the size (float) of each box side (default 1)
  19136. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  19137. * * 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)
  19138. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  19139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19140. * * 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
  19141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19142. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  19143. * @param name defines the name of the mesh
  19144. * @param options defines the options used to create the mesh
  19145. * @param scene defines the hosting scene
  19146. * @returns the box mesh
  19147. */
  19148. static CreateBox(name: string, options: {
  19149. size?: number;
  19150. width?: number;
  19151. height?: number;
  19152. depth?: number;
  19153. faceUV?: Vector4[];
  19154. faceColors?: Color4[];
  19155. sideOrientation?: number;
  19156. frontUVs?: Vector4;
  19157. backUVs?: Vector4;
  19158. updatable?: boolean;
  19159. }, scene?: Nullable<Scene>): Mesh;
  19160. /**
  19161. * Creates a sphere mesh
  19162. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  19163. * * 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 than `diameter`)
  19164. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  19165. * * 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
  19166. * * 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)
  19167. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19168. * * 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
  19169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19170. * @param name defines the name of the mesh
  19171. * @param options defines the options used to create the mesh
  19172. * @param scene defines the hosting scene
  19173. * @returns the sphere mesh
  19174. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  19175. */
  19176. static CreateSphere(name: string, options: {
  19177. segments?: number;
  19178. diameter?: number;
  19179. diameterX?: number;
  19180. diameterY?: number;
  19181. diameterZ?: number;
  19182. arc?: number;
  19183. slice?: number;
  19184. sideOrientation?: number;
  19185. frontUVs?: Vector4;
  19186. backUVs?: Vector4;
  19187. updatable?: boolean;
  19188. }, scene: any): Mesh;
  19189. /**
  19190. * Creates a plane polygonal mesh. By default, this is a disc
  19191. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  19192. * * 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
  19193. * * 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
  19194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19195. * * 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
  19196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19197. * @param name defines the name of the mesh
  19198. * @param options defines the options used to create the mesh
  19199. * @param scene defines the hosting scene
  19200. * @returns the plane polygonal mesh
  19201. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  19202. */
  19203. static CreateDisc(name: string, options: {
  19204. radius?: number;
  19205. tessellation?: number;
  19206. arc?: number;
  19207. updatable?: boolean;
  19208. sideOrientation?: number;
  19209. frontUVs?: Vector4;
  19210. backUVs?: Vector4;
  19211. }, scene?: Nullable<Scene>): Mesh;
  19212. /**
  19213. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  19214. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  19215. * * 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`)
  19216. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  19217. * * 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
  19218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19219. * * 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
  19220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19221. * @param name defines the name of the mesh
  19222. * @param options defines the options used to create the mesh
  19223. * @param scene defines the hosting scene
  19224. * @returns the icosahedron mesh
  19225. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  19226. */
  19227. static CreateIcoSphere(name: string, options: {
  19228. radius?: number;
  19229. radiusX?: number;
  19230. radiusY?: number;
  19231. radiusZ?: number;
  19232. flat?: boolean;
  19233. subdivisions?: number;
  19234. sideOrientation?: number;
  19235. frontUVs?: Vector4;
  19236. backUVs?: Vector4;
  19237. updatable?: boolean;
  19238. }, scene: Scene): Mesh;
  19239. /**
  19240. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  19241. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  19242. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  19243. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  19244. * * 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
  19245. * * 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
  19246. * * 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
  19247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19248. * * 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
  19249. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  19250. * * 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
  19251. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  19252. * * 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
  19253. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  19254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19255. * @param name defines the name of the mesh
  19256. * @param options defines the options used to create the mesh
  19257. * @param scene defines the hosting scene
  19258. * @returns the ribbon mesh
  19259. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  19260. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  19261. */
  19262. static CreateRibbon(name: string, options: {
  19263. pathArray: Vector3[][];
  19264. closeArray?: boolean;
  19265. closePath?: boolean;
  19266. offset?: number;
  19267. updatable?: boolean;
  19268. sideOrientation?: number;
  19269. frontUVs?: Vector4;
  19270. backUVs?: Vector4;
  19271. instance?: Mesh;
  19272. invertUV?: boolean;
  19273. uvs?: Vector2[];
  19274. colors?: Color4[];
  19275. }, scene?: Nullable<Scene>): Mesh;
  19276. /**
  19277. * Creates a cylinder or a cone mesh
  19278. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  19279. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  19280. * * 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.
  19281. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  19282. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  19283. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  19284. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  19285. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  19286. * * 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).
  19287. * * 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
  19288. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  19289. * * 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
  19290. * * 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.
  19291. * * If `enclose` is false, a ring surface is one element.
  19292. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  19293. * * 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
  19294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19295. * * 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
  19296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19297. * @param name defines the name of the mesh
  19298. * @param options defines the options used to create the mesh
  19299. * @param scene defines the hosting scene
  19300. * @returns the cylinder mesh
  19301. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  19302. */
  19303. static CreateCylinder(name: string, options: {
  19304. height?: number;
  19305. diameterTop?: number;
  19306. diameterBottom?: number;
  19307. diameter?: number;
  19308. tessellation?: number;
  19309. subdivisions?: number;
  19310. arc?: number;
  19311. faceColors?: Color4[];
  19312. faceUV?: Vector4[];
  19313. updatable?: boolean;
  19314. hasRings?: boolean;
  19315. enclose?: boolean;
  19316. sideOrientation?: number;
  19317. frontUVs?: Vector4;
  19318. backUVs?: Vector4;
  19319. }, scene: any): Mesh;
  19320. /**
  19321. * Creates a torus mesh
  19322. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  19323. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  19324. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  19325. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19326. * * 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
  19327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19328. * @param name defines the name of the mesh
  19329. * @param options defines the options used to create the mesh
  19330. * @param scene defines the hosting scene
  19331. * @returns the torus mesh
  19332. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  19333. */
  19334. static CreateTorus(name: string, options: {
  19335. diameter?: number;
  19336. thickness?: number;
  19337. tessellation?: number;
  19338. updatable?: boolean;
  19339. sideOrientation?: number;
  19340. frontUVs?: Vector4;
  19341. backUVs?: Vector4;
  19342. }, scene: any): Mesh;
  19343. /**
  19344. * Creates a torus knot mesh
  19345. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  19346. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  19347. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  19348. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  19349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19350. * * 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
  19351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19352. * @param name defines the name of the mesh
  19353. * @param options defines the options used to create the mesh
  19354. * @param scene defines the hosting scene
  19355. * @returns the torus knot mesh
  19356. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  19357. */
  19358. static CreateTorusKnot(name: string, options: {
  19359. radius?: number;
  19360. tube?: number;
  19361. radialSegments?: number;
  19362. tubularSegments?: number;
  19363. p?: number;
  19364. q?: number;
  19365. updatable?: boolean;
  19366. sideOrientation?: number;
  19367. frontUVs?: Vector4;
  19368. backUVs?: Vector4;
  19369. }, scene: any): Mesh;
  19370. /**
  19371. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  19372. * * 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
  19373. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  19374. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  19375. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  19376. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  19377. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  19378. * * 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
  19379. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  19380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19381. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  19382. * @param name defines the name of the new line system
  19383. * @param options defines the options used to create the line system
  19384. * @param scene defines the hosting scene
  19385. * @returns a new line system mesh
  19386. */
  19387. static CreateLineSystem(name: string, options: {
  19388. lines: Vector3[][];
  19389. updatable?: boolean;
  19390. instance?: Nullable<LinesMesh>;
  19391. colors?: Nullable<Color4[][]>;
  19392. useVertexAlpha?: boolean;
  19393. }, scene: Nullable<Scene>): LinesMesh;
  19394. /**
  19395. * Creates a line mesh
  19396. * 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
  19397. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  19398. * * The parameter `points` is an array successive Vector3
  19399. * * 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
  19400. * * The optional parameter `colors` is an array of successive Color4, one per line point
  19401. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  19402. * * When updating an instance, remember that only point positions can change, not the number of points
  19403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19404. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  19405. * @param name defines the name of the new line system
  19406. * @param options defines the options used to create the line system
  19407. * @param scene defines the hosting scene
  19408. * @returns a new line mesh
  19409. */
  19410. static CreateLines(name: string, options: {
  19411. points: Vector3[];
  19412. updatable?: boolean;
  19413. instance?: Nullable<LinesMesh>;
  19414. colors?: Color4[];
  19415. useVertexAlpha?: boolean;
  19416. }, scene?: Nullable<Scene>): LinesMesh;
  19417. /**
  19418. * Creates a dashed line mesh
  19419. * * 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
  19420. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  19421. * * The parameter `points` is an array successive Vector3
  19422. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  19423. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  19424. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  19425. * * 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
  19426. * * When updating an instance, remember that only point positions can change, not the number of points
  19427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19428. * @param name defines the name of the mesh
  19429. * @param options defines the options used to create the mesh
  19430. * @param scene defines the hosting scene
  19431. * @returns the dashed line mesh
  19432. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  19433. */
  19434. static CreateDashedLines(name: string, options: {
  19435. points: Vector3[];
  19436. dashSize?: number;
  19437. gapSize?: number;
  19438. dashNb?: number;
  19439. updatable?: boolean;
  19440. instance?: LinesMesh;
  19441. }, scene?: Nullable<Scene>): LinesMesh;
  19442. /**
  19443. * 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.
  19444. * * 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.
  19445. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  19446. * * 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.
  19447. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  19448. * * 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
  19449. * * 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
  19450. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  19451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19452. * * 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
  19453. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  19454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19455. * @param name defines the name of the mesh
  19456. * @param options defines the options used to create the mesh
  19457. * @param scene defines the hosting scene
  19458. * @returns the extruded shape mesh
  19459. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  19460. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  19461. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  19462. */
  19463. static ExtrudeShape(name: string, options: {
  19464. shape: Vector3[];
  19465. path: Vector3[];
  19466. scale?: number;
  19467. rotation?: number;
  19468. cap?: number;
  19469. updatable?: boolean;
  19470. sideOrientation?: number;
  19471. frontUVs?: Vector4;
  19472. backUVs?: Vector4;
  19473. instance?: Mesh;
  19474. invertUV?: boolean;
  19475. }, scene?: Nullable<Scene>): Mesh;
  19476. /**
  19477. * Creates an custom extruded shape mesh.
  19478. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  19479. * * 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.
  19480. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  19481. * * 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
  19482. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  19483. * * 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
  19484. * * It must returns a float value that will be the scale value applied to the shape on each path point
  19485. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  19486. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  19487. * * 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
  19488. * * 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
  19489. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  19490. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19491. * * 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
  19492. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  19493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19494. * @param name defines the name of the mesh
  19495. * @param options defines the options used to create the mesh
  19496. * @param scene defines the hosting scene
  19497. * @returns the custom extruded shape mesh
  19498. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  19499. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  19500. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  19501. */
  19502. static ExtrudeShapeCustom(name: string, options: {
  19503. shape: Vector3[];
  19504. path: Vector3[];
  19505. scaleFunction?: any;
  19506. rotationFunction?: any;
  19507. ribbonCloseArray?: boolean;
  19508. ribbonClosePath?: boolean;
  19509. cap?: number;
  19510. updatable?: boolean;
  19511. sideOrientation?: number;
  19512. frontUVs?: Vector4;
  19513. backUVs?: Vector4;
  19514. instance?: Mesh;
  19515. invertUV?: boolean;
  19516. }, scene: Scene): Mesh;
  19517. /**
  19518. * Creates lathe mesh.
  19519. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  19520. * * 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
  19521. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  19522. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  19523. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  19524. * * 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
  19525. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  19526. * * 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
  19527. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19528. * * 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
  19529. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  19530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19531. * @param name defines the name of the mesh
  19532. * @param options defines the options used to create the mesh
  19533. * @param scene defines the hosting scene
  19534. * @returns the lathe mesh
  19535. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  19536. */
  19537. static CreateLathe(name: string, options: {
  19538. shape: Vector3[];
  19539. radius?: number;
  19540. tessellation?: number;
  19541. clip?: number;
  19542. arc?: number;
  19543. closed?: boolean;
  19544. updatable?: boolean;
  19545. sideOrientation?: number;
  19546. frontUVs?: Vector4;
  19547. backUVs?: Vector4;
  19548. cap?: number;
  19549. invertUV?: boolean;
  19550. }, scene: Scene): Mesh;
  19551. /**
  19552. * Creates a plane mesh
  19553. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  19554. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  19555. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  19556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19557. * * 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
  19558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19559. * @param name defines the name of the mesh
  19560. * @param options defines the options used to create the mesh
  19561. * @param scene defines the hosting scene
  19562. * @returns the plane mesh
  19563. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  19564. */
  19565. static CreatePlane(name: string, options: {
  19566. size?: number;
  19567. width?: number;
  19568. height?: number;
  19569. sideOrientation?: number;
  19570. frontUVs?: Vector4;
  19571. backUVs?: Vector4;
  19572. updatable?: boolean;
  19573. sourcePlane?: Plane;
  19574. }, scene: Scene): Mesh;
  19575. /**
  19576. * Creates a ground mesh
  19577. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  19578. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  19579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19580. * @param name defines the name of the mesh
  19581. * @param options defines the options used to create the mesh
  19582. * @param scene defines the hosting scene
  19583. * @returns the ground mesh
  19584. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  19585. */
  19586. static CreateGround(name: string, options: {
  19587. width?: number;
  19588. height?: number;
  19589. subdivisions?: number;
  19590. subdivisionsX?: number;
  19591. subdivisionsY?: number;
  19592. updatable?: boolean;
  19593. }, scene: any): Mesh;
  19594. /**
  19595. * Creates a tiled ground mesh
  19596. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  19597. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  19598. * * 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
  19599. * * 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
  19600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19601. * @param name defines the name of the mesh
  19602. * @param options defines the options used to create the mesh
  19603. * @param scene defines the hosting scene
  19604. * @returns the tiled ground mesh
  19605. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  19606. */
  19607. static CreateTiledGround(name: string, options: {
  19608. xmin: number;
  19609. zmin: number;
  19610. xmax: number;
  19611. zmax: number;
  19612. subdivisions?: {
  19613. w: number;
  19614. h: number;
  19615. };
  19616. precision?: {
  19617. w: number;
  19618. h: number;
  19619. };
  19620. updatable?: boolean;
  19621. }, scene: Scene): Mesh;
  19622. /**
  19623. * Creates a ground mesh from a height map
  19624. * * The parameter `url` sets the URL of the height map image resource.
  19625. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  19626. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  19627. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  19628. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  19629. * * 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.
  19630. * * 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).
  19631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19632. * @param name defines the name of the mesh
  19633. * @param url defines the url to the height map
  19634. * @param options defines the options used to create the mesh
  19635. * @param scene defines the hosting scene
  19636. * @returns the ground mesh
  19637. * @see http://doc.babylonjs.com/babylon101/height_map
  19638. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  19639. */
  19640. static CreateGroundFromHeightMap(name: string, url: string, options: {
  19641. width?: number;
  19642. height?: number;
  19643. subdivisions?: number;
  19644. minHeight?: number;
  19645. maxHeight?: number;
  19646. colorFilter?: Color3;
  19647. updatable?: boolean;
  19648. onReady?: (mesh: GroundMesh) => void;
  19649. }, scene: Scene): GroundMesh;
  19650. /**
  19651. * Creates a polygon mesh
  19652. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  19653. * * 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
  19654. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19656. * * 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)
  19657. * * Remember you can only change the shape positions, not their number when updating a polygon
  19658. * @param name defines the name of the mesh
  19659. * @param options defines the options used to create the mesh
  19660. * @param scene defines the hosting scene
  19661. * @returns the polygon mesh
  19662. */
  19663. static CreatePolygon(name: string, options: {
  19664. shape: Vector3[];
  19665. holes?: Vector3[][];
  19666. depth?: number;
  19667. faceUV?: Vector4[];
  19668. faceColors?: Color4[];
  19669. updatable?: boolean;
  19670. sideOrientation?: number;
  19671. frontUVs?: Vector4;
  19672. backUVs?: Vector4;
  19673. }, scene: Scene): Mesh;
  19674. /**
  19675. * Creates an extruded polygon mesh, with depth in the Y direction.
  19676. * * 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)
  19677. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  19678. * @param name defines the name of the mesh
  19679. * @param options defines the options used to create the mesh
  19680. * @param scene defines the hosting scene
  19681. * @returns the polygon mesh
  19682. */
  19683. static ExtrudePolygon(name: string, options: {
  19684. shape: Vector3[];
  19685. holes?: Vector3[][];
  19686. depth?: number;
  19687. faceUV?: Vector4[];
  19688. faceColors?: Color4[];
  19689. updatable?: boolean;
  19690. sideOrientation?: number;
  19691. frontUVs?: Vector4;
  19692. backUVs?: Vector4;
  19693. }, scene: Scene): Mesh;
  19694. /**
  19695. * Creates a tube mesh.
  19696. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  19697. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  19698. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  19699. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  19700. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  19701. * * 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)
  19702. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  19703. * * 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
  19704. * * 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
  19705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19706. * * 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
  19707. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  19708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19709. * @param name defines the name of the mesh
  19710. * @param options defines the options used to create the mesh
  19711. * @param scene defines the hosting scene
  19712. * @returns the tube mesh
  19713. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  19714. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  19715. */
  19716. static CreateTube(name: string, options: {
  19717. path: Vector3[];
  19718. radius?: number;
  19719. tessellation?: number;
  19720. radiusFunction?: {
  19721. (i: number, distance: number): number;
  19722. };
  19723. cap?: number;
  19724. arc?: number;
  19725. updatable?: boolean;
  19726. sideOrientation?: number;
  19727. frontUVs?: Vector4;
  19728. backUVs?: Vector4;
  19729. instance?: Mesh;
  19730. invertUV?: boolean;
  19731. }, scene: Scene): Mesh;
  19732. /**
  19733. * Creates a polyhedron mesh
  19734. * * 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
  19735. * * The parameter `size` (positive float, default 1) sets the polygon size
  19736. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  19737. * * 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`
  19738. * * 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
  19739. * * 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)`)
  19740. * * 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
  19741. * * 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
  19742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  19743. * * 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
  19744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19745. * @param name defines the name of the mesh
  19746. * @param options defines the options used to create the mesh
  19747. * @param scene defines the hosting scene
  19748. * @returns the polyhedron mesh
  19749. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  19750. */
  19751. static CreatePolyhedron(name: string, options: {
  19752. type?: number;
  19753. size?: number;
  19754. sizeX?: number;
  19755. sizeY?: number;
  19756. sizeZ?: number;
  19757. custom?: any;
  19758. faceUV?: Vector4[];
  19759. faceColors?: Color4[];
  19760. flat?: boolean;
  19761. updatable?: boolean;
  19762. sideOrientation?: number;
  19763. frontUVs?: Vector4;
  19764. backUVs?: Vector4;
  19765. }, scene: Scene): Mesh;
  19766. /**
  19767. * Creates a decal mesh.
  19768. * 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
  19769. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  19770. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  19771. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  19772. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  19773. * @param name defines the name of the mesh
  19774. * @param sourceMesh defines the mesh where the decal must be applied
  19775. * @param options defines the options used to create the mesh
  19776. * @param scene defines the hosting scene
  19777. * @returns the decal mesh
  19778. * @see http://doc.babylonjs.com/how_to/decals
  19779. */
  19780. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  19781. position?: Vector3;
  19782. normal?: Vector3;
  19783. size?: Vector3;
  19784. angle?: number;
  19785. }): Mesh;
  19786. private static _ExtrudeShapeGeneric;
  19787. }
  19788. }
  19789. declare module BABYLON {
  19790. class MeshLODLevel {
  19791. distance: number;
  19792. mesh: Nullable<Mesh>;
  19793. constructor(distance: number, mesh: Nullable<Mesh>);
  19794. }
  19795. }
  19796. declare module BABYLON {
  19797. /**
  19798. * A simplifier interface for future simplification implementations.
  19799. */
  19800. interface ISimplifier {
  19801. /**
  19802. * Simplification of a given mesh according to the given settings.
  19803. * Since this requires computation, it is assumed that the function runs async.
  19804. * @param settings The settings of the simplification, including quality and distance
  19805. * @param successCallback A callback that will be called after the mesh was simplified.
  19806. * @param errorCallback in case of an error, this callback will be called. optional.
  19807. */
  19808. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  19809. }
  19810. /**
  19811. * Expected simplification settings.
  19812. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  19813. */
  19814. interface ISimplificationSettings {
  19815. quality: number;
  19816. distance: number;
  19817. optimizeMesh?: boolean;
  19818. }
  19819. class SimplificationSettings implements ISimplificationSettings {
  19820. quality: number;
  19821. distance: number;
  19822. optimizeMesh?: boolean | undefined;
  19823. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  19824. }
  19825. interface ISimplificationTask {
  19826. settings: Array<ISimplificationSettings>;
  19827. simplificationType: SimplificationType;
  19828. mesh: Mesh;
  19829. successCallback?: () => void;
  19830. parallelProcessing: boolean;
  19831. }
  19832. class SimplificationQueue {
  19833. private _simplificationArray;
  19834. running: boolean;
  19835. constructor();
  19836. addTask(task: ISimplificationTask): void;
  19837. executeNext(): void;
  19838. runSimplification(task: ISimplificationTask): void;
  19839. private getSimplifier;
  19840. }
  19841. /**
  19842. * The implemented types of simplification
  19843. * At the moment only Quadratic Error Decimation is implemented
  19844. */
  19845. enum SimplificationType {
  19846. /** Quadratic error decimation */
  19847. QUADRATIC = 0
  19848. }
  19849. class DecimationTriangle {
  19850. vertices: Array<DecimationVertex>;
  19851. normal: Vector3;
  19852. error: Array<number>;
  19853. deleted: boolean;
  19854. isDirty: boolean;
  19855. borderFactor: number;
  19856. deletePending: boolean;
  19857. originalOffset: number;
  19858. constructor(vertices: Array<DecimationVertex>);
  19859. }
  19860. class DecimationVertex {
  19861. position: Vector3;
  19862. id: number;
  19863. q: QuadraticMatrix;
  19864. isBorder: boolean;
  19865. triangleStart: number;
  19866. triangleCount: number;
  19867. originalOffsets: Array<number>;
  19868. constructor(position: Vector3, id: number);
  19869. updatePosition(newPosition: Vector3): void;
  19870. }
  19871. class QuadraticMatrix {
  19872. data: Array<number>;
  19873. constructor(data?: Array<number>);
  19874. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  19875. addInPlace(matrix: QuadraticMatrix): void;
  19876. addArrayInPlace(data: Array<number>): void;
  19877. add(matrix: QuadraticMatrix): QuadraticMatrix;
  19878. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  19879. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  19880. }
  19881. class Reference {
  19882. vertexId: number;
  19883. triangleId: number;
  19884. constructor(vertexId: number, triangleId: number);
  19885. }
  19886. /**
  19887. * An implementation of the Quadratic Error simplification algorithm.
  19888. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  19889. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  19890. * @author RaananW
  19891. */
  19892. class QuadraticErrorSimplification implements ISimplifier {
  19893. private _mesh;
  19894. private triangles;
  19895. private vertices;
  19896. private references;
  19897. private _reconstructedMesh;
  19898. syncIterations: number;
  19899. aggressiveness: number;
  19900. decimationIterations: number;
  19901. boundingBoxEpsilon: number;
  19902. constructor(_mesh: Mesh);
  19903. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  19904. private runDecimation;
  19905. private initWithMesh;
  19906. private init;
  19907. private reconstructMesh;
  19908. private initDecimatedMesh;
  19909. private isFlipped;
  19910. private updateTriangles;
  19911. private identifyBorder;
  19912. private updateMesh;
  19913. private vertexError;
  19914. private calculateError;
  19915. }
  19916. }
  19917. declare module BABYLON {
  19918. class Polygon {
  19919. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  19920. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  19921. static Parse(input: string): Vector2[];
  19922. static StartingAt(x: number, y: number): Path2;
  19923. }
  19924. class PolygonMeshBuilder {
  19925. private _points;
  19926. private _outlinepoints;
  19927. private _holes;
  19928. private _name;
  19929. private _scene;
  19930. private _epoints;
  19931. private _eholes;
  19932. private _addToepoint;
  19933. constructor(name: string, contours: Path2, scene: Scene);
  19934. constructor(name: string, contours: Vector2[], scene: Scene);
  19935. addHole(hole: Vector2[]): PolygonMeshBuilder;
  19936. build(updatable?: boolean, depth?: number): Mesh;
  19937. private addSide;
  19938. }
  19939. }
  19940. declare module BABYLON {
  19941. class BaseSubMesh {
  19942. /** @hidden */
  19943. _materialDefines: Nullable<MaterialDefines>;
  19944. /** @hidden */
  19945. _materialEffect: Nullable<Effect>;
  19946. readonly effect: Nullable<Effect>;
  19947. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  19948. }
  19949. class SubMesh extends BaseSubMesh implements ICullable {
  19950. materialIndex: number;
  19951. verticesStart: number;
  19952. verticesCount: number;
  19953. indexStart: number;
  19954. indexCount: number;
  19955. linesIndexCount: number;
  19956. private _mesh;
  19957. private _renderingMesh;
  19958. private _boundingInfo;
  19959. private _linesIndexBuffer;
  19960. /** @hidden */
  19961. _lastColliderWorldVertices: Nullable<Vector3[]>;
  19962. /** @hidden */
  19963. _trianglePlanes: Plane[];
  19964. /** @hidden */
  19965. _lastColliderTransformMatrix: Matrix;
  19966. /** @hidden */
  19967. _renderId: number;
  19968. /** @hidden */
  19969. _alphaIndex: number;
  19970. /** @hidden */
  19971. _distanceToCamera: number;
  19972. /** @hidden */
  19973. _id: number;
  19974. private _currentMaterial;
  19975. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  19976. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  19977. readonly IsGlobal: boolean;
  19978. /**
  19979. * Returns the submesh BoudingInfo object.
  19980. */
  19981. getBoundingInfo(): BoundingInfo;
  19982. /**
  19983. * Sets the submesh BoundingInfo.
  19984. * Return the SubMesh.
  19985. */
  19986. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  19987. /**
  19988. * Returns the mesh of the current submesh.
  19989. */
  19990. getMesh(): AbstractMesh;
  19991. /**
  19992. * Returns the rendering mesh of the submesh.
  19993. */
  19994. getRenderingMesh(): Mesh;
  19995. /**
  19996. * Returns the submesh material.
  19997. */
  19998. getMaterial(): Nullable<Material>;
  19999. /**
  20000. * Sets a new updated BoundingInfo object to the submesh.
  20001. * Returns the SubMesh.
  20002. */
  20003. refreshBoundingInfo(): SubMesh;
  20004. /** @hidden */
  20005. _checkCollision(collider: Collider): boolean;
  20006. /**
  20007. * Updates the submesh BoundingInfo.
  20008. * Returns the Submesh.
  20009. */
  20010. updateBoundingInfo(world: Matrix): SubMesh;
  20011. /**
  20012. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20013. * Boolean returned.
  20014. */
  20015. isInFrustum(frustumPlanes: Plane[]): boolean;
  20016. /**
  20017. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  20018. * Boolean returned.
  20019. */
  20020. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20021. /**
  20022. * Renders the submesh.
  20023. * Returns it.
  20024. */
  20025. render(enableAlphaMode: boolean): SubMesh;
  20026. /**
  20027. * Returns a new Index Buffer.
  20028. * Type returned : WebGLBuffer.
  20029. */
  20030. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  20031. /**
  20032. * True is the passed Ray intersects the submesh bounding box.
  20033. * Boolean returned.
  20034. */
  20035. canIntersects(ray: Ray): boolean;
  20036. /**
  20037. * Returns an object IntersectionInfo.
  20038. */
  20039. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  20040. /** @hidden */
  20041. _rebuild(): void;
  20042. /**
  20043. * Creates a new Submesh from the passed Mesh.
  20044. */
  20045. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20046. /**
  20047. * Disposes the Submesh.
  20048. * Returns nothing.
  20049. */
  20050. dispose(): void;
  20051. /**
  20052. * Creates a new Submesh from the passed parameters :
  20053. * - materialIndex (integer) : the index of the main mesh material.
  20054. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  20055. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  20056. * - mesh (Mesh) : the main mesh to create the submesh from.
  20057. * - renderingMesh (optional Mesh) : rendering mesh.
  20058. */
  20059. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20060. }
  20061. }
  20062. declare module BABYLON {
  20063. class TransformNode extends Node {
  20064. static BILLBOARDMODE_NONE: number;
  20065. static BILLBOARDMODE_X: number;
  20066. static BILLBOARDMODE_Y: number;
  20067. static BILLBOARDMODE_Z: number;
  20068. static BILLBOARDMODE_ALL: number;
  20069. private _forward;
  20070. private _forwardInverted;
  20071. private _up;
  20072. private _right;
  20073. private _rightInverted;
  20074. private _rotation;
  20075. private _rotationQuaternion;
  20076. protected _scaling: Vector3;
  20077. protected _isDirty: boolean;
  20078. private _transformToBoneReferal;
  20079. /**
  20080. * Set the billboard mode. Default is 0.
  20081. *
  20082. * | Value | Type | Description |
  20083. * | --- | --- | --- |
  20084. * | 0 | BILLBOARDMODE_NONE | |
  20085. * | 1 | BILLBOARDMODE_X | |
  20086. * | 2 | BILLBOARDMODE_Y | |
  20087. * | 4 | BILLBOARDMODE_Z | |
  20088. * | 7 | BILLBOARDMODE_ALL | |
  20089. *
  20090. */
  20091. billboardMode: number;
  20092. scalingDeterminant: number;
  20093. infiniteDistance: boolean;
  20094. /**
  20095. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  20096. * By default the system will update normals to compensate
  20097. */
  20098. ignoreNonUniformScaling: boolean;
  20099. position: Vector3;
  20100. /** @hidden */
  20101. _poseMatrix: Matrix;
  20102. private _localWorld;
  20103. /** @hidden */
  20104. _worldMatrix: Matrix;
  20105. /** @hidden */
  20106. _worldMatrixDeterminant: number;
  20107. private _absolutePosition;
  20108. private _pivotMatrix;
  20109. private _pivotMatrixInverse;
  20110. private _postMultiplyPivotMatrix;
  20111. protected _isWorldMatrixFrozen: boolean;
  20112. /**
  20113. * An event triggered after the world matrix is updated
  20114. */
  20115. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  20116. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  20117. /**
  20118. * Gets a string identifying the name of the class
  20119. * @returns "TransformNode" string
  20120. */
  20121. getClassName(): string;
  20122. /**
  20123. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  20124. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  20125. * Default : (0.0, 0.0, 0.0)
  20126. */
  20127. rotation: Vector3;
  20128. /**
  20129. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  20130. * Default : (1.0, 1.0, 1.0)
  20131. */
  20132. /**
  20133. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  20134. * Default : (1.0, 1.0, 1.0)
  20135. */
  20136. scaling: Vector3;
  20137. /**
  20138. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  20139. * It's null by default.
  20140. * If set, only the rotationQuaternion is then used to compute the mesh rotation and its property `.rotation\ is then ignored and set to (0.0, 0.0, 0.0)
  20141. */
  20142. rotationQuaternion: Nullable<Quaternion>;
  20143. /**
  20144. * The forward direction of that transform in world space.
  20145. */
  20146. readonly forward: Vector3;
  20147. /**
  20148. * The up direction of that transform in world space.
  20149. */
  20150. readonly up: Vector3;
  20151. /**
  20152. * The right direction of that transform in world space.
  20153. */
  20154. readonly right: Vector3;
  20155. /**
  20156. * Returns the latest update of the World matrix
  20157. * Returns a Matrix.
  20158. */
  20159. getWorldMatrix(): Matrix;
  20160. /** @hidden */
  20161. _getWorldMatrixDeterminant(): number;
  20162. /**
  20163. * Returns directly the latest state of the mesh World matrix.
  20164. * A Matrix is returned.
  20165. */
  20166. readonly worldMatrixFromCache: Matrix;
  20167. /**
  20168. * Copies the parameter passed Matrix into the mesh Pose matrix.
  20169. * Returns the TransformNode.
  20170. */
  20171. updatePoseMatrix(matrix: Matrix): TransformNode;
  20172. /**
  20173. * Returns the mesh Pose matrix.
  20174. * Returned object : Matrix
  20175. */
  20176. getPoseMatrix(): Matrix;
  20177. /** @hidden */
  20178. _isSynchronized(): boolean;
  20179. /** @hidden */
  20180. _initCache(): void;
  20181. markAsDirty(property: string): TransformNode;
  20182. /**
  20183. * Returns the current mesh absolute position.
  20184. * Returns a Vector3.
  20185. */
  20186. readonly absolutePosition: Vector3;
  20187. /**
  20188. * Sets a new matrix to apply before all other transformation
  20189. * @param matrix defines the transform matrix
  20190. * @returns the current TransformNode
  20191. */
  20192. setPreTransformMatrix(matrix: Matrix): TransformNode;
  20193. /**
  20194. * Sets a new pivot matrix to the current node
  20195. * @param matrix defines the new pivot matrix to use
  20196. * @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
  20197. * @returns the current TransformNode
  20198. */
  20199. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  20200. /**
  20201. * Returns the mesh pivot matrix.
  20202. * Default : Identity.
  20203. * A Matrix is returned.
  20204. */
  20205. getPivotMatrix(): Matrix;
  20206. /**
  20207. * Prevents the World matrix to be computed any longer.
  20208. * Returns the TransformNode.
  20209. */
  20210. freezeWorldMatrix(): TransformNode;
  20211. /**
  20212. * Allows back the World matrix computation.
  20213. * Returns the TransformNode.
  20214. */
  20215. unfreezeWorldMatrix(): this;
  20216. /**
  20217. * True if the World matrix has been frozen.
  20218. * Returns a boolean.
  20219. */
  20220. readonly isWorldMatrixFrozen: boolean;
  20221. /**
  20222. * Retuns the mesh absolute position in the World.
  20223. * Returns a Vector3.
  20224. */
  20225. getAbsolutePosition(): Vector3;
  20226. /**
  20227. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  20228. * Returns the TransformNode.
  20229. */
  20230. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20231. /**
  20232. * Sets the mesh position in its local space.
  20233. * Returns the TransformNode.
  20234. */
  20235. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  20236. /**
  20237. * Returns the mesh position in the local space from the current World matrix values.
  20238. * Returns a new Vector3.
  20239. */
  20240. getPositionExpressedInLocalSpace(): Vector3;
  20241. /**
  20242. * Translates the mesh along the passed Vector3 in its local space.
  20243. * Returns the TransformNode.
  20244. */
  20245. locallyTranslate(vector3: Vector3): TransformNode;
  20246. private static _lookAtVectorCache;
  20247. /**
  20248. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  20249. * @param targetPoint the position (must be in same space as current mesh) to look at
  20250. * @param yawCor optional yaw (y-axis) correction in radians
  20251. * @param pitchCor optional pitch (x-axis) correction in radians
  20252. * @param rollCor optional roll (z-axis) correction in radians
  20253. * @param space the choosen space of the target
  20254. * @returns the TransformNode.
  20255. */
  20256. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  20257. /**
  20258. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  20259. * This Vector3 is expressed in the World space.
  20260. */
  20261. getDirection(localAxis: Vector3): Vector3;
  20262. /**
  20263. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  20264. * localAxis is expressed in the mesh local space.
  20265. * result is computed in the Wordl space from the mesh World matrix.
  20266. * Returns the TransformNode.
  20267. */
  20268. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  20269. /**
  20270. * Sets a new pivot point to the current node
  20271. * @param point defines the new pivot point to use
  20272. * @param space defines if the point is in world or local space (local by default)
  20273. * @returns the current TransformNode
  20274. */
  20275. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  20276. /**
  20277. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  20278. */
  20279. getPivotPoint(): Vector3;
  20280. /**
  20281. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  20282. * Returns the TransformNode.
  20283. */
  20284. getPivotPointToRef(result: Vector3): TransformNode;
  20285. /**
  20286. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  20287. */
  20288. getAbsolutePivotPoint(): Vector3;
  20289. /**
  20290. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  20291. * Returns the TransformNode.
  20292. */
  20293. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  20294. /**
  20295. * Defines the passed node as the parent of the current node.
  20296. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  20297. * Returns the TransformNode.
  20298. */
  20299. setParent(node: Nullable<Node>): TransformNode;
  20300. private _nonUniformScaling;
  20301. readonly nonUniformScaling: boolean;
  20302. /** @hidden */
  20303. _updateNonUniformScalingState(value: boolean): boolean;
  20304. /**
  20305. * Attach the current TransformNode to another TransformNode associated with a bone
  20306. * @param bone Bone affecting the TransformNode
  20307. * @param affectedTransformNode TransformNode associated with the bone
  20308. */
  20309. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  20310. detachFromBone(): TransformNode;
  20311. private static _rotationAxisCache;
  20312. /**
  20313. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  20314. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  20315. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  20316. * The passed axis is also normalized.
  20317. * Returns the TransformNode.
  20318. */
  20319. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20320. /**
  20321. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  20322. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  20323. * The passed axis is also normalized.
  20324. * Returns the TransformNode.
  20325. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  20326. */
  20327. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  20328. /**
  20329. * Translates the mesh along the axis vector for the passed distance in the given space.
  20330. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  20331. * Returns the TransformNode.
  20332. */
  20333. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20334. /**
  20335. * Adds a rotation step to the mesh current rotation.
  20336. * x, y, z are Euler angles expressed in radians.
  20337. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  20338. * This means this rotation is made in the mesh local space only.
  20339. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  20340. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  20341. * ```javascript
  20342. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  20343. * ```
  20344. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  20345. * 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.
  20346. * Returns the TransformNode.
  20347. */
  20348. addRotation(x: number, y: number, z: number): TransformNode;
  20349. /**
  20350. * Computes the mesh World matrix and returns it.
  20351. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  20352. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  20353. * If the parameter `force`is set to `true`, the actual computation is done.
  20354. * Returns the mesh World Matrix.
  20355. */
  20356. computeWorldMatrix(force?: boolean): Matrix;
  20357. protected _afterComputeWorldMatrix(): void;
  20358. /**
  20359. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  20360. * @param func: callback function to add
  20361. *
  20362. * Returns the TransformNode.
  20363. */
  20364. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  20365. /**
  20366. * Removes a registered callback function.
  20367. * Returns the TransformNode.
  20368. */
  20369. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  20370. /**
  20371. * Clone the current transform node
  20372. * Returns the new transform node
  20373. * @param name Name of the new clone
  20374. * @param newParent New parent for the clone
  20375. * @param doNotCloneChildren Do not clone children hierarchy
  20376. */
  20377. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  20378. serialize(currentSerializationObject?: any): any;
  20379. /**
  20380. * Returns a new TransformNode object parsed from the source provided.
  20381. * The parameter `parsedMesh` is the source.
  20382. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  20383. */
  20384. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  20385. /**
  20386. * Releases resources associated with this transform node.
  20387. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20388. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20389. */
  20390. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20391. }
  20392. }
  20393. declare module BABYLON {
  20394. class VertexBuffer {
  20395. /** @hidden */
  20396. _buffer: Buffer;
  20397. private _kind;
  20398. private _size;
  20399. private _ownsBuffer;
  20400. private _instanced;
  20401. private _instanceDivisor;
  20402. /**
  20403. * The byte type.
  20404. */
  20405. static readonly BYTE: number;
  20406. /**
  20407. * The unsigned byte type.
  20408. */
  20409. static readonly UNSIGNED_BYTE: number;
  20410. /**
  20411. * The short type.
  20412. */
  20413. static readonly SHORT: number;
  20414. /**
  20415. * The unsigned short type.
  20416. */
  20417. static readonly UNSIGNED_SHORT: number;
  20418. /**
  20419. * The integer type.
  20420. */
  20421. static readonly INT: number;
  20422. /**
  20423. * The unsigned integer type.
  20424. */
  20425. static readonly UNSIGNED_INT: number;
  20426. /**
  20427. * The float type.
  20428. */
  20429. static readonly FLOAT: number;
  20430. /**
  20431. * Gets or sets the instance divisor when in instanced mode
  20432. */
  20433. instanceDivisor: number;
  20434. /**
  20435. * Gets the byte stride.
  20436. */
  20437. readonly byteStride: number;
  20438. /**
  20439. * Gets the byte offset.
  20440. */
  20441. readonly byteOffset: number;
  20442. /**
  20443. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  20444. */
  20445. readonly normalized: boolean;
  20446. /**
  20447. * Gets the data type of each component in the array.
  20448. */
  20449. readonly type: number;
  20450. /**
  20451. * Constructor
  20452. * @param engine the engine
  20453. * @param data the data to use for this vertex buffer
  20454. * @param kind the vertex buffer kind
  20455. * @param updatable whether the data is updatable
  20456. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  20457. * @param stride the stride (optional)
  20458. * @param instanced whether the buffer is instanced (optional)
  20459. * @param offset the offset of the data (optional)
  20460. * @param size the number of components (optional)
  20461. * @param type the type of the component (optional)
  20462. * @param normalized whether the data contains normalized data (optional)
  20463. * @param useBytes set to true if stride and offset are in bytes (optional)
  20464. */
  20465. 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);
  20466. /** @hidden */
  20467. _rebuild(): void;
  20468. /**
  20469. * Returns the kind of the VertexBuffer (string).
  20470. */
  20471. getKind(): string;
  20472. /**
  20473. * Boolean : is the VertexBuffer updatable ?
  20474. */
  20475. isUpdatable(): boolean;
  20476. /**
  20477. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  20478. */
  20479. getData(): Nullable<DataArray>;
  20480. /**
  20481. * Returns the WebGLBuffer associated to the VertexBuffer.
  20482. */
  20483. getBuffer(): Nullable<WebGLBuffer>;
  20484. /**
  20485. * Returns the stride as a multiple of the type byte length.
  20486. * DEPRECATED. Use byteStride instead.
  20487. */
  20488. getStrideSize(): number;
  20489. /**
  20490. * Returns the offset as a multiple of the type byte length.
  20491. * DEPRECATED. Use byteOffset instead.
  20492. */
  20493. getOffset(): number;
  20494. /**
  20495. * Returns the number of components per vertex attribute (integer).
  20496. */
  20497. getSize(): number;
  20498. /**
  20499. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  20500. */
  20501. getIsInstanced(): boolean;
  20502. /**
  20503. * Returns the instancing divisor, zero for non-instanced (integer).
  20504. */
  20505. getInstanceDivisor(): number;
  20506. /**
  20507. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  20508. * Returns the created WebGLBuffer.
  20509. */
  20510. create(data?: DataArray): void;
  20511. /**
  20512. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  20513. * This function will create a new buffer if the current one is not updatable
  20514. * Returns the updated WebGLBuffer.
  20515. */
  20516. update(data: DataArray): void;
  20517. /**
  20518. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  20519. * Returns the directly updated WebGLBuffer.
  20520. * @param data the new data
  20521. * @param offset the new offset
  20522. * @param useBytes set to true if the offset is in bytes
  20523. */
  20524. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  20525. /**
  20526. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  20527. */
  20528. dispose(): void;
  20529. /**
  20530. * Enumerates each value of this vertex buffer as numbers.
  20531. * @param count the number of values to enumerate
  20532. * @param callback the callback function called for each value
  20533. */
  20534. forEach(count: number, callback: (value: number, index: number) => void): void;
  20535. private static _PositionKind;
  20536. private static _NormalKind;
  20537. private static _TangentKind;
  20538. private static _UVKind;
  20539. private static _UV2Kind;
  20540. private static _UV3Kind;
  20541. private static _UV4Kind;
  20542. private static _UV5Kind;
  20543. private static _UV6Kind;
  20544. private static _ColorKind;
  20545. private static _MatricesIndicesKind;
  20546. private static _MatricesWeightsKind;
  20547. private static _MatricesIndicesExtraKind;
  20548. private static _MatricesWeightsExtraKind;
  20549. static readonly PositionKind: string;
  20550. static readonly NormalKind: string;
  20551. static readonly TangentKind: string;
  20552. static readonly UVKind: string;
  20553. static readonly UV2Kind: string;
  20554. static readonly UV3Kind: string;
  20555. static readonly UV4Kind: string;
  20556. static readonly UV5Kind: string;
  20557. static readonly UV6Kind: string;
  20558. static readonly ColorKind: string;
  20559. static readonly MatricesIndicesKind: string;
  20560. static readonly MatricesWeightsKind: string;
  20561. static readonly MatricesIndicesExtraKind: string;
  20562. static readonly MatricesWeightsExtraKind: string;
  20563. /**
  20564. * Deduces the stride given a kind.
  20565. * @param kind The kind string to deduce
  20566. * @returns The deduced stride
  20567. */
  20568. static DeduceStride(kind: string): number;
  20569. /**
  20570. * Gets the byte length of the given type.
  20571. * @param type the type
  20572. * @returns the number of bytes
  20573. */
  20574. static GetTypeByteLength(type: number): number;
  20575. /**
  20576. * Enumerates each value of the given parameters as numbers.
  20577. * @param data the data to enumerate
  20578. * @param byteOffset the byte offset of the data
  20579. * @param byteStride the byte stride of the data
  20580. * @param componentCount the number of components per element
  20581. * @param componentType the type of the component
  20582. * @param count the total number of components
  20583. * @param normalized whether the data is normalized
  20584. * @param callback the callback function called for each value
  20585. */
  20586. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  20587. private static _GetFloatValue;
  20588. }
  20589. }
  20590. declare module BABYLON {
  20591. /**
  20592. * Defines a target to use with MorphTargetManager
  20593. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20594. */
  20595. class MorphTarget implements IAnimatable {
  20596. /** defines the name of the target */
  20597. name: string;
  20598. /**
  20599. * Gets or sets the list of animations
  20600. */
  20601. animations: Animation[];
  20602. private _scene;
  20603. private _positions;
  20604. private _normals;
  20605. private _tangents;
  20606. private _influence;
  20607. /**
  20608. * Observable raised when the influence changes
  20609. */
  20610. onInfluenceChanged: Observable<boolean>;
  20611. /**
  20612. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  20613. */
  20614. influence: number;
  20615. private _animationPropertiesOverride;
  20616. /**
  20617. * Gets or sets the animation properties override
  20618. */
  20619. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  20620. /**
  20621. * Creates a new MorphTarget
  20622. * @param name defines the name of the target
  20623. * @param influence defines the influence to use
  20624. */
  20625. constructor(
  20626. /** defines the name of the target */
  20627. name: string, influence?: number, scene?: Nullable<Scene>);
  20628. /**
  20629. * Gets a boolean defining if the target contains position data
  20630. */
  20631. readonly hasPositions: boolean;
  20632. /**
  20633. * Gets a boolean defining if the target contains normal data
  20634. */
  20635. readonly hasNormals: boolean;
  20636. /**
  20637. * Gets a boolean defining if the target contains tangent data
  20638. */
  20639. readonly hasTangents: boolean;
  20640. /**
  20641. * Affects position data to this target
  20642. * @param data defines the position data to use
  20643. */
  20644. setPositions(data: Nullable<FloatArray>): void;
  20645. /**
  20646. * Gets the position data stored in this target
  20647. * @returns a FloatArray containing the position data (or null if not present)
  20648. */
  20649. getPositions(): Nullable<FloatArray>;
  20650. /**
  20651. * Affects normal data to this target
  20652. * @param data defines the normal data to use
  20653. */
  20654. setNormals(data: Nullable<FloatArray>): void;
  20655. /**
  20656. * Gets the normal data stored in this target
  20657. * @returns a FloatArray containing the normal data (or null if not present)
  20658. */
  20659. getNormals(): Nullable<FloatArray>;
  20660. /**
  20661. * Affects tangent data to this target
  20662. * @param data defines the tangent data to use
  20663. */
  20664. setTangents(data: Nullable<FloatArray>): void;
  20665. /**
  20666. * Gets the tangent data stored in this target
  20667. * @returns a FloatArray containing the tangent data (or null if not present)
  20668. */
  20669. getTangents(): Nullable<FloatArray>;
  20670. /**
  20671. * Serializes the current target into a Serialization object
  20672. * @returns the serialized object
  20673. */
  20674. serialize(): any;
  20675. /**
  20676. * Creates a new target from serialized data
  20677. * @param serializationObject defines the serialized data to use
  20678. * @returns a new MorphTarget
  20679. */
  20680. static Parse(serializationObject: any): MorphTarget;
  20681. /**
  20682. * Creates a MorphTarget from mesh data
  20683. * @param mesh defines the source mesh
  20684. * @param name defines the name to use for the new target
  20685. * @param influence defines the influence to attach to the target
  20686. * @returns a new MorphTarget
  20687. */
  20688. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  20689. }
  20690. }
  20691. declare module BABYLON {
  20692. /**
  20693. * This class is used to deform meshes using morphing between different targets
  20694. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20695. */
  20696. class MorphTargetManager {
  20697. private _targets;
  20698. private _targetObservable;
  20699. private _activeTargets;
  20700. private _scene;
  20701. private _influences;
  20702. private _supportsNormals;
  20703. private _supportsTangents;
  20704. private _vertexCount;
  20705. private _uniqueId;
  20706. private _tempInfluences;
  20707. /**
  20708. * Creates a new MorphTargetManager
  20709. * @param scene defines the current scene
  20710. */
  20711. constructor(scene?: Nullable<Scene>);
  20712. /**
  20713. * Gets the unique ID of this manager
  20714. */
  20715. readonly uniqueId: number;
  20716. /**
  20717. * Gets the number of vertices handled by this manager
  20718. */
  20719. readonly vertexCount: number;
  20720. /**
  20721. * Gets a boolean indicating if this manager supports morphing of normals
  20722. */
  20723. readonly supportsNormals: boolean;
  20724. /**
  20725. * Gets a boolean indicating if this manager supports morphing of tangents
  20726. */
  20727. readonly supportsTangents: boolean;
  20728. /**
  20729. * Gets the number of targets stored in this manager
  20730. */
  20731. readonly numTargets: number;
  20732. /**
  20733. * Gets the number of influencers (ie. the number of targets with influences > 0)
  20734. */
  20735. readonly numInfluencers: number;
  20736. /**
  20737. * Gets the list of influences (one per target)
  20738. */
  20739. readonly influences: Float32Array;
  20740. /**
  20741. * Gets the active target at specified index. An active target is a target with an influence > 0
  20742. * @param index defines the index to check
  20743. * @returns the requested target
  20744. */
  20745. getActiveTarget(index: number): MorphTarget;
  20746. /**
  20747. * Gets the target at specified index
  20748. * @param index defines the index to check
  20749. * @returns the requested target
  20750. */
  20751. getTarget(index: number): MorphTarget;
  20752. /**
  20753. * Add a new target to this manager
  20754. * @param target defines the target to add
  20755. */
  20756. addTarget(target: MorphTarget): void;
  20757. /**
  20758. * Removes a target from the manager
  20759. * @param target defines the target to remove
  20760. */
  20761. removeTarget(target: MorphTarget): void;
  20762. /**
  20763. * Serializes the current manager into a Serialization object
  20764. * @returns the serialized object
  20765. */
  20766. serialize(): any;
  20767. private _syncActiveTargets;
  20768. /**
  20769. * Syncrhonize the targets with all the meshes using this morph target manager
  20770. */
  20771. synchronize(): void;
  20772. /**
  20773. * Creates a new MorphTargetManager from serialized data
  20774. * @param serializationObject defines the serialized data
  20775. * @param scene defines the hosting scene
  20776. * @returns the new MorphTargetManager
  20777. */
  20778. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  20779. }
  20780. }
  20781. declare module BABYLON {
  20782. /**
  20783. * This represents the base class for particle system in Babylon.
  20784. * 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.
  20785. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  20786. * @example https://doc.babylonjs.com/babylon101/particles
  20787. */
  20788. class BaseParticleSystem {
  20789. /**
  20790. * Source color is added to the destination color without alpha affecting the result.
  20791. */
  20792. static BLENDMODE_ONEONE: number;
  20793. /**
  20794. * Blend current color and particle color using particle’s alpha.
  20795. */
  20796. static BLENDMODE_STANDARD: number;
  20797. /**
  20798. * Add current color and particle color multiplied by particle’s alpha.
  20799. */
  20800. static BLENDMODE_ADD: number;
  20801. /**
  20802. * List of animations used by the particle system.
  20803. */
  20804. animations: Animation[];
  20805. /**
  20806. * The id of the Particle system.
  20807. */
  20808. id: string;
  20809. /**
  20810. * The friendly name of the Particle system.
  20811. */
  20812. name: string;
  20813. /**
  20814. * The rendering group used by the Particle system to chose when to render.
  20815. */
  20816. renderingGroupId: number;
  20817. /**
  20818. * The emitter represents the Mesh or position we are attaching the particle system to.
  20819. */
  20820. emitter: Nullable<AbstractMesh | Vector3>;
  20821. /**
  20822. * The maximum number of particles to emit per frame
  20823. */
  20824. emitRate: number;
  20825. /**
  20826. * If you want to launch only a few particles at once, that can be done, as well.
  20827. */
  20828. manualEmitCount: number;
  20829. /**
  20830. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  20831. */
  20832. updateSpeed: number;
  20833. /**
  20834. * The amount of time the particle system is running (depends of the overall update speed).
  20835. */
  20836. targetStopDuration: number;
  20837. /**
  20838. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  20839. */
  20840. disposeOnStop: boolean;
  20841. /**
  20842. * Minimum power of emitting particles.
  20843. */
  20844. minEmitPower: number;
  20845. /**
  20846. * Maximum power of emitting particles.
  20847. */
  20848. maxEmitPower: number;
  20849. /**
  20850. * Minimum life time of emitting particles.
  20851. */
  20852. minLifeTime: number;
  20853. /**
  20854. * Maximum life time of emitting particles.
  20855. */
  20856. maxLifeTime: number;
  20857. /**
  20858. * Minimum Size of emitting particles.
  20859. */
  20860. minSize: number;
  20861. /**
  20862. * Maximum Size of emitting particles.
  20863. */
  20864. maxSize: number;
  20865. /**
  20866. * Minimum scale of emitting particles on X axis.
  20867. */
  20868. minScaleX: number;
  20869. /**
  20870. * Maximum scale of emitting particles on X axis.
  20871. */
  20872. maxScaleX: number;
  20873. /**
  20874. * Minimum scale of emitting particles on Y axis.
  20875. */
  20876. minScaleY: number;
  20877. /**
  20878. * Maximum scale of emitting particles on Y axis.
  20879. */
  20880. maxScaleY: number;
  20881. /**
  20882. * Gets or sets the minimal initial rotation in radians.
  20883. */
  20884. minInitialRotation: number;
  20885. /**
  20886. * Gets or sets the maximal initial rotation in radians.
  20887. */
  20888. maxInitialRotation: number;
  20889. /**
  20890. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  20891. */
  20892. minAngularSpeed: number;
  20893. /**
  20894. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  20895. */
  20896. maxAngularSpeed: number;
  20897. /**
  20898. * The texture used to render each particle. (this can be a spritesheet)
  20899. */
  20900. particleTexture: Nullable<Texture>;
  20901. /**
  20902. * The layer mask we are rendering the particles through.
  20903. */
  20904. layerMask: number;
  20905. /**
  20906. * This can help using your own shader to render the particle system.
  20907. * The according effect will be created
  20908. */
  20909. customShader: any;
  20910. /**
  20911. * By default particle system starts as soon as they are created. This prevents the
  20912. * automatic start to happen and let you decide when to start emitting particles.
  20913. */
  20914. preventAutoStart: boolean;
  20915. /**
  20916. * Gets or sets a texture used to add random noise to particle positions
  20917. */
  20918. noiseTexture: Nullable<BaseTexture>;
  20919. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  20920. noiseStrength: Vector3;
  20921. /**
  20922. * Callback triggered when the particle animation is ending.
  20923. */
  20924. onAnimationEnd: Nullable<() => void>;
  20925. /**
  20926. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  20927. */
  20928. blendMode: number;
  20929. /**
  20930. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  20931. * to override the particles.
  20932. */
  20933. forceDepthWrite: boolean;
  20934. /** 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 */
  20935. preWarmCycles: number;
  20936. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  20937. preWarmStepOffset: number;
  20938. /**
  20939. * 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)
  20940. */
  20941. spriteCellChangeSpeed: number;
  20942. /**
  20943. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  20944. */
  20945. startSpriteCellID: number;
  20946. /**
  20947. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  20948. */
  20949. endSpriteCellID: number;
  20950. /**
  20951. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  20952. */
  20953. spriteCellWidth: number;
  20954. /**
  20955. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  20956. */
  20957. spriteCellHeight: number;
  20958. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  20959. translationPivot: Vector2;
  20960. /** @hidden */
  20961. protected _isAnimationSheetEnabled: boolean;
  20962. /**
  20963. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  20964. */
  20965. isAnimationSheetEnabled: boolean;
  20966. /**
  20967. * You can use gravity if you want to give an orientation to your particles.
  20968. */
  20969. gravity: Vector3;
  20970. protected _colorGradients: Nullable<Array<ColorGradient>>;
  20971. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  20972. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  20973. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  20974. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  20975. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  20976. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  20977. limitVelocityDamping: number;
  20978. /**
  20979. * Gets the current list of limit velocity gradients.
  20980. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  20981. * @returns the list of limit velocity gradients
  20982. */
  20983. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  20984. /**
  20985. * Gets the current list of color gradients.
  20986. * You must use addColorGradient and removeColorGradient to udpate this list
  20987. * @returns the list of color gradients
  20988. */
  20989. getColorGradients(): Nullable<Array<ColorGradient>>;
  20990. /**
  20991. * Gets the current list of size gradients.
  20992. * You must use addSizeGradient and removeSizeGradient to udpate this list
  20993. * @returns the list of size gradients
  20994. */
  20995. getSizeGradients(): Nullable<Array<FactorGradient>>;
  20996. /**
  20997. * Gets the current list of life time gradients.
  20998. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  20999. * @returns the list of life time gradients
  21000. */
  21001. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  21002. /**
  21003. * Gets the current list of angular speed gradients.
  21004. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21005. * @returns the list of angular speed gradients
  21006. */
  21007. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21008. /**
  21009. * Gets the current list of velocity gradients.
  21010. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21011. * @returns the list of velocity gradients
  21012. */
  21013. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21014. /**
  21015. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21016. * This only works when particleEmitterTyps is a BoxParticleEmitter
  21017. */
  21018. direction1: Vector3;
  21019. /**
  21020. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21021. * This only works when particleEmitterTyps is a BoxParticleEmitter
  21022. */
  21023. direction2: Vector3;
  21024. /**
  21025. * 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.
  21026. * This only works when particleEmitterTyps is a BoxParticleEmitter
  21027. */
  21028. minEmitBox: Vector3;
  21029. /**
  21030. * 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.
  21031. * This only works when particleEmitterTyps is a BoxParticleEmitter
  21032. */
  21033. maxEmitBox: Vector3;
  21034. /**
  21035. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  21036. */
  21037. color1: Color4;
  21038. /**
  21039. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  21040. */
  21041. color2: Color4;
  21042. /**
  21043. * Color the particle will have at the end of its lifetime
  21044. */
  21045. colorDead: Color4;
  21046. /**
  21047. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  21048. */
  21049. textureMask: Color4;
  21050. /**
  21051. * The particle emitter type defines the emitter used by the particle system.
  21052. * It can be for example box, sphere, or cone...
  21053. */
  21054. particleEmitterType: IParticleEmitterType;
  21055. /**
  21056. * Gets or sets the billboard mode to use when isBillboardBased = true.
  21057. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  21058. */
  21059. billboardMode: number;
  21060. protected _isBillboardBased: boolean;
  21061. /**
  21062. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  21063. */
  21064. isBillboardBased: boolean;
  21065. /**
  21066. * The scene the particle system belongs to.
  21067. */
  21068. protected _scene: Scene;
  21069. /**
  21070. * Local cache of defines for image processing.
  21071. */
  21072. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  21073. /**
  21074. * Default configuration related to image processing available in the standard Material.
  21075. */
  21076. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  21077. /**
  21078. * Gets the image processing configuration used either in this material.
  21079. */
  21080. /**
  21081. * Sets the Default image processing configuration used either in the this material.
  21082. *
  21083. * If sets to null, the scene one is in use.
  21084. */
  21085. imageProcessingConfiguration: ImageProcessingConfiguration;
  21086. /**
  21087. * Attaches a new image processing configuration to the Standard Material.
  21088. * @param configuration
  21089. */
  21090. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  21091. /** @hidden */
  21092. protected _reset(): void;
  21093. /**
  21094. * Instantiates a particle system.
  21095. * 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.
  21096. * @param name The name of the particle system
  21097. */
  21098. constructor(name: string);
  21099. /**
  21100. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  21101. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21102. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21103. * @returns the emitter
  21104. */
  21105. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  21106. /**
  21107. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21108. * @param radius The radius of the hemisphere to emit from
  21109. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21110. * @returns the emitter
  21111. */
  21112. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  21113. /**
  21114. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  21115. * @param radius The radius of the sphere to emit from
  21116. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21117. * @returns the emitter
  21118. */
  21119. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  21120. /**
  21121. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  21122. * @param radius The radius of the sphere to emit from
  21123. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21124. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21125. * @returns the emitter
  21126. */
  21127. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  21128. /**
  21129. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21130. * @param radius The radius of the cone to emit from
  21131. * @param angle The base angle of the cone
  21132. * @returns the emitter
  21133. */
  21134. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  21135. /**
  21136. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21137. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21138. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21139. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21140. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21141. * @returns the emitter
  21142. */
  21143. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21144. }
  21145. }
  21146. declare module BABYLON {
  21147. /**
  21148. * This represents a GPU particle system in Babylon
  21149. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  21150. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  21151. */
  21152. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  21153. /**
  21154. * The layer mask we are rendering the particles through.
  21155. */
  21156. layerMask: number;
  21157. private _capacity;
  21158. private _activeCount;
  21159. private _currentActiveCount;
  21160. private _accumulatedCount;
  21161. private _renderEffect;
  21162. private _updateEffect;
  21163. private _buffer0;
  21164. private _buffer1;
  21165. private _spriteBuffer;
  21166. private _updateVAO;
  21167. private _renderVAO;
  21168. private _targetIndex;
  21169. private _sourceBuffer;
  21170. private _targetBuffer;
  21171. private _engine;
  21172. private _currentRenderId;
  21173. private _started;
  21174. private _stopped;
  21175. private _timeDelta;
  21176. private _randomTexture;
  21177. private _randomTexture2;
  21178. private _attributesStrideSize;
  21179. private _updateEffectOptions;
  21180. private _randomTextureSize;
  21181. private _actualFrame;
  21182. private readonly _rawTextureWidth;
  21183. /**
  21184. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  21185. */
  21186. static readonly IsSupported: boolean;
  21187. /**
  21188. * An event triggered when the system is disposed.
  21189. */
  21190. onDisposeObservable: Observable<GPUParticleSystem>;
  21191. /**
  21192. * Gets the maximum number of particles active at the same time.
  21193. * @returns The max number of active particles.
  21194. */
  21195. getCapacity(): number;
  21196. /**
  21197. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  21198. * to override the particles.
  21199. */
  21200. forceDepthWrite: boolean;
  21201. /**
  21202. * Gets or set the number of active particles
  21203. */
  21204. activeParticleCount: number;
  21205. private _preWarmDone;
  21206. /**
  21207. * Is this system ready to be used/rendered
  21208. * @return true if the system is ready
  21209. */
  21210. isReady(): boolean;
  21211. /**
  21212. * Gets Wether the system has been started.
  21213. * @returns True if it has been started, otherwise false.
  21214. */
  21215. isStarted(): boolean;
  21216. /**
  21217. * Starts the particle system and begins to emit
  21218. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  21219. */
  21220. start(delay?: number): void;
  21221. /**
  21222. * Stops the particle system.
  21223. */
  21224. stop(): void;
  21225. /**
  21226. * Remove all active particles
  21227. */
  21228. reset(): void;
  21229. /**
  21230. * Returns the string "GPUParticleSystem"
  21231. * @returns a string containing the class name
  21232. */
  21233. getClassName(): string;
  21234. private _colorGradientsTexture;
  21235. private _removeGradient;
  21236. /**
  21237. * Adds a new color gradient
  21238. * @param gradient defines the gradient to use (between 0 and 1)
  21239. * @param color defines the color to affect to the specified gradient
  21240. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  21241. * @returns the current particle system
  21242. */
  21243. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  21244. /**
  21245. * Remove a specific color gradient
  21246. * @param gradient defines the gradient to remove
  21247. * @returns the current particle system
  21248. */
  21249. removeColorGradient(gradient: number): GPUParticleSystem;
  21250. private _angularSpeedGradientsTexture;
  21251. private _sizeGradientsTexture;
  21252. private _velocityGradientsTexture;
  21253. private _limitVelocityGradientsTexture;
  21254. private _addFactorGradient;
  21255. /**
  21256. * Adds a new size gradient
  21257. * @param gradient defines the gradient to use (between 0 and 1)
  21258. * @param factor defines the size factor to affect to the specified gradient
  21259. * @returns the current particle system
  21260. */
  21261. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  21262. /**
  21263. * Remove a specific size gradient
  21264. * @param gradient defines the gradient to remove
  21265. * @returns the current particle system
  21266. */
  21267. removeSizeGradient(gradient: number): GPUParticleSystem;
  21268. /**
  21269. * Adds a new angular speed gradient
  21270. * @param gradient defines the gradient to use (between 0 and 1)
  21271. * @param factor defines the angular speed to affect to the specified gradient
  21272. * @returns the current particle system
  21273. */
  21274. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  21275. /**
  21276. * Remove a specific angular speed gradient
  21277. * @param gradient defines the gradient to remove
  21278. * @returns the current particle system
  21279. */
  21280. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  21281. /**
  21282. * Adds a new velocity gradient
  21283. * @param gradient defines the gradient to use (between 0 and 1)
  21284. * @param factor defines the velocity to affect to the specified gradient
  21285. * @returns the current particle system
  21286. */
  21287. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  21288. /**
  21289. * Remove a specific velocity gradient
  21290. * @param gradient defines the gradient to remove
  21291. * @returns the current particle system
  21292. */
  21293. removeVelocityGradient(gradient: number): GPUParticleSystem;
  21294. /**
  21295. * Adds a new limit velocity gradient
  21296. * @param gradient defines the gradient to use (between 0 and 1)
  21297. * @param factor defines the limit velocity value to affect to the specified gradient
  21298. * @returns the current particle system
  21299. */
  21300. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  21301. /**
  21302. * Remove a specific limit velocity gradient
  21303. * @param gradient defines the gradient to remove
  21304. * @returns the current particle system
  21305. */
  21306. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  21307. /**
  21308. * Instantiates a GPU particle system.
  21309. * 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.
  21310. * @param name The name of the particle system
  21311. * @param options The options used to create the system
  21312. * @param scene The scene the particle system belongs to
  21313. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  21314. */
  21315. constructor(name: string, options: Partial<{
  21316. capacity: number;
  21317. randomTextureSize: number;
  21318. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  21319. protected _reset(): void;
  21320. private _createUpdateVAO;
  21321. private _createRenderVAO;
  21322. private _initialize;
  21323. /** @hidden */
  21324. _recreateUpdateEffect(): void;
  21325. /** @hidden */
  21326. _recreateRenderEffect(): void;
  21327. /**
  21328. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  21329. * @param preWarm defines if we are in the pre-warmimg phase
  21330. */
  21331. animate(preWarm?: boolean): void;
  21332. private _createFactorGradientTexture;
  21333. private _createSizeGradientTexture;
  21334. private _createAngularSpeedGradientTexture;
  21335. private _createVelocityGradientTexture;
  21336. private _createColorGradientTexture;
  21337. /**
  21338. * Renders the particle system in its current state
  21339. * @param preWarm defines if the system should only update the particles but not render them
  21340. * @returns the current number of particles
  21341. */
  21342. render(preWarm?: boolean): number;
  21343. /**
  21344. * Rebuilds the particle system
  21345. */
  21346. rebuild(): void;
  21347. private _releaseBuffers;
  21348. private _releaseVAOs;
  21349. /**
  21350. * Disposes the particle system and free the associated resources
  21351. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  21352. */
  21353. dispose(disposeTexture?: boolean): void;
  21354. /**
  21355. * Clones the particle system.
  21356. * @param name The name of the cloned object
  21357. * @param newEmitter The new emitter to use
  21358. * @returns the cloned particle system
  21359. */
  21360. clone(name: string, newEmitter: any): GPUParticleSystem;
  21361. /**
  21362. * Serializes the particle system to a JSON object.
  21363. * @returns the JSON object
  21364. */
  21365. serialize(): any;
  21366. /**
  21367. * Parses a JSON object to create a GPU particle system.
  21368. * @param parsedParticleSystem The JSON object to parse
  21369. * @param scene The scene to create the particle system in
  21370. * @param rootUrl The root url to use to load external dependencies like texture
  21371. * @returns the parsed GPU particle system
  21372. */
  21373. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  21374. }
  21375. }
  21376. declare module BABYLON {
  21377. /**
  21378. * Interface representing a particle system in Babylon.js.
  21379. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  21380. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  21381. */
  21382. interface IParticleSystem {
  21383. /**
  21384. * List of animations used by the particle system.
  21385. */
  21386. animations: Animation[];
  21387. /**
  21388. * The id of the Particle system.
  21389. */
  21390. id: string;
  21391. /**
  21392. * The name of the Particle system.
  21393. */
  21394. name: string;
  21395. /**
  21396. * The emitter represents the Mesh or position we are attaching the particle system to.
  21397. */
  21398. emitter: Nullable<AbstractMesh | Vector3>;
  21399. /**
  21400. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  21401. */
  21402. isBillboardBased: boolean;
  21403. /**
  21404. * The rendering group used by the Particle system to chose when to render.
  21405. */
  21406. renderingGroupId: number;
  21407. /**
  21408. * The layer mask we are rendering the particles through.
  21409. */
  21410. layerMask: number;
  21411. /**
  21412. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  21413. */
  21414. updateSpeed: number;
  21415. /**
  21416. * The amount of time the particle system is running (depends of the overall update speed).
  21417. */
  21418. targetStopDuration: number;
  21419. /**
  21420. * The texture used to render each particle. (this can be a spritesheet)
  21421. */
  21422. particleTexture: Nullable<Texture>;
  21423. /**
  21424. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  21425. */
  21426. blendMode: number;
  21427. /**
  21428. * Minimum life time of emitting particles.
  21429. */
  21430. minLifeTime: number;
  21431. /**
  21432. * Maximum life time of emitting particles.
  21433. */
  21434. maxLifeTime: number;
  21435. /**
  21436. * Minimum Size of emitting particles.
  21437. */
  21438. minSize: number;
  21439. /**
  21440. * Maximum Size of emitting particles.
  21441. */
  21442. maxSize: number;
  21443. /**
  21444. * Minimum scale of emitting particles on X axis.
  21445. */
  21446. minScaleX: number;
  21447. /**
  21448. * Maximum scale of emitting particles on X axis.
  21449. */
  21450. maxScaleX: number;
  21451. /**
  21452. * Minimum scale of emitting particles on Y axis.
  21453. */
  21454. minScaleY: number;
  21455. /**
  21456. * Maximum scale of emitting particles on Y axis.
  21457. */
  21458. maxScaleY: number;
  21459. /**
  21460. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21461. */
  21462. color1: Color4;
  21463. /**
  21464. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21465. */
  21466. color2: Color4;
  21467. /**
  21468. * Color the particle will have at the end of its lifetime.
  21469. */
  21470. colorDead: Color4;
  21471. /**
  21472. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  21473. */
  21474. emitRate: number;
  21475. /**
  21476. * You can use gravity if you want to give an orientation to your particles.
  21477. */
  21478. gravity: Vector3;
  21479. /**
  21480. * Minimum power of emitting particles.
  21481. */
  21482. minEmitPower: number;
  21483. /**
  21484. * Maximum power of emitting particles.
  21485. */
  21486. maxEmitPower: number;
  21487. /**
  21488. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  21489. */
  21490. minAngularSpeed: number;
  21491. /**
  21492. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  21493. */
  21494. maxAngularSpeed: number;
  21495. /**
  21496. * Gets or sets the minimal initial rotation in radians.
  21497. */
  21498. minInitialRotation: number;
  21499. /**
  21500. * Gets or sets the maximal initial rotation in radians.
  21501. */
  21502. maxInitialRotation: number;
  21503. /**
  21504. * The particle emitter type defines the emitter used by the particle system.
  21505. * It can be for example box, sphere, or cone...
  21506. */
  21507. particleEmitterType: Nullable<IParticleEmitterType>;
  21508. /**
  21509. * 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
  21510. */
  21511. preWarmCycles: number;
  21512. /**
  21513. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  21514. */
  21515. preWarmStepOffset: number;
  21516. /**
  21517. * 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)
  21518. */
  21519. spriteCellChangeSpeed: number;
  21520. /**
  21521. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  21522. */
  21523. startSpriteCellID: number;
  21524. /**
  21525. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  21526. */
  21527. endSpriteCellID: number;
  21528. /**
  21529. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  21530. */
  21531. spriteCellWidth: number;
  21532. /**
  21533. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  21534. */
  21535. spriteCellHeight: number;
  21536. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  21537. translationPivot: Vector2;
  21538. /**
  21539. * Gets or sets a texture used to add random noise to particle positions
  21540. */
  21541. noiseTexture: Nullable<BaseTexture>;
  21542. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  21543. noiseStrength: Vector3;
  21544. /**
  21545. * Gets or sets the billboard mode to use when isBillboardBased = true.
  21546. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  21547. */
  21548. billboardMode: number;
  21549. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  21550. limitVelocityDamping: number;
  21551. /**
  21552. * Gets the maximum number of particles active at the same time.
  21553. * @returns The max number of active particles.
  21554. */
  21555. getCapacity(): number;
  21556. /**
  21557. * Gets Wether the system has been started.
  21558. * @returns True if it has been started, otherwise false.
  21559. */
  21560. isStarted(): boolean;
  21561. /**
  21562. * Gets if the particle system has been started.
  21563. * @return true if the system has been started, otherwise false.
  21564. */
  21565. isStarted(): boolean;
  21566. /**
  21567. * Animates the particle system for this frame.
  21568. */
  21569. animate(): void;
  21570. /**
  21571. * Renders the particle system in its current state.
  21572. * @returns the current number of particles
  21573. */
  21574. render(): number;
  21575. /**
  21576. * Dispose the particle system and frees its associated resources.
  21577. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  21578. */
  21579. dispose(disposeTexture?: boolean): void;
  21580. /**
  21581. * Clones the particle system.
  21582. * @param name The name of the cloned object
  21583. * @param newEmitter The new emitter to use
  21584. * @returns the cloned particle system
  21585. */
  21586. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  21587. /**
  21588. * Serializes the particle system to a JSON object.
  21589. * @returns the JSON object
  21590. */
  21591. serialize(): any;
  21592. /**
  21593. * Rebuild the particle system
  21594. */
  21595. rebuild(): void;
  21596. /**
  21597. * Starts the particle system and begins to emit
  21598. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  21599. */
  21600. start(delay?: number): void;
  21601. /**
  21602. * Stops the particle system.
  21603. */
  21604. stop(): void;
  21605. /**
  21606. * Remove all active particles
  21607. */
  21608. reset(): void;
  21609. /**
  21610. * Is this system ready to be used/rendered
  21611. * @return true if the system is ready
  21612. */
  21613. isReady(): boolean;
  21614. /**
  21615. * Adds a new color gradient
  21616. * @param gradient defines the gradient to use (between 0 and 1)
  21617. * @param color defines the color to affect to the specified gradient
  21618. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  21619. * @returns the current particle system
  21620. */
  21621. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  21622. /**
  21623. * Remove a specific color gradient
  21624. * @param gradient defines the gradient to remove
  21625. * @returns the current particle system
  21626. */
  21627. removeColorGradient(gradient: number): IParticleSystem;
  21628. /**
  21629. * Adds a new size gradient
  21630. * @param gradient defines the gradient to use (between 0 and 1)
  21631. * @param factor defines the size factor to affect to the specified gradient
  21632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21633. * @returns the current particle system
  21634. */
  21635. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21636. /**
  21637. * Remove a specific size gradient
  21638. * @param gradient defines the gradient to remove
  21639. * @returns the current particle system
  21640. */
  21641. removeSizeGradient(gradient: number): IParticleSystem;
  21642. /**
  21643. * Gets the current list of color gradients.
  21644. * You must use addColorGradient and removeColorGradient to udpate this list
  21645. * @returns the list of color gradients
  21646. */
  21647. getColorGradients(): Nullable<Array<ColorGradient>>;
  21648. /**
  21649. * Gets the current list of size gradients.
  21650. * You must use addSizeGradient and removeSizeGradient to udpate this list
  21651. * @returns the list of size gradients
  21652. */
  21653. getSizeGradients(): Nullable<Array<FactorGradient>>;
  21654. /**
  21655. * Gets the current list of angular speed gradients.
  21656. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21657. * @returns the list of angular speed gradients
  21658. */
  21659. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21660. /**
  21661. * Adds a new angular speed gradient
  21662. * @param gradient defines the gradient to use (between 0 and 1)
  21663. * @param factor defines the angular speed to affect to the specified gradient
  21664. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21665. * @returns the current particle system
  21666. */
  21667. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21668. /**
  21669. * Remove a specific angular speed gradient
  21670. * @param gradient defines the gradient to remove
  21671. * @returns the current particle system
  21672. */
  21673. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21674. /**
  21675. * Gets the current list of velocity gradients.
  21676. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21677. * @returns the list of velocity gradients
  21678. */
  21679. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21680. /**
  21681. * Adds a new velocity gradient
  21682. * @param gradient defines the gradient to use (between 0 and 1)
  21683. * @param factor defines the velocity to affect to the specified gradient
  21684. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21685. * @returns the current particle system
  21686. */
  21687. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21688. /**
  21689. * Remove a specific velocity gradient
  21690. * @param gradient defines the gradient to remove
  21691. * @returns the current particle system
  21692. */
  21693. removeVelocityGradient(gradient: number): IParticleSystem;
  21694. /**
  21695. * Gets the current list of limit velocity gradients.
  21696. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  21697. * @returns the list of limit velocity gradients
  21698. */
  21699. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  21700. /**
  21701. * Adds a new limit velocity gradient
  21702. * @param gradient defines the gradient to use (between 0 and 1)
  21703. * @param factor defines the limit velocity to affect to the specified gradient
  21704. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21705. * @returns the current particle system
  21706. */
  21707. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21708. /**
  21709. * Remove a specific limit velocity gradient
  21710. * @param gradient defines the gradient to remove
  21711. * @returns the current particle system
  21712. */
  21713. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  21714. }
  21715. }
  21716. declare module BABYLON {
  21717. /**
  21718. * A particle represents one of the element emitted by a particle system.
  21719. * This is mainly define by its coordinates, direction, velocity and age.
  21720. */
  21721. class Particle {
  21722. /**
  21723. * particleSystem the particle system the particle belongs to.
  21724. */
  21725. particleSystem: ParticleSystem;
  21726. /**
  21727. * The world position of the particle in the scene.
  21728. */
  21729. position: Vector3;
  21730. /**
  21731. * The world direction of the particle in the scene.
  21732. */
  21733. direction: Vector3;
  21734. /**
  21735. * The color of the particle.
  21736. */
  21737. color: Color4;
  21738. /**
  21739. * The color change of the particle per step.
  21740. */
  21741. colorStep: Color4;
  21742. /**
  21743. * Defines how long will the life of the particle be.
  21744. */
  21745. lifeTime: number;
  21746. /**
  21747. * The current age of the particle.
  21748. */
  21749. age: number;
  21750. /**
  21751. * The current size of the particle.
  21752. */
  21753. size: number;
  21754. /**
  21755. * The current scale of the particle.
  21756. */
  21757. scale: Vector2;
  21758. /**
  21759. * The current angle of the particle.
  21760. */
  21761. angle: number;
  21762. /**
  21763. * Defines how fast is the angle changing.
  21764. */
  21765. angularSpeed: number;
  21766. /**
  21767. * Defines the cell index used by the particle to be rendered from a sprite.
  21768. */
  21769. cellIndex: number;
  21770. /** @hidden */
  21771. _initialDirection: Nullable<Vector3>;
  21772. /** @hidden */
  21773. _initialStartSpriteCellID: number;
  21774. _initialEndSpriteCellID: number;
  21775. /** @hidden */
  21776. _currentColorGradient: Nullable<ColorGradient>;
  21777. /** @hidden */
  21778. _currentColor1: Color4;
  21779. /** @hidden */
  21780. _currentColor2: Color4;
  21781. /** @hidden */
  21782. _currentSizeGradient: Nullable<FactorGradient>;
  21783. /** @hidden */
  21784. _currentSize1: number;
  21785. /** @hidden */
  21786. _currentSize2: number;
  21787. /** @hidden */
  21788. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  21789. /** @hidden */
  21790. _currentAngularSpeed1: number;
  21791. /** @hidden */
  21792. _currentAngularSpeed2: number;
  21793. /** @hidden */
  21794. _currentVelocityGradient: Nullable<FactorGradient>;
  21795. /** @hidden */
  21796. _currentVelocity1: number;
  21797. /** @hidden */
  21798. _currentVelocity2: number;
  21799. /** @hidden */
  21800. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  21801. /** @hidden */
  21802. _currentLimitVelocity1: number;
  21803. /** @hidden */
  21804. _currentLimitVelocity2: number;
  21805. /**
  21806. * Creates a new instance Particle
  21807. * @param particleSystem the particle system the particle belongs to
  21808. */
  21809. constructor(
  21810. /**
  21811. * particleSystem the particle system the particle belongs to.
  21812. */
  21813. particleSystem: ParticleSystem);
  21814. private updateCellInfoFromSystem;
  21815. /**
  21816. * Defines how the sprite cell index is updated for the particle
  21817. */
  21818. updateCellIndex(): void;
  21819. /**
  21820. * Copy the properties of particle to another one.
  21821. * @param other the particle to copy the information to.
  21822. */
  21823. copyTo(other: Particle): void;
  21824. }
  21825. }
  21826. declare module BABYLON {
  21827. /**
  21828. * This class is made for on one-liner static method to help creating particle system set.
  21829. */
  21830. class ParticleHelper {
  21831. /**
  21832. * Gets or sets base Assets URL
  21833. */
  21834. static BaseAssetsUrl: string;
  21835. /**
  21836. * Create a default particle system that you can tweak
  21837. * @param emitter defines the emitter to use
  21838. * @param capacity defines the system capacity (default is 500 particles)
  21839. * @param scene defines the hosting scene
  21840. * @returns the new Particle system
  21841. */
  21842. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene): ParticleSystem;
  21843. /**
  21844. * This is the main static method (one-liner) of this helper to create different particle systems
  21845. * @param type This string represents the type to the particle system to create
  21846. * @param scene The scene where the particle system should live
  21847. * @param gpu If the system will use gpu
  21848. * @returns the ParticleSystemSet created
  21849. */
  21850. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  21851. /**
  21852. * Static function used to export a particle system to a ParticleSystemSet variable.
  21853. * Please note that the emitter shape is not exported
  21854. * @param system defines the particle systems to export
  21855. */
  21856. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  21857. }
  21858. }
  21859. declare module BABYLON {
  21860. /**
  21861. * This represents a particle system in Babylon.
  21862. * 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.
  21863. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  21864. * @example https://doc.babylonjs.com/babylon101/particles
  21865. */
  21866. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  21867. /**
  21868. * This function can be defined to provide custom update for active particles.
  21869. * This function will be called instead of regular update (age, position, color, etc.).
  21870. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  21871. */
  21872. updateFunction: (particles: Particle[]) => void;
  21873. private _emitterWorldMatrix;
  21874. /**
  21875. * This function can be defined to specify initial direction for every new particle.
  21876. * It by default use the emitterType defined function
  21877. */
  21878. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  21879. /**
  21880. * This function can be defined to specify initial position for every new particle.
  21881. * It by default use the emitterType defined function
  21882. */
  21883. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  21884. /**
  21885. * An event triggered when the system is disposed
  21886. */
  21887. onDisposeObservable: Observable<ParticleSystem>;
  21888. private _onDisposeObserver;
  21889. /**
  21890. * Sets a callback that will be triggered when the system is disposed
  21891. */
  21892. onDispose: () => void;
  21893. /**
  21894. * Get hosting scene
  21895. * @returns the scene
  21896. */
  21897. getScene(): Scene;
  21898. private _particles;
  21899. private _epsilon;
  21900. private _capacity;
  21901. private _stockParticles;
  21902. private _newPartsExcess;
  21903. private _vertexData;
  21904. private _vertexBuffer;
  21905. private _vertexBuffers;
  21906. private _spriteBuffer;
  21907. private _indexBuffer;
  21908. private _effect;
  21909. private _customEffect;
  21910. private _cachedDefines;
  21911. private _scaledColorStep;
  21912. private _colorDiff;
  21913. private _scaledDirection;
  21914. private _scaledGravity;
  21915. private _currentRenderId;
  21916. private _alive;
  21917. private _useInstancing;
  21918. private _started;
  21919. private _stopped;
  21920. private _actualFrame;
  21921. private _scaledUpdateSpeed;
  21922. private _vertexBufferSize;
  21923. /**
  21924. * this is the Sub-emitters templates that will be used to generate particle system when the particle dies, this property is used by the root particle system only.
  21925. */
  21926. subEmitters: ParticleSystem[];
  21927. /**
  21928. * The current active Sub-systems, this property is used by the root particle system only.
  21929. */
  21930. activeSubSystems: Array<ParticleSystem>;
  21931. private _rootParticleSystem;
  21932. /**
  21933. * Gets the current list of active particles
  21934. */
  21935. readonly particles: Particle[];
  21936. /**
  21937. * Returns the string "ParticleSystem"
  21938. * @returns a string containing the class name
  21939. */
  21940. getClassName(): string;
  21941. /**
  21942. * Instantiates a particle system.
  21943. * 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.
  21944. * @param name The name of the particle system
  21945. * @param capacity The max number of particles alive at the same time
  21946. * @param scene The scene the particle system belongs to
  21947. * @param customEffect a custom effect used to change the way particles are rendered by default
  21948. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  21949. * @param epsilon Offset used to render the particles
  21950. */
  21951. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  21952. private _addFactorGradient;
  21953. private _removeFactorGradient;
  21954. /**
  21955. * Adds a new life time gradient
  21956. * @param gradient defines the gradient to use (between 0 and 1)
  21957. * @param factor defines the life time factor to affect to the specified gradient
  21958. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21959. * @returns the current particle system
  21960. */
  21961. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21962. /**
  21963. * Remove a specific life time gradient
  21964. * @param gradient defines the gradient to remove
  21965. * @returns the current particle system
  21966. */
  21967. removeLifeTimeGradient(gradient: number): IParticleSystem;
  21968. /**
  21969. * Adds a new size gradient
  21970. * @param gradient defines the gradient to use (between 0 and 1)
  21971. * @param factor defines the size factor to affect to the specified gradient
  21972. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21973. * @returns the current particle system
  21974. */
  21975. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21976. /**
  21977. * Remove a specific size gradient
  21978. * @param gradient defines the gradient to remove
  21979. * @returns the current particle system
  21980. */
  21981. removeSizeGradient(gradient: number): IParticleSystem;
  21982. /**
  21983. * Adds a new angular speed gradient
  21984. * @param gradient defines the gradient to use (between 0 and 1)
  21985. * @param factor defines the angular speed to affect to the specified gradient
  21986. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21987. * @returns the current particle system
  21988. */
  21989. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21990. /**
  21991. * Remove a specific angular speed gradient
  21992. * @param gradient defines the gradient to remove
  21993. * @returns the current particle system
  21994. */
  21995. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21996. /**
  21997. * Adds a new velocity gradient
  21998. * @param gradient defines the gradient to use (between 0 and 1)
  21999. * @param factor defines the velocity to affect to the specified gradient
  22000. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  22001. * @returns the current particle system
  22002. */
  22003. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  22004. /**
  22005. * Remove a specific velocity gradient
  22006. * @param gradient defines the gradient to remove
  22007. * @returns the current particle system
  22008. */
  22009. removeVelocityGradient(gradient: number): IParticleSystem;
  22010. /**
  22011. * Adds a new limit velocity gradient
  22012. * @param gradient defines the gradient to use (between 0 and 1)
  22013. * @param factor defines the limit velocity value to affect to the specified gradient
  22014. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  22015. * @returns the current particle system
  22016. */
  22017. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  22018. /**
  22019. * Remove a specific limit velocity gradient
  22020. * @param gradient defines the gradient to remove
  22021. * @returns the current particle system
  22022. */
  22023. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  22024. /**
  22025. * Adds a new color gradient
  22026. * @param gradient defines the gradient to use (between 0 and 1)
  22027. * @param color defines the color to affect to the specified gradient
  22028. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  22029. */
  22030. addColorGradient(gradient: number, color: Color4, color2?: Color4): IParticleSystem;
  22031. /**
  22032. * Remove a specific color gradient
  22033. * @param gradient defines the gradient to remove
  22034. */
  22035. removeColorGradient(gradient: number): IParticleSystem;
  22036. private _fetchR;
  22037. protected _reset(): void;
  22038. private _resetEffect;
  22039. private _createVertexBuffers;
  22040. private _createIndexBuffer;
  22041. /**
  22042. * Gets the maximum number of particles active at the same time.
  22043. * @returns The max number of active particles.
  22044. */
  22045. getCapacity(): number;
  22046. /**
  22047. * Gets whether there are still active particles in the system.
  22048. * @returns True if it is alive, otherwise false.
  22049. */
  22050. isAlive(): boolean;
  22051. /**
  22052. * Gets whether the system has been started.
  22053. * @returns True if it has been started, otherwise false.
  22054. */
  22055. isStarted(): boolean;
  22056. /**
  22057. * Starts the particle system and begins to emit
  22058. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  22059. */
  22060. start(delay?: number): void;
  22061. /**
  22062. * Stops the particle system.
  22063. * @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.
  22064. */
  22065. stop(stopSubEmitters?: boolean): void;
  22066. /**
  22067. * Remove all active particles
  22068. */
  22069. reset(): void;
  22070. /**
  22071. * @hidden (for internal use only)
  22072. */
  22073. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  22074. /**
  22075. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  22076. * Its lifetime will start back at 0.
  22077. */
  22078. recycleParticle: (particle: Particle) => void;
  22079. private _stopSubEmitters;
  22080. private _createParticle;
  22081. private _removeFromRoot;
  22082. private _emitFromParticle;
  22083. private _update;
  22084. /** @hidden */
  22085. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean): string[];
  22086. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  22087. private _getEffect;
  22088. /**
  22089. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  22090. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  22091. */
  22092. animate(preWarmOnly?: boolean): void;
  22093. private _appendParticleVertices;
  22094. /**
  22095. * Rebuilds the particle system.
  22096. */
  22097. rebuild(): void;
  22098. /**
  22099. * Is this system ready to be used/rendered
  22100. * @return true if the system is ready
  22101. */
  22102. isReady(): boolean;
  22103. /**
  22104. * Renders the particle system in its current state.
  22105. * @returns the current number of particles
  22106. */
  22107. render(): number;
  22108. /**
  22109. * Disposes the particle system and free the associated resources
  22110. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  22111. */
  22112. dispose(disposeTexture?: boolean): void;
  22113. /**
  22114. * Clones the particle system.
  22115. * @param name The name of the cloned object
  22116. * @param newEmitter The new emitter to use
  22117. * @returns the cloned particle system
  22118. */
  22119. clone(name: string, newEmitter: any): ParticleSystem;
  22120. /**
  22121. * Serializes the particle system to a JSON object.
  22122. * @returns the JSON object
  22123. */
  22124. serialize(): any;
  22125. /** @hidden */
  22126. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  22127. /** @hidden */
  22128. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  22129. /**
  22130. * Parses a JSON object to create a particle system.
  22131. * @param parsedParticleSystem The JSON object to parse
  22132. * @param scene The scene to create the particle system in
  22133. * @param rootUrl The root url to use to load external dependencies like texture
  22134. * @returns the Parsed particle system
  22135. */
  22136. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  22137. }
  22138. }
  22139. declare module BABYLON {
  22140. interface Engine {
  22141. /**
  22142. * Create an effect to use with particle systems.
  22143. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  22144. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  22145. * @param uniformsNames defines a list of attribute names
  22146. * @param samplers defines an array of string used to represent textures
  22147. * @param defines defines the string containing the defines to use to compile the shaders
  22148. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  22149. * @param onCompiled defines a function to call when the effect creation is successful
  22150. * @param onError defines a function to call when the effect creation has failed
  22151. * @returns the new Effect
  22152. */
  22153. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  22154. }
  22155. }
  22156. declare module BABYLON {
  22157. /**
  22158. * Represents a set of particle systems working together to create a specific effect
  22159. */
  22160. class ParticleSystemSet implements IDisposable {
  22161. private _emitterCreationOptions;
  22162. private _emitterNode;
  22163. /**
  22164. * Gets the particle system list
  22165. */
  22166. systems: IParticleSystem[];
  22167. /**
  22168. * Gets the emitter node used with this set
  22169. */
  22170. readonly emitterNode: Nullable<TransformNode>;
  22171. /**
  22172. * Creates a new emitter mesh as a sphere
  22173. * @param options defines the options used to create the sphere
  22174. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  22175. * @param scene defines the hosting scene
  22176. */
  22177. setEmitterAsSphere(options: {
  22178. diameter: number;
  22179. segments: number;
  22180. color: Color3;
  22181. }, renderingGroupId: number, scene: Scene): void;
  22182. /**
  22183. * Starts all particle systems of the set
  22184. * @param emitter defines an optional mesh to use as emitter for the particle systems
  22185. */
  22186. start(emitter?: AbstractMesh): void;
  22187. /**
  22188. * Release all associated resources
  22189. */
  22190. dispose(): void;
  22191. /**
  22192. * Serialize the set into a JSON compatible object
  22193. * @returns a JSON compatible representation of the set
  22194. */
  22195. serialize(): any;
  22196. /**
  22197. * Parse a new ParticleSystemSet from a serialized source
  22198. * @param data defines a JSON compatible representation of the set
  22199. * @param scene defines the hosting scene
  22200. * @param gpu defines if we want GPU particles or CPU particles
  22201. * @returns a new ParticleSystemSet
  22202. */
  22203. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  22204. }
  22205. }
  22206. declare module BABYLON {
  22207. /**
  22208. * Represents one particle of a solid particle system.
  22209. */
  22210. class SolidParticle {
  22211. /**
  22212. * particle global index
  22213. */
  22214. idx: number;
  22215. /**
  22216. * The color of the particle
  22217. */
  22218. color: Nullable<Color4>;
  22219. /**
  22220. * The world space position of the particle.
  22221. */
  22222. position: Vector3;
  22223. /**
  22224. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  22225. */
  22226. rotation: Vector3;
  22227. /**
  22228. * The world space rotation quaternion of the particle.
  22229. */
  22230. rotationQuaternion: Nullable<Quaternion>;
  22231. /**
  22232. * The scaling of the particle.
  22233. */
  22234. scaling: Vector3;
  22235. /**
  22236. * The uvs of the particle.
  22237. */
  22238. uvs: Vector4;
  22239. /**
  22240. * The current speed of the particle.
  22241. */
  22242. velocity: Vector3;
  22243. /**
  22244. * The pivot point in the particle local space.
  22245. */
  22246. pivot: Vector3;
  22247. /**
  22248. * Must the particle be translated from its pivot point in its local space ?
  22249. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  22250. * Default : false
  22251. */
  22252. translateFromPivot: boolean;
  22253. /**
  22254. * Is the particle active or not ?
  22255. */
  22256. alive: boolean;
  22257. /**
  22258. * Is the particle visible or not ?
  22259. */
  22260. isVisible: boolean;
  22261. /**
  22262. * Index of this particle in the global "positions" array (Internal use)
  22263. * @hidden
  22264. */
  22265. _pos: number;
  22266. /**
  22267. * @hidden Index of this particle in the global "indices" array (Internal use)
  22268. */
  22269. _ind: number;
  22270. /**
  22271. * @hidden ModelShape of this particle (Internal use)
  22272. */
  22273. _model: ModelShape;
  22274. /**
  22275. * ModelShape id of this particle
  22276. */
  22277. shapeId: number;
  22278. /**
  22279. * Index of the particle in its shape id (Internal use)
  22280. */
  22281. idxInShape: number;
  22282. /**
  22283. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  22284. */
  22285. _modelBoundingInfo: BoundingInfo;
  22286. /**
  22287. * @hidden Particle BoundingInfo object (Internal use)
  22288. */
  22289. _boundingInfo: BoundingInfo;
  22290. /**
  22291. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  22292. */
  22293. _sps: SolidParticleSystem;
  22294. /**
  22295. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  22296. */
  22297. _stillInvisible: boolean;
  22298. /**
  22299. * @hidden Last computed particle rotation matrix
  22300. */
  22301. _rotationMatrix: number[];
  22302. /**
  22303. * Parent particle Id, if any.
  22304. * Default null.
  22305. */
  22306. parentId: Nullable<number>;
  22307. /**
  22308. * @hidden Internal global position in the SPS.
  22309. */
  22310. _globalPosition: Vector3;
  22311. /**
  22312. * Creates a Solid Particle object.
  22313. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  22314. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  22315. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  22316. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  22317. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  22318. * @param shapeId (integer) is the model shape identifier in the SPS.
  22319. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  22320. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  22321. */
  22322. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  22323. /**
  22324. * Legacy support, changed scale to scaling
  22325. */
  22326. /**
  22327. * Legacy support, changed scale to scaling
  22328. */
  22329. scale: Vector3;
  22330. /**
  22331. * Legacy support, changed quaternion to rotationQuaternion
  22332. */
  22333. /**
  22334. * Legacy support, changed quaternion to rotationQuaternion
  22335. */
  22336. quaternion: Nullable<Quaternion>;
  22337. /**
  22338. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  22339. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  22340. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  22341. * @returns true if it intersects
  22342. */
  22343. intersectsMesh(target: Mesh | SolidParticle): boolean;
  22344. }
  22345. /**
  22346. * Represents the shape of the model used by one particle of a solid particle system.
  22347. * SPS internal tool, don't use it manually.
  22348. */
  22349. class ModelShape {
  22350. /**
  22351. * The shape id
  22352. * @hidden
  22353. */
  22354. shapeID: number;
  22355. /**
  22356. * flat array of model positions (internal use)
  22357. * @hidden
  22358. */
  22359. _shape: Vector3[];
  22360. /**
  22361. * flat array of model UVs (internal use)
  22362. * @hidden
  22363. */
  22364. _shapeUV: number[];
  22365. /**
  22366. * length of the shape in the model indices array (internal use)
  22367. * @hidden
  22368. */
  22369. _indicesLength: number;
  22370. /**
  22371. * Custom position function (internal use)
  22372. * @hidden
  22373. */
  22374. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  22375. /**
  22376. * Custom vertex function (internal use)
  22377. * @hidden
  22378. */
  22379. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  22380. /**
  22381. * 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.
  22382. * SPS internal tool, don't use it manually.
  22383. * @hidden
  22384. */
  22385. 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>);
  22386. }
  22387. /**
  22388. * Represents a Depth Sorted Particle in the solid particle system.
  22389. */
  22390. class DepthSortedParticle {
  22391. /**
  22392. * Index of the particle in the "indices" array
  22393. */
  22394. ind: number;
  22395. /**
  22396. * Length of the particle shape in the "indices" array
  22397. */
  22398. indicesLength: number;
  22399. /**
  22400. * Squared distance from the particle to the camera
  22401. */
  22402. sqDistance: number;
  22403. }
  22404. }
  22405. declare module BABYLON {
  22406. /**
  22407. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  22408. *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.
  22409. * The SPS is also a particle system. It provides some methods to manage the particles.
  22410. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  22411. *
  22412. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  22413. */
  22414. class SolidParticleSystem implements IDisposable {
  22415. /**
  22416. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  22417. * Example : var p = SPS.particles[i];
  22418. */
  22419. particles: SolidParticle[];
  22420. /**
  22421. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  22422. */
  22423. nbParticles: number;
  22424. /**
  22425. * If the particles must ever face the camera (default false). Useful for planar particles.
  22426. */
  22427. billboard: boolean;
  22428. /**
  22429. * Recompute normals when adding a shape
  22430. */
  22431. recomputeNormals: boolean;
  22432. /**
  22433. * This a counter ofr your own usage. It's not set by any SPS functions.
  22434. */
  22435. counter: number;
  22436. /**
  22437. * The SPS name. This name is also given to the underlying mesh.
  22438. */
  22439. name: string;
  22440. /**
  22441. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  22442. */
  22443. mesh: Mesh;
  22444. /**
  22445. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  22446. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  22447. */
  22448. vars: any;
  22449. /**
  22450. * This array is populated when the SPS is set as 'pickable'.
  22451. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  22452. * Each element of this array is an object `{idx: int, faceId: int}`.
  22453. * `idx` is the picked particle index in the `SPS.particles` array
  22454. * `faceId` is the picked face index counted within this particle.
  22455. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  22456. */
  22457. pickedParticles: {
  22458. idx: number;
  22459. faceId: number;
  22460. }[];
  22461. /**
  22462. * This array is populated when `enableDepthSort` is set to true.
  22463. * Each element of this array is an instance of the class DepthSortedParticle.
  22464. */
  22465. depthSortedParticles: DepthSortedParticle[];
  22466. /**
  22467. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  22468. * @hidden
  22469. */
  22470. _bSphereOnly: boolean;
  22471. /**
  22472. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  22473. * @hidden
  22474. */
  22475. _bSphereRadiusFactor: number;
  22476. private _scene;
  22477. private _positions;
  22478. private _indices;
  22479. private _normals;
  22480. private _colors;
  22481. private _uvs;
  22482. private _indices32;
  22483. private _positions32;
  22484. private _normals32;
  22485. private _fixedNormal32;
  22486. private _colors32;
  22487. private _uvs32;
  22488. private _index;
  22489. private _updatable;
  22490. private _pickable;
  22491. private _isVisibilityBoxLocked;
  22492. private _alwaysVisible;
  22493. private _depthSort;
  22494. private _shapeCounter;
  22495. private _copy;
  22496. private _shape;
  22497. private _shapeUV;
  22498. private _color;
  22499. private _computeParticleColor;
  22500. private _computeParticleTexture;
  22501. private _computeParticleRotation;
  22502. private _computeParticleVertex;
  22503. private _computeBoundingBox;
  22504. private _depthSortParticles;
  22505. private _cam_axisZ;
  22506. private _cam_axisY;
  22507. private _cam_axisX;
  22508. private _axisZ;
  22509. private _camera;
  22510. private _particle;
  22511. private _camDir;
  22512. private _camInvertedPosition;
  22513. private _rotMatrix;
  22514. private _invertMatrix;
  22515. private _rotated;
  22516. private _quaternion;
  22517. private _vertex;
  22518. private _normal;
  22519. private _yaw;
  22520. private _pitch;
  22521. private _roll;
  22522. private _halfroll;
  22523. private _halfpitch;
  22524. private _halfyaw;
  22525. private _sinRoll;
  22526. private _cosRoll;
  22527. private _sinPitch;
  22528. private _cosPitch;
  22529. private _sinYaw;
  22530. private _cosYaw;
  22531. private _mustUnrotateFixedNormals;
  22532. private _minimum;
  22533. private _maximum;
  22534. private _minBbox;
  22535. private _maxBbox;
  22536. private _particlesIntersect;
  22537. private _depthSortFunction;
  22538. private _needs32Bits;
  22539. private _pivotBackTranslation;
  22540. private _scaledPivot;
  22541. private _particleHasParent;
  22542. private _parent;
  22543. /**
  22544. * Creates a SPS (Solid Particle System) object.
  22545. * @param name (String) is the SPS name, this will be the underlying mesh name.
  22546. * @param scene (Scene) is the scene in which the SPS is added.
  22547. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  22548. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  22549. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  22550. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  22551. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  22552. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  22553. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  22554. */
  22555. constructor(name: string, scene: Scene, options?: {
  22556. updatable?: boolean;
  22557. isPickable?: boolean;
  22558. enableDepthSort?: boolean;
  22559. particleIntersection?: boolean;
  22560. boundingSphereOnly?: boolean;
  22561. bSphereRadiusFactor?: number;
  22562. });
  22563. /**
  22564. * Builds the SPS underlying mesh. Returns a standard Mesh.
  22565. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  22566. * @returns the created mesh
  22567. */
  22568. buildMesh(): Mesh;
  22569. /**
  22570. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  22571. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  22572. * Thus the particles generated from `digest()` have their property `position` set yet.
  22573. * @param mesh ( Mesh ) is the mesh to be digested
  22574. * @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
  22575. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  22576. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  22577. * @returns the current SPS
  22578. */
  22579. digest(mesh: Mesh, options?: {
  22580. facetNb?: number;
  22581. number?: number;
  22582. delta?: number;
  22583. }): SolidParticleSystem;
  22584. private _unrotateFixedNormals;
  22585. private _resetCopy;
  22586. private _meshBuilder;
  22587. private _posToShape;
  22588. private _uvsToShapeUV;
  22589. private _addParticle;
  22590. /**
  22591. * Adds some particles to the SPS from the model shape. Returns the shape id.
  22592. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  22593. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  22594. * @param nb (positive integer) the number of particles to be created from this model
  22595. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  22596. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  22597. * @returns the number of shapes in the system
  22598. */
  22599. addShape(mesh: Mesh, nb: number, options?: {
  22600. positionFunction?: any;
  22601. vertexFunction?: any;
  22602. }): number;
  22603. private _rebuildParticle;
  22604. /**
  22605. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  22606. * @returns the SPS.
  22607. */
  22608. rebuildMesh(): SolidParticleSystem;
  22609. /**
  22610. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  22611. * This method calls `updateParticle()` for each particle of the SPS.
  22612. * For an animated SPS, it is usually called within the render loop.
  22613. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  22614. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  22615. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  22616. * @returns the SPS.
  22617. */
  22618. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  22619. private _quaternionRotationYPR;
  22620. private _quaternionToRotationMatrix;
  22621. /**
  22622. * Disposes the SPS.
  22623. */
  22624. dispose(): void;
  22625. /**
  22626. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  22627. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22628. * @returns the SPS.
  22629. */
  22630. refreshVisibleSize(): SolidParticleSystem;
  22631. /**
  22632. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  22633. * @param size the size (float) of the visibility box
  22634. * note : this doesn't lock the SPS mesh bounding box.
  22635. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22636. */
  22637. setVisibilityBox(size: number): void;
  22638. /**
  22639. * Gets whether the SPS as always visible or not
  22640. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22641. */
  22642. /**
  22643. * Sets the SPS as always visible or not
  22644. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22645. */
  22646. isAlwaysVisible: boolean;
  22647. /**
  22648. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22649. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22650. */
  22651. /**
  22652. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22653. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22654. */
  22655. isVisibilityBoxLocked: boolean;
  22656. /**
  22657. * Tells to `setParticles()` to compute the particle rotations or not.
  22658. * Default value : true. The SPS is faster when it's set to false.
  22659. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22660. */
  22661. /**
  22662. * Gets if `setParticles()` computes the particle rotations or not.
  22663. * Default value : true. The SPS is faster when it's set to false.
  22664. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22665. */
  22666. computeParticleRotation: boolean;
  22667. /**
  22668. * Tells to `setParticles()` to compute the particle colors or not.
  22669. * Default value : true. The SPS is faster when it's set to false.
  22670. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22671. */
  22672. /**
  22673. * Gets if `setParticles()` computes the particle colors or not.
  22674. * Default value : true. The SPS is faster when it's set to false.
  22675. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22676. */
  22677. computeParticleColor: boolean;
  22678. /**
  22679. * Gets if `setParticles()` computes the particle textures or not.
  22680. * Default value : true. The SPS is faster when it's set to false.
  22681. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  22682. */
  22683. computeParticleTexture: boolean;
  22684. /**
  22685. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  22686. * Default value : false. The SPS is faster when it's set to false.
  22687. * Note : the particle custom vertex positions aren't stored values.
  22688. */
  22689. /**
  22690. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  22691. * Default value : false. The SPS is faster when it's set to false.
  22692. * Note : the particle custom vertex positions aren't stored values.
  22693. */
  22694. computeParticleVertex: boolean;
  22695. /**
  22696. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  22697. */
  22698. /**
  22699. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  22700. */
  22701. computeBoundingBox: boolean;
  22702. /**
  22703. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  22704. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22705. * Default : `true`
  22706. */
  22707. /**
  22708. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  22709. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22710. * Default : `true`
  22711. */
  22712. depthSortParticles: boolean;
  22713. /**
  22714. * This function does nothing. It may be overwritten to set all the particle first values.
  22715. * The SPS doesn't call this function, you may have to call it by your own.
  22716. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22717. */
  22718. initParticles(): void;
  22719. /**
  22720. * This function does nothing. It may be overwritten to recycle a particle.
  22721. * The SPS doesn't call this function, you may have to call it by your own.
  22722. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22723. * @param particle The particle to recycle
  22724. * @returns the recycled particle
  22725. */
  22726. recycleParticle(particle: SolidParticle): SolidParticle;
  22727. /**
  22728. * Updates a particle : this function should be overwritten by the user.
  22729. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  22730. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22731. * @example : just set a particle position or velocity and recycle conditions
  22732. * @param particle The particle to update
  22733. * @returns the updated particle
  22734. */
  22735. updateParticle(particle: SolidParticle): SolidParticle;
  22736. /**
  22737. * Updates a vertex of a particle : it can be overwritten by the user.
  22738. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  22739. * @param particle the current particle
  22740. * @param vertex the current index of the current particle
  22741. * @param pt the index of the current vertex in the particle shape
  22742. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  22743. * @example : just set a vertex particle position
  22744. * @returns the updated vertex
  22745. */
  22746. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  22747. /**
  22748. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  22749. * This does nothing and may be overwritten by the user.
  22750. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22751. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22752. * @param update the boolean update value actually passed to setParticles()
  22753. */
  22754. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22755. /**
  22756. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  22757. * This will be passed three parameters.
  22758. * This does nothing and may be overwritten by the user.
  22759. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22760. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22761. * @param update the boolean update value actually passed to setParticles()
  22762. */
  22763. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22764. }
  22765. }
  22766. declare module BABYLON {
  22767. interface PhysicsImpostorJoint {
  22768. mainImpostor: PhysicsImpostor;
  22769. connectedImpostor: PhysicsImpostor;
  22770. joint: PhysicsJoint;
  22771. }
  22772. class PhysicsEngine {
  22773. private _physicsPlugin;
  22774. gravity: Vector3;
  22775. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  22776. setGravity(gravity: Vector3): void;
  22777. /**
  22778. * Set the time step of the physics engine.
  22779. * default is 1/60.
  22780. * To slow it down, enter 1/600 for example.
  22781. * To speed it up, 1/30
  22782. * @param {number} newTimeStep the new timestep to apply to this world.
  22783. */
  22784. setTimeStep(newTimeStep?: number): void;
  22785. /**
  22786. * Get the time step of the physics engine.
  22787. */
  22788. getTimeStep(): number;
  22789. dispose(): void;
  22790. getPhysicsPluginName(): string;
  22791. static Epsilon: number;
  22792. private _impostors;
  22793. private _joints;
  22794. /**
  22795. * Adding a new impostor for the impostor tracking.
  22796. * This will be done by the impostor itself.
  22797. * @param {PhysicsImpostor} impostor the impostor to add
  22798. */
  22799. addImpostor(impostor: PhysicsImpostor): void;
  22800. /**
  22801. * Remove an impostor from the engine.
  22802. * This impostor and its mesh will not longer be updated by the physics engine.
  22803. * @param {PhysicsImpostor} impostor the impostor to remove
  22804. */
  22805. removeImpostor(impostor: PhysicsImpostor): void;
  22806. /**
  22807. * Add a joint to the physics engine
  22808. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  22809. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  22810. * @param {PhysicsJoint} the joint that will connect both impostors.
  22811. */
  22812. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22813. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22814. /**
  22815. * Called by the scene. no need to call it.
  22816. * @hidden
  22817. */
  22818. _step(delta: number): void;
  22819. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22820. getImpostors(): Array<PhysicsImpostor>;
  22821. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22822. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22823. }
  22824. interface IPhysicsEnginePlugin {
  22825. world: any;
  22826. name: string;
  22827. setGravity(gravity: Vector3): void;
  22828. setTimeStep(timeStep: number): void;
  22829. getTimeStep(): number;
  22830. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22831. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22832. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22833. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22834. removePhysicsBody(impostor: PhysicsImpostor): void;
  22835. generateJoint(joint: PhysicsImpostorJoint): void;
  22836. removeJoint(joint: PhysicsImpostorJoint): void;
  22837. isSupported(): boolean;
  22838. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22839. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22840. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22841. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22842. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22843. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22844. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22845. getBodyMass(impostor: PhysicsImpostor): number;
  22846. getBodyFriction(impostor: PhysicsImpostor): number;
  22847. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22848. getBodyRestitution(impostor: PhysicsImpostor): number;
  22849. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22850. sleepBody(impostor: PhysicsImpostor): void;
  22851. wakeUpBody(impostor: PhysicsImpostor): void;
  22852. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22853. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22854. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22855. getRadius(impostor: PhysicsImpostor): number;
  22856. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22857. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22858. dispose(): void;
  22859. }
  22860. }
  22861. declare module BABYLON {
  22862. class PhysicsHelper {
  22863. private _scene;
  22864. private _physicsEngine;
  22865. constructor(scene: Scene);
  22866. /**
  22867. * @param {Vector3} origin the origin of the explosion
  22868. * @param {number} radius the explosion radius
  22869. * @param {number} strength the explosion strength
  22870. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  22871. */
  22872. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  22873. /**
  22874. * @param {Vector3} origin the origin of the explosion
  22875. * @param {number} radius the explosion radius
  22876. * @param {number} strength the explosion strength
  22877. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  22878. */
  22879. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  22880. /**
  22881. * @param {Vector3} origin the origin of the explosion
  22882. * @param {number} radius the explosion radius
  22883. * @param {number} strength the explosion strength
  22884. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  22885. */
  22886. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  22887. /**
  22888. * @param {Vector3} origin the origin of the updraft
  22889. * @param {number} radius the radius of the updraft
  22890. * @param {number} strength the strength of the updraft
  22891. * @param {number} height the height of the updraft
  22892. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  22893. */
  22894. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  22895. /**
  22896. * @param {Vector3} origin the of the vortex
  22897. * @param {number} radius the radius of the vortex
  22898. * @param {number} strength the strength of the vortex
  22899. * @param {number} height the height of the vortex
  22900. */
  22901. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  22902. }
  22903. /***** Radial explosion *****/
  22904. class PhysicsRadialExplosionEvent {
  22905. private _scene;
  22906. private _sphere;
  22907. private _sphereOptions;
  22908. private _rays;
  22909. private _dataFetched;
  22910. constructor(scene: Scene);
  22911. /**
  22912. * Returns the data related to the radial explosion event (sphere & rays).
  22913. * @returns {PhysicsRadialExplosionEventData}
  22914. */
  22915. getData(): PhysicsRadialExplosionEventData;
  22916. /**
  22917. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  22918. * @param impostor
  22919. * @param {Vector3} origin the origin of the explosion
  22920. * @param {number} radius the explosion radius
  22921. * @param {number} strength the explosion strength
  22922. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  22923. * @returns {Nullable<PhysicsForceAndContactPoint>}
  22924. */
  22925. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  22926. /**
  22927. * Disposes the sphere.
  22928. * @param {bolean} force
  22929. */
  22930. dispose(force?: boolean): void;
  22931. /*** Helpers ***/
  22932. private _prepareSphere;
  22933. private _intersectsWithSphere;
  22934. }
  22935. /***** Gravitational Field *****/
  22936. class PhysicsGravitationalFieldEvent {
  22937. private _physicsHelper;
  22938. private _scene;
  22939. private _origin;
  22940. private _radius;
  22941. private _strength;
  22942. private _falloff;
  22943. private _tickCallback;
  22944. private _sphere;
  22945. private _dataFetched;
  22946. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  22947. /**
  22948. * Returns the data related to the gravitational field event (sphere).
  22949. * @returns {PhysicsGravitationalFieldEventData}
  22950. */
  22951. getData(): PhysicsGravitationalFieldEventData;
  22952. /**
  22953. * Enables the gravitational field.
  22954. */
  22955. enable(): void;
  22956. /**
  22957. * Disables the gravitational field.
  22958. */
  22959. disable(): void;
  22960. /**
  22961. * Disposes the sphere.
  22962. * @param {bolean} force
  22963. */
  22964. dispose(force?: boolean): void;
  22965. private _tick;
  22966. }
  22967. /***** Updraft *****/
  22968. class PhysicsUpdraftEvent {
  22969. private _scene;
  22970. private _origin;
  22971. private _radius;
  22972. private _strength;
  22973. private _height;
  22974. private _updraftMode;
  22975. private _physicsEngine;
  22976. private _originTop;
  22977. private _originDirection;
  22978. private _tickCallback;
  22979. private _cylinder;
  22980. private _cylinderPosition;
  22981. private _dataFetched;
  22982. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  22983. /**
  22984. * Returns the data related to the updraft event (cylinder).
  22985. * @returns {PhysicsUpdraftEventData}
  22986. */
  22987. getData(): PhysicsUpdraftEventData;
  22988. /**
  22989. * Enables the updraft.
  22990. */
  22991. enable(): void;
  22992. /**
  22993. * Disables the cortex.
  22994. */
  22995. disable(): void;
  22996. /**
  22997. * Disposes the sphere.
  22998. * @param {bolean} force
  22999. */
  23000. dispose(force?: boolean): void;
  23001. private getImpostorForceAndContactPoint;
  23002. private _tick;
  23003. /*** Helpers ***/
  23004. private _prepareCylinder;
  23005. private _intersectsWithCylinder;
  23006. }
  23007. /***** Vortex *****/
  23008. class PhysicsVortexEvent {
  23009. private _scene;
  23010. private _origin;
  23011. private _radius;
  23012. private _strength;
  23013. private _height;
  23014. private _physicsEngine;
  23015. private _originTop;
  23016. private _centripetalForceThreshold;
  23017. private _updraftMultiplier;
  23018. private _tickCallback;
  23019. private _cylinder;
  23020. private _cylinderPosition;
  23021. private _dataFetched;
  23022. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  23023. /**
  23024. * Returns the data related to the vortex event (cylinder).
  23025. * @returns {PhysicsVortexEventData}
  23026. */
  23027. getData(): PhysicsVortexEventData;
  23028. /**
  23029. * Enables the vortex.
  23030. */
  23031. enable(): void;
  23032. /**
  23033. * Disables the cortex.
  23034. */
  23035. disable(): void;
  23036. /**
  23037. * Disposes the sphere.
  23038. * @param {bolean} force
  23039. */
  23040. dispose(force?: boolean): void;
  23041. private getImpostorForceAndContactPoint;
  23042. private _tick;
  23043. /*** Helpers ***/
  23044. private _prepareCylinder;
  23045. private _intersectsWithCylinder;
  23046. }
  23047. /***** Enums *****/
  23048. /**
  23049. * The strenght of the force in correspondence to the distance of the affected object
  23050. */
  23051. enum PhysicsRadialImpulseFalloff {
  23052. /** Defines that impulse is constant in strength across it's whole radius */
  23053. Constant = 0,
  23054. /** DEfines that impulse gets weaker if it's further from the origin */
  23055. Linear = 1
  23056. }
  23057. /**
  23058. * The strenght of the force in correspondence to the distance of the affected object
  23059. */
  23060. enum PhysicsUpdraftMode {
  23061. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  23062. Center = 0,
  23063. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  23064. Perpendicular = 1
  23065. }
  23066. /***** Data interfaces *****/
  23067. interface PhysicsForceAndContactPoint {
  23068. force: Vector3;
  23069. contactPoint: Vector3;
  23070. }
  23071. interface PhysicsRadialExplosionEventData {
  23072. sphere: Mesh;
  23073. rays: Array<Ray>;
  23074. }
  23075. interface PhysicsGravitationalFieldEventData {
  23076. sphere: Mesh;
  23077. }
  23078. interface PhysicsUpdraftEventData {
  23079. cylinder: Mesh;
  23080. }
  23081. interface PhysicsVortexEventData {
  23082. cylinder: Mesh;
  23083. }
  23084. }
  23085. declare module BABYLON {
  23086. interface PhysicsImpostorParameters {
  23087. mass: number;
  23088. friction?: number;
  23089. restitution?: number;
  23090. nativeOptions?: any;
  23091. ignoreParent?: boolean;
  23092. disableBidirectionalTransformation?: boolean;
  23093. }
  23094. interface IPhysicsEnabledObject {
  23095. position: Vector3;
  23096. rotationQuaternion: Nullable<Quaternion>;
  23097. scaling: Vector3;
  23098. rotation?: Vector3;
  23099. parent?: any;
  23100. getBoundingInfo(): BoundingInfo;
  23101. computeWorldMatrix(force: boolean): Matrix;
  23102. getWorldMatrix?(): Matrix;
  23103. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23104. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23105. getIndices?(): Nullable<IndicesArray>;
  23106. getScene?(): Scene;
  23107. getAbsolutePosition(): Vector3;
  23108. getAbsolutePivotPoint(): Vector3;
  23109. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23110. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23111. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23112. getClassName(): string;
  23113. }
  23114. class PhysicsImpostor {
  23115. object: IPhysicsEnabledObject;
  23116. type: number;
  23117. private _options;
  23118. private _scene?;
  23119. static DEFAULT_OBJECT_SIZE: Vector3;
  23120. static IDENTITY_QUATERNION: Quaternion;
  23121. private _physicsEngine;
  23122. private _physicsBody;
  23123. private _bodyUpdateRequired;
  23124. private _onBeforePhysicsStepCallbacks;
  23125. private _onAfterPhysicsStepCallbacks;
  23126. private _onPhysicsCollideCallbacks;
  23127. private _deltaPosition;
  23128. private _deltaRotation;
  23129. private _deltaRotationConjugated;
  23130. private _parent;
  23131. private _isDisposed;
  23132. private static _tmpVecs;
  23133. private static _tmpQuat;
  23134. readonly isDisposed: boolean;
  23135. mass: number;
  23136. friction: number;
  23137. restitution: number;
  23138. uniqueId: number;
  23139. private _joints;
  23140. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23141. /**
  23142. * This function will completly initialize this impostor.
  23143. * It will create a new body - but only if this mesh has no parent.
  23144. * If it has, this impostor will not be used other than to define the impostor
  23145. * of the child mesh.
  23146. * @hidden
  23147. */
  23148. _init(): void;
  23149. private _getPhysicsParent;
  23150. /**
  23151. * Should a new body be generated.
  23152. */
  23153. isBodyInitRequired(): boolean;
  23154. setScalingUpdated(updated: boolean): void;
  23155. /**
  23156. * Force a regeneration of this or the parent's impostor's body.
  23157. * Use under cautious - This will remove all joints already implemented.
  23158. */
  23159. forceUpdate(): void;
  23160. /**
  23161. * Gets the body that holds this impostor. Either its own, or its parent.
  23162. */
  23163. /**
  23164. * Set the physics body. Used mainly by the physics engine/plugin
  23165. */
  23166. physicsBody: any;
  23167. parent: Nullable<PhysicsImpostor>;
  23168. resetUpdateFlags(): void;
  23169. getObjectExtendSize(): Vector3;
  23170. getObjectCenter(): Vector3;
  23171. /**
  23172. * Get a specific parametes from the options parameter.
  23173. */
  23174. getParam(paramName: string): any;
  23175. /**
  23176. * Sets a specific parameter in the options given to the physics plugin
  23177. */
  23178. setParam(paramName: string, value: number): void;
  23179. /**
  23180. * Specifically change the body's mass option. Won't recreate the physics body object
  23181. */
  23182. setMass(mass: number): void;
  23183. getLinearVelocity(): Nullable<Vector3>;
  23184. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23185. getAngularVelocity(): Nullable<Vector3>;
  23186. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23187. /**
  23188. * Execute a function with the physics plugin native code.
  23189. * Provide a function the will have two variables - the world object and the physics body object.
  23190. */
  23191. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23192. /**
  23193. * Register a function that will be executed before the physics world is stepping forward.
  23194. */
  23195. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23196. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23197. /**
  23198. * Register a function that will be executed after the physics step
  23199. */
  23200. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23201. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23202. /**
  23203. * register a function that will be executed when this impostor collides against a different body.
  23204. */
  23205. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23206. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23207. private _tmpQuat;
  23208. private _tmpQuat2;
  23209. getParentsRotation(): Quaternion;
  23210. /**
  23211. * this function is executed by the physics engine.
  23212. */
  23213. beforeStep: () => void;
  23214. /**
  23215. * this function is executed by the physics engine.
  23216. */
  23217. afterStep: () => void;
  23218. /**
  23219. * Legacy collision detection event support
  23220. */
  23221. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23222. onCollide: (e: {
  23223. body: any;
  23224. }) => void;
  23225. /**
  23226. * Apply a force
  23227. */
  23228. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23229. /**
  23230. * Apply an impulse
  23231. */
  23232. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23233. /**
  23234. * A help function to create a joint.
  23235. */
  23236. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23237. /**
  23238. * Add a joint to this impostor with a different impostor.
  23239. */
  23240. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23241. /**
  23242. * Will keep this body still, in a sleep mode.
  23243. */
  23244. sleep(): PhysicsImpostor;
  23245. /**
  23246. * Wake the body up.
  23247. */
  23248. wakeUp(): PhysicsImpostor;
  23249. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23250. dispose(): void;
  23251. setDeltaPosition(position: Vector3): void;
  23252. setDeltaRotation(rotation: Quaternion): void;
  23253. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23254. getRadius(): number;
  23255. /**
  23256. * Sync a bone with this impostor
  23257. * @param bone The bone to sync to the impostor.
  23258. * @param boneMesh The mesh that the bone is influencing.
  23259. * @param jointPivot The pivot of the joint / bone in local space.
  23260. * @param distToJoint Optional distance from the impostor to the joint.
  23261. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23262. */
  23263. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23264. /**
  23265. * Sync impostor to a bone
  23266. * @param bone The bone that the impostor will be synced to.
  23267. * @param boneMesh The mesh that the bone is influencing.
  23268. * @param jointPivot The pivot of the joint / bone in local space.
  23269. * @param distToJoint Optional distance from the impostor to the joint.
  23270. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23271. * @param boneAxis Optional vector3 axis the bone is aligned with
  23272. */
  23273. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23274. static NoImpostor: number;
  23275. static SphereImpostor: number;
  23276. static BoxImpostor: number;
  23277. static PlaneImpostor: number;
  23278. static MeshImpostor: number;
  23279. static CylinderImpostor: number;
  23280. static ParticleImpostor: number;
  23281. static HeightmapImpostor: number;
  23282. }
  23283. }
  23284. declare module BABYLON {
  23285. interface PhysicsJointData {
  23286. mainPivot?: Vector3;
  23287. connectedPivot?: Vector3;
  23288. mainAxis?: Vector3;
  23289. connectedAxis?: Vector3;
  23290. collision?: boolean;
  23291. nativeParams?: any;
  23292. }
  23293. /**
  23294. * This is a holder class for the physics joint created by the physics plugin.
  23295. * It holds a set of functions to control the underlying joint.
  23296. */
  23297. class PhysicsJoint {
  23298. type: number;
  23299. jointData: PhysicsJointData;
  23300. private _physicsJoint;
  23301. protected _physicsPlugin: IPhysicsEnginePlugin;
  23302. constructor(type: number, jointData: PhysicsJointData);
  23303. physicsJoint: any;
  23304. physicsPlugin: IPhysicsEnginePlugin;
  23305. /**
  23306. * Execute a function that is physics-plugin specific.
  23307. * @param {Function} func the function that will be executed.
  23308. * It accepts two parameters: the physics world and the physics joint.
  23309. */
  23310. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23311. static DistanceJoint: number;
  23312. static HingeJoint: number;
  23313. static BallAndSocketJoint: number;
  23314. static WheelJoint: number;
  23315. static SliderJoint: number;
  23316. static PrismaticJoint: number;
  23317. static UniversalJoint: number;
  23318. static Hinge2Joint: number;
  23319. static PointToPointJoint: number;
  23320. static SpringJoint: number;
  23321. static LockJoint: number;
  23322. }
  23323. /**
  23324. * A class representing a physics distance joint.
  23325. */
  23326. class DistanceJoint extends PhysicsJoint {
  23327. constructor(jointData: DistanceJointData);
  23328. /**
  23329. * Update the predefined distance.
  23330. */
  23331. updateDistance(maxDistance: number, minDistance?: number): void;
  23332. }
  23333. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23334. constructor(type: number, jointData: PhysicsJointData);
  23335. /**
  23336. * Set the motor values.
  23337. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23338. * @param {number} force the force to apply
  23339. * @param {number} maxForce max force for this motor.
  23340. */
  23341. setMotor(force?: number, maxForce?: number): void;
  23342. /**
  23343. * Set the motor's limits.
  23344. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23345. */
  23346. setLimit(upperLimit: number, lowerLimit?: number): void;
  23347. }
  23348. /**
  23349. * This class represents a single hinge physics joint
  23350. */
  23351. class HingeJoint extends MotorEnabledJoint {
  23352. constructor(jointData: PhysicsJointData);
  23353. /**
  23354. * Set the motor values.
  23355. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23356. * @param {number} force the force to apply
  23357. * @param {number} maxForce max force for this motor.
  23358. */
  23359. setMotor(force?: number, maxForce?: number): void;
  23360. /**
  23361. * Set the motor's limits.
  23362. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23363. */
  23364. setLimit(upperLimit: number, lowerLimit?: number): void;
  23365. }
  23366. /**
  23367. * This class represents a dual hinge physics joint (same as wheel joint)
  23368. */
  23369. class Hinge2Joint extends MotorEnabledJoint {
  23370. constructor(jointData: PhysicsJointData);
  23371. /**
  23372. * Set the motor values.
  23373. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23374. * @param {number} force the force to apply
  23375. * @param {number} maxForce max force for this motor.
  23376. * @param {motorIndex} the motor's index, 0 or 1.
  23377. */
  23378. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23379. /**
  23380. * Set the motor limits.
  23381. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23382. * @param {number} upperLimit the upper limit
  23383. * @param {number} lowerLimit lower limit
  23384. * @param {motorIndex} the motor's index, 0 or 1.
  23385. */
  23386. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23387. }
  23388. interface IMotorEnabledJoint {
  23389. physicsJoint: any;
  23390. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23391. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23392. }
  23393. interface DistanceJointData extends PhysicsJointData {
  23394. maxDistance: number;
  23395. }
  23396. interface SpringJointData extends PhysicsJointData {
  23397. length: number;
  23398. stiffness: number;
  23399. damping: number;
  23400. }
  23401. }
  23402. declare module BABYLON {
  23403. /**
  23404. * Class used to generate realtime reflection / refraction cube textures
  23405. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  23406. */
  23407. class ReflectionProbe {
  23408. /** defines the name of the probe */
  23409. name: string;
  23410. private _scene;
  23411. private _renderTargetTexture;
  23412. private _projectionMatrix;
  23413. private _viewMatrix;
  23414. private _target;
  23415. private _add;
  23416. private _attachedMesh;
  23417. private _invertYAxis;
  23418. /** Gets or sets probe position (center of the cube map) */
  23419. position: Vector3;
  23420. /**
  23421. * Creates a new reflection probe
  23422. * @param name defines the name of the probe
  23423. * @param size defines the texture resolution (for each face)
  23424. * @param scene defines the hosting scene
  23425. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  23426. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  23427. */
  23428. constructor(
  23429. /** defines the name of the probe */
  23430. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  23431. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  23432. samples: number;
  23433. /** Gets or sets the refresh rate to use (on every frame by default) */
  23434. refreshRate: number;
  23435. /**
  23436. * Gets the hosting scene
  23437. * @returns a Scene
  23438. */
  23439. getScene(): Scene;
  23440. /** Gets the internal CubeTexture used to render to */
  23441. readonly cubeTexture: RenderTargetTexture;
  23442. /** Gets the list of meshes to render */
  23443. readonly renderList: Nullable<AbstractMesh[]>;
  23444. /**
  23445. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  23446. * @param mesh defines the mesh to attach to
  23447. */
  23448. attachToMesh(mesh: AbstractMesh): void;
  23449. /**
  23450. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  23451. * @param renderingGroupId The rendering group id corresponding to its index
  23452. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23453. */
  23454. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23455. /**
  23456. * Clean all associated resources
  23457. */
  23458. dispose(): void;
  23459. }
  23460. }
  23461. declare module BABYLON {
  23462. interface Scene {
  23463. /** @hidden (Backing field) */
  23464. _boundingBoxRenderer: BoundingBoxRenderer;
  23465. /** @hidden (Backing field) */
  23466. _forceShowBoundingBoxes: boolean;
  23467. /**
  23468. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  23469. */
  23470. forceShowBoundingBoxes: boolean;
  23471. /**
  23472. * Gets the bounding box renderer associated with the scene
  23473. * @returns a BoundingBoxRenderer
  23474. */
  23475. getBoundingBoxRenderer(): BoundingBoxRenderer;
  23476. }
  23477. interface AbstractMesh {
  23478. /** @hidden (Backing field) */
  23479. _showBoundingBox: boolean;
  23480. /**
  23481. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  23482. */
  23483. showBoundingBox: boolean;
  23484. }
  23485. class BoundingBoxRenderer implements ISceneComponent {
  23486. /**
  23487. * The component name helpfull to identify the component in the list of scene components.
  23488. */
  23489. readonly name: string;
  23490. /**
  23491. * The scene the component belongs to.
  23492. */
  23493. scene: Scene;
  23494. frontColor: Color3;
  23495. backColor: Color3;
  23496. showBackLines: boolean;
  23497. renderList: SmartArray<BoundingBox>;
  23498. private _colorShader;
  23499. private _vertexBuffers;
  23500. private _indexBuffer;
  23501. constructor(scene: Scene);
  23502. /**
  23503. * Registers the component in a given scene
  23504. */
  23505. register(): void;
  23506. private _evaluateSubMesh;
  23507. private _activeMesh;
  23508. private _prepareRessources;
  23509. private _createIndexBuffer;
  23510. /**
  23511. * Rebuilds the elements related to this component in case of
  23512. * context lost for instance.
  23513. */
  23514. rebuild(): void;
  23515. reset(): void;
  23516. render(): void;
  23517. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  23518. dispose(): void;
  23519. }
  23520. }
  23521. declare module BABYLON {
  23522. /**
  23523. * This represents a depth renderer in Babylon.
  23524. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  23525. */
  23526. class DepthRenderer {
  23527. private _scene;
  23528. private _depthMap;
  23529. private _effect;
  23530. private _cachedDefines;
  23531. private _camera;
  23532. /**
  23533. * Instantiates a depth renderer
  23534. * @param scene The scene the renderer belongs to
  23535. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  23536. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  23537. */
  23538. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  23539. /**
  23540. * Creates the depth rendering effect and checks if the effect is ready.
  23541. * @param subMesh The submesh to be used to render the depth map of
  23542. * @param useInstances If multiple world instances should be used
  23543. * @returns if the depth renderer is ready to render the depth map
  23544. */
  23545. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23546. /**
  23547. * Gets the texture which the depth map will be written to.
  23548. * @returns The depth map texture
  23549. */
  23550. getDepthMap(): RenderTargetTexture;
  23551. /**
  23552. * Disposes of the depth renderer.
  23553. */
  23554. dispose(): void;
  23555. }
  23556. }
  23557. declare module BABYLON {
  23558. class EdgesRenderer {
  23559. edgesWidthScalerForOrthographic: number;
  23560. edgesWidthScalerForPerspective: number;
  23561. private _source;
  23562. private _linesPositions;
  23563. private _linesNormals;
  23564. private _linesIndices;
  23565. private _epsilon;
  23566. private _indicesCount;
  23567. private _lineShader;
  23568. private _ib;
  23569. private _buffers;
  23570. private _checkVerticesInsteadOfIndices;
  23571. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  23572. isEnabled: boolean;
  23573. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  23574. private _prepareRessources;
  23575. /** @hidden */
  23576. _rebuild(): void;
  23577. dispose(): void;
  23578. private _processEdgeForAdjacencies;
  23579. private _processEdgeForAdjacenciesWithVertices;
  23580. private _checkEdge;
  23581. _generateEdgesLines(): void;
  23582. render(): void;
  23583. }
  23584. }
  23585. declare module BABYLON {
  23586. /**
  23587. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  23588. */
  23589. class GeometryBufferRenderer {
  23590. private _scene;
  23591. private _multiRenderTarget;
  23592. private _ratio;
  23593. private _enablePosition;
  23594. protected _effect: Effect;
  23595. protected _cachedDefines: string;
  23596. /**
  23597. * Set the render list (meshes to be rendered) used in the G buffer.
  23598. */
  23599. renderList: Mesh[];
  23600. /**
  23601. * Gets wether or not G buffer are supported by the running hardware.
  23602. * This requires draw buffer supports
  23603. */
  23604. readonly isSupported: boolean;
  23605. /**
  23606. * Gets wether or not position are enabled for the G buffer.
  23607. */
  23608. /**
  23609. * Sets wether or not position are enabled for the G buffer.
  23610. */
  23611. enablePosition: boolean;
  23612. /**
  23613. * Gets the scene associated with the buffer.
  23614. */
  23615. readonly scene: Scene;
  23616. /**
  23617. * Gets the ratio used by the buffer during its creation.
  23618. * How big is the buffer related to the main canvas.
  23619. */
  23620. readonly ratio: number;
  23621. /**
  23622. * Creates a new G Buffer for the scene
  23623. * @param scene The scene the buffer belongs to
  23624. * @param ratio How big is the buffer related to the main canvas.
  23625. */
  23626. constructor(scene: Scene, ratio?: number);
  23627. /**
  23628. * Checks wether everything is ready to render a submesh to the G buffer.
  23629. * @param subMesh the submesh to check readiness for
  23630. * @param useInstances is the mesh drawn using instance or not
  23631. * @returns true if ready otherwise false
  23632. */
  23633. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23634. /**
  23635. * Gets the current underlying G Buffer.
  23636. * @returns the buffer
  23637. */
  23638. getGBuffer(): MultiRenderTarget;
  23639. /**
  23640. * Gets the number of samples used to render the buffer (anti aliasing).
  23641. */
  23642. /**
  23643. * Sets the number of samples used to render the buffer (anti aliasing).
  23644. */
  23645. samples: number;
  23646. /**
  23647. * Disposes the renderer and frees up associated resources.
  23648. */
  23649. dispose(): void;
  23650. protected _createRenderTargets(): void;
  23651. }
  23652. }
  23653. declare module BABYLON {
  23654. class OutlineRenderer {
  23655. private _scene;
  23656. private _effect;
  23657. private _cachedDefines;
  23658. zOffset: number;
  23659. constructor(scene: Scene);
  23660. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  23661. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23662. }
  23663. }
  23664. declare module BABYLON {
  23665. class RenderingGroup {
  23666. index: number;
  23667. private _scene;
  23668. private _opaqueSubMeshes;
  23669. private _transparentSubMeshes;
  23670. private _alphaTestSubMeshes;
  23671. private _depthOnlySubMeshes;
  23672. private _particleSystems;
  23673. private _spriteManagers;
  23674. private _opaqueSortCompareFn;
  23675. private _alphaTestSortCompareFn;
  23676. private _transparentSortCompareFn;
  23677. private _renderOpaque;
  23678. private _renderAlphaTest;
  23679. private _renderTransparent;
  23680. private _edgesRenderers;
  23681. onBeforeTransparentRendering: () => void;
  23682. /**
  23683. * Set the opaque sort comparison function.
  23684. * If null the sub meshes will be render in the order they were created
  23685. */
  23686. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  23687. /**
  23688. * Set the alpha test sort comparison function.
  23689. * If null the sub meshes will be render in the order they were created
  23690. */
  23691. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  23692. /**
  23693. * Set the transparent sort comparison function.
  23694. * If null the sub meshes will be render in the order they were created
  23695. */
  23696. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  23697. /**
  23698. * Creates a new rendering group.
  23699. * @param index The rendering group index
  23700. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  23701. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  23702. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  23703. */
  23704. 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>);
  23705. /**
  23706. * Render all the sub meshes contained in the group.
  23707. * @param customRenderFunction Used to override the default render behaviour of the group.
  23708. * @returns true if rendered some submeshes.
  23709. */
  23710. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  23711. /**
  23712. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  23713. * @param subMeshes The submeshes to render
  23714. */
  23715. private renderOpaqueSorted;
  23716. /**
  23717. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  23718. * @param subMeshes The submeshes to render
  23719. */
  23720. private renderAlphaTestSorted;
  23721. /**
  23722. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  23723. * @param subMeshes The submeshes to render
  23724. */
  23725. private renderTransparentSorted;
  23726. /**
  23727. * Renders the submeshes in a specified order.
  23728. * @param subMeshes The submeshes to sort before render
  23729. * @param sortCompareFn The comparison function use to sort
  23730. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  23731. * @param transparent Specifies to activate blending if true
  23732. */
  23733. private static renderSorted;
  23734. /**
  23735. * Renders the submeshes in the order they were dispatched (no sort applied).
  23736. * @param subMeshes The submeshes to render
  23737. */
  23738. private static renderUnsorted;
  23739. /**
  23740. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  23741. * are rendered back to front if in the same alpha index.
  23742. *
  23743. * @param a The first submesh
  23744. * @param b The second submesh
  23745. * @returns The result of the comparison
  23746. */
  23747. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  23748. /**
  23749. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  23750. * are rendered back to front.
  23751. *
  23752. * @param a The first submesh
  23753. * @param b The second submesh
  23754. * @returns The result of the comparison
  23755. */
  23756. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  23757. /**
  23758. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  23759. * are rendered front to back (prevent overdraw).
  23760. *
  23761. * @param a The first submesh
  23762. * @param b The second submesh
  23763. * @returns The result of the comparison
  23764. */
  23765. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  23766. /**
  23767. * Resets the different lists of submeshes to prepare a new frame.
  23768. */
  23769. prepare(): void;
  23770. dispose(): void;
  23771. /**
  23772. * Inserts the submesh in its correct queue depending on its material.
  23773. * @param subMesh The submesh to dispatch
  23774. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  23775. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  23776. */
  23777. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  23778. dispatchSprites(spriteManager: SpriteManager): void;
  23779. dispatchParticles(particleSystem: IParticleSystem): void;
  23780. private _renderParticles;
  23781. private _renderSprites;
  23782. }
  23783. }
  23784. declare module BABYLON {
  23785. /**
  23786. * Interface describing the different options available in the rendering manager
  23787. * regarding Auto Clear between groups.
  23788. */
  23789. interface IRenderingManagerAutoClearSetup {
  23790. /**
  23791. * Defines whether or not autoclear is enable.
  23792. */
  23793. autoClear: boolean;
  23794. /**
  23795. * Defines whether or not to autoclear the depth buffer.
  23796. */
  23797. depth: boolean;
  23798. /**
  23799. * Defines whether or not to autoclear the stencil buffer.
  23800. */
  23801. stencil: boolean;
  23802. }
  23803. class RenderingManager {
  23804. /**
  23805. * The max id used for rendering groups (not included)
  23806. */
  23807. static MAX_RENDERINGGROUPS: number;
  23808. /**
  23809. * The min id used for rendering groups (included)
  23810. */
  23811. static MIN_RENDERINGGROUPS: number;
  23812. /**
  23813. * Used to globally prevent autoclearing scenes.
  23814. */
  23815. static AUTOCLEAR: boolean;
  23816. /**
  23817. * @hidden
  23818. */
  23819. _useSceneAutoClearSetup: boolean;
  23820. private _scene;
  23821. private _renderingGroups;
  23822. private _depthStencilBufferAlreadyCleaned;
  23823. private _autoClearDepthStencil;
  23824. private _customOpaqueSortCompareFn;
  23825. private _customAlphaTestSortCompareFn;
  23826. private _customTransparentSortCompareFn;
  23827. private _renderingGroupInfo;
  23828. constructor(scene: Scene);
  23829. private _clearDepthStencilBuffer;
  23830. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  23831. reset(): void;
  23832. dispose(): void;
  23833. /**
  23834. * Clear the info related to rendering groups preventing retention points during dispose.
  23835. */
  23836. freeRenderingGroups(): void;
  23837. private _prepareRenderingGroup;
  23838. dispatchSprites(spriteManager: SpriteManager): void;
  23839. dispatchParticles(particleSystem: IParticleSystem): void;
  23840. /**
  23841. * @param subMesh The submesh to dispatch
  23842. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  23843. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  23844. */
  23845. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  23846. /**
  23847. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23848. * This allowed control for front to back rendering or reversly depending of the special needs.
  23849. *
  23850. * @param renderingGroupId The rendering group id corresponding to its index
  23851. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23852. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23853. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23854. */
  23855. 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;
  23856. /**
  23857. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23858. *
  23859. * @param renderingGroupId The rendering group id corresponding to its index
  23860. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23861. * @param depth Automatically clears depth between groups if true and autoClear is true.
  23862. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  23863. */
  23864. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  23865. /**
  23866. * Gets the current auto clear configuration for one rendering group of the rendering
  23867. * manager.
  23868. * @param index the rendering group index to get the information for
  23869. * @returns The auto clear setup for the requested rendering group
  23870. */
  23871. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  23872. }
  23873. }
  23874. declare module BABYLON {
  23875. /**
  23876. * Renders a layer on top of an existing scene
  23877. */
  23878. class UtilityLayerRenderer implements IDisposable {
  23879. /** the original scene that will be rendered on top of */
  23880. originalScene: Scene;
  23881. private _pointerCaptures;
  23882. private _lastPointerEvents;
  23883. private static _DefaultUtilityLayer;
  23884. private static _DefaultKeepDepthUtilityLayer;
  23885. /**
  23886. * 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)
  23887. */
  23888. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  23889. /**
  23890. * 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)
  23891. */
  23892. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  23893. /**
  23894. * The scene that is rendered on top of the original scene
  23895. */
  23896. utilityLayerScene: Scene;
  23897. /**
  23898. * If the utility layer should automatically be rendered on top of existing scene
  23899. */
  23900. shouldRender: boolean;
  23901. /**
  23902. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  23903. */
  23904. onlyCheckPointerDownEvents: boolean;
  23905. /**
  23906. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  23907. */
  23908. processAllEvents: boolean;
  23909. /**
  23910. * Observable raised when the pointer move from the utility layer scene to the main scene
  23911. */
  23912. onPointerOutObservable: Observable<number>;
  23913. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  23914. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  23915. private _afterRenderObserver;
  23916. private _sceneDisposeObserver;
  23917. private _originalPointerObserver;
  23918. /**
  23919. * Instantiates a UtilityLayerRenderer
  23920. * @param originalScene the original scene that will be rendered on top of
  23921. */
  23922. constructor(
  23923. /** the original scene that will be rendered on top of */
  23924. originalScene: Scene);
  23925. private _notifyObservers;
  23926. /**
  23927. * Renders the utility layers scene on top of the original scene
  23928. */
  23929. render(): void;
  23930. /**
  23931. * Disposes of the renderer
  23932. */
  23933. dispose(): void;
  23934. private _updateCamera;
  23935. }
  23936. }
  23937. declare module BABYLON {
  23938. /**
  23939. * Postprocess used to generate anaglyphic rendering
  23940. */
  23941. class AnaglyphPostProcess extends PostProcess {
  23942. private _passedProcess;
  23943. /**
  23944. * Creates a new AnaglyphPostProcess
  23945. * @param name defines postprocess name
  23946. * @param options defines creation options or target ratio scale
  23947. * @param rigCameras defines cameras using this postprocess
  23948. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  23949. * @param engine defines hosting engine
  23950. * @param reusable defines if the postprocess will be reused multiple times per frame
  23951. */
  23952. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  23953. }
  23954. }
  23955. declare module BABYLON {
  23956. class BlackAndWhitePostProcess extends PostProcess {
  23957. degree: number;
  23958. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  23959. }
  23960. }
  23961. declare module BABYLON {
  23962. /**
  23963. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  23964. */
  23965. class BloomEffect extends PostProcessRenderEffect {
  23966. private bloomScale;
  23967. /**
  23968. * @hidden Internal
  23969. */
  23970. _effects: Array<PostProcess>;
  23971. /**
  23972. * @hidden Internal
  23973. */
  23974. _downscale: ExtractHighlightsPostProcess;
  23975. private _blurX;
  23976. private _blurY;
  23977. private _merge;
  23978. /**
  23979. * The luminance threshold to find bright areas of the image to bloom.
  23980. */
  23981. threshold: number;
  23982. /**
  23983. * The strength of the bloom.
  23984. */
  23985. weight: number;
  23986. /**
  23987. * Specifies the size of the bloom blur kernel, relative to the final output size
  23988. */
  23989. kernel: number;
  23990. /**
  23991. * Creates a new instance of @see BloomEffect
  23992. * @param scene The scene the effect belongs to.
  23993. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  23994. * @param bloomKernel The size of the kernel to be used when applying the blur.
  23995. * @param bloomWeight The the strength of bloom.
  23996. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  23997. * @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)
  23998. */
  23999. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  24000. /**
  24001. * Disposes each of the internal effects for a given camera.
  24002. * @param camera The camera to dispose the effect on.
  24003. */
  24004. disposeEffects(camera: Camera): void;
  24005. /**
  24006. * @hidden Internal
  24007. */
  24008. _updateEffects(): void;
  24009. /**
  24010. * Internal
  24011. * @returns if all the contained post processes are ready.
  24012. * @hidden
  24013. */
  24014. _isReady(): boolean;
  24015. }
  24016. }
  24017. declare module BABYLON {
  24018. /**
  24019. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  24020. */
  24021. class BloomMergePostProcess extends PostProcess {
  24022. /** Weight of the bloom to be added to the original input. */
  24023. weight: number;
  24024. /**
  24025. * Creates a new instance of @see BloomMergePostProcess
  24026. * @param name The name of the effect.
  24027. * @param originalFromInput Post process which's input will be used for the merge.
  24028. * @param blurred Blurred highlights post process which's output will be used.
  24029. * @param weight Weight of the bloom to be added to the original input.
  24030. * @param options The required width/height ratio to downsize to before computing the render pass.
  24031. * @param camera The camera to apply the render pass to.
  24032. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24033. * @param engine The engine which the post process will be applied. (default: current engine)
  24034. * @param reusable If the post process can be reused on the same frame. (default: false)
  24035. * @param textureType Type of textures used when performing the post process. (default: 0)
  24036. * @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)
  24037. */
  24038. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  24039. /** Weight of the bloom to be added to the original input. */
  24040. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  24041. }
  24042. }
  24043. declare module BABYLON {
  24044. /**
  24045. * The Blur Post Process which blurs an image based on a kernel and direction.
  24046. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  24047. */
  24048. class BlurPostProcess extends PostProcess {
  24049. /** The direction in which to blur the image. */
  24050. direction: Vector2;
  24051. private blockCompilation;
  24052. protected _kernel: number;
  24053. protected _idealKernel: number;
  24054. protected _packedFloat: boolean;
  24055. private _staticDefines;
  24056. /**
  24057. * Sets the length in pixels of the blur sample region
  24058. */
  24059. /**
  24060. * Gets the length in pixels of the blur sample region
  24061. */
  24062. kernel: number;
  24063. /**
  24064. * Sets wether or not the blur needs to unpack/repack floats
  24065. */
  24066. /**
  24067. * Gets wether or not the blur is unpacking/repacking floats
  24068. */
  24069. packedFloat: boolean;
  24070. /**
  24071. * Creates a new instance BlurPostProcess
  24072. * @param name The name of the effect.
  24073. * @param direction The direction in which to blur the image.
  24074. * @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.
  24075. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24076. * @param camera The camera to apply the render pass to.
  24077. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24078. * @param engine The engine which the post process will be applied. (default: current engine)
  24079. * @param reusable If the post process can be reused on the same frame. (default: false)
  24080. * @param textureType Type of textures used when performing the post process. (default: 0)
  24081. * @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)
  24082. */
  24083. constructor(name: string,
  24084. /** The direction in which to blur the image. */
  24085. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  24086. /**
  24087. * Updates the effect with the current post process compile time values and recompiles the shader.
  24088. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24089. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24090. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24091. * @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
  24092. * @param onCompiled Called when the shader has been compiled.
  24093. * @param onError Called if there is an error when compiling a shader.
  24094. */
  24095. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24096. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24097. /**
  24098. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  24099. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  24100. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  24101. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  24102. * The gaps between physical kernels are compensated for in the weighting of the samples
  24103. * @param idealKernel Ideal blur kernel.
  24104. * @return Nearest best kernel.
  24105. */
  24106. protected _nearestBestKernel(idealKernel: number): number;
  24107. /**
  24108. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  24109. * @param x The point on the Gaussian distribution to sample.
  24110. * @return the value of the Gaussian function at x.
  24111. */
  24112. protected _gaussianWeight(x: number): number;
  24113. /**
  24114. * Generates a string that can be used as a floating point number in GLSL.
  24115. * @param x Value to print.
  24116. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  24117. * @return GLSL float string.
  24118. */
  24119. protected _glslFloat(x: number, decimalFigures?: number): string;
  24120. }
  24121. }
  24122. declare module BABYLON {
  24123. /**
  24124. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  24125. */
  24126. class ChromaticAberrationPostProcess extends PostProcess {
  24127. /**
  24128. * The amount of seperation of rgb channels (default: 30)
  24129. */
  24130. aberrationAmount: number;
  24131. /**
  24132. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  24133. */
  24134. radialIntensity: number;
  24135. /**
  24136. * 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))
  24137. */
  24138. direction: Vector2;
  24139. /**
  24140. * 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))
  24141. */
  24142. centerPosition: Vector2;
  24143. /**
  24144. * Creates a new instance ChromaticAberrationPostProcess
  24145. * @param name The name of the effect.
  24146. * @param screenWidth The width of the screen to apply the effect on.
  24147. * @param screenHeight The height of the screen to apply the effect on.
  24148. * @param options The required width/height ratio to downsize to before computing the render pass.
  24149. * @param camera The camera to apply the render pass to.
  24150. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24151. * @param engine The engine which the post process will be applied. (default: current engine)
  24152. * @param reusable If the post process can be reused on the same frame. (default: false)
  24153. * @param textureType Type of textures used when performing the post process. (default: 0)
  24154. * @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)
  24155. */
  24156. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  24157. }
  24158. }
  24159. declare module BABYLON {
  24160. /**
  24161. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  24162. */
  24163. class CircleOfConfusionPostProcess extends PostProcess {
  24164. /**
  24165. * 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.
  24166. */
  24167. lensSize: number;
  24168. /**
  24169. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  24170. */
  24171. fStop: number;
  24172. /**
  24173. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  24174. */
  24175. focusDistance: number;
  24176. /**
  24177. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  24178. */
  24179. focalLength: number;
  24180. private _depthTexture;
  24181. /**
  24182. * Creates a new instance CircleOfConfusionPostProcess
  24183. * @param name The name of the effect.
  24184. * @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.
  24185. * @param options The required width/height ratio to downsize to before computing the render pass.
  24186. * @param camera The camera to apply the render pass to.
  24187. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24188. * @param engine The engine which the post process will be applied. (default: current engine)
  24189. * @param reusable If the post process can be reused on the same frame. (default: false)
  24190. * @param textureType Type of textures used when performing the post process. (default: 0)
  24191. * @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)
  24192. */
  24193. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  24194. /**
  24195. * 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.
  24196. */
  24197. depthTexture: RenderTargetTexture;
  24198. }
  24199. }
  24200. declare module BABYLON {
  24201. class ColorCorrectionPostProcess extends PostProcess {
  24202. private _colorTableTexture;
  24203. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  24204. }
  24205. }
  24206. declare module BABYLON {
  24207. /**
  24208. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  24209. * input texture to perform effects such as edge detection or sharpening
  24210. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  24211. */
  24212. class ConvolutionPostProcess extends PostProcess {
  24213. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  24214. kernel: number[];
  24215. /**
  24216. * Creates a new instance ConvolutionPostProcess
  24217. * @param name The name of the effect.
  24218. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  24219. * @param options The required width/height ratio to downsize to before computing the render pass.
  24220. * @param camera The camera to apply the render pass to.
  24221. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24222. * @param engine The engine which the post process will be applied. (default: current engine)
  24223. * @param reusable If the post process can be reused on the same frame. (default: false)
  24224. * @param textureType Type of textures used when performing the post process. (default: 0)
  24225. */
  24226. constructor(name: string,
  24227. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  24228. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24229. /**
  24230. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  24231. */
  24232. static EdgeDetect0Kernel: number[];
  24233. /**
  24234. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  24235. */
  24236. static EdgeDetect1Kernel: number[];
  24237. /**
  24238. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  24239. */
  24240. static EdgeDetect2Kernel: number[];
  24241. /**
  24242. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  24243. */
  24244. static SharpenKernel: number[];
  24245. /**
  24246. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  24247. */
  24248. static EmbossKernel: number[];
  24249. /**
  24250. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  24251. */
  24252. static GaussianKernel: number[];
  24253. }
  24254. }
  24255. declare module BABYLON {
  24256. /**
  24257. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  24258. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  24259. * based on samples that have a large difference in distance than the center pixel.
  24260. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  24261. */
  24262. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  24263. direction: Vector2;
  24264. /**
  24265. * Creates a new instance CircleOfConfusionPostProcess
  24266. * @param name The name of the effect.
  24267. * @param scene The scene the effect belongs to.
  24268. * @param direction The direction the blur should be applied.
  24269. * @param kernel The size of the kernel used to blur.
  24270. * @param options The required width/height ratio to downsize to before computing the render pass.
  24271. * @param camera The camera to apply the render pass to.
  24272. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  24273. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  24274. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24275. * @param engine The engine which the post process will be applied. (default: current engine)
  24276. * @param reusable If the post process can be reused on the same frame. (default: false)
  24277. * @param textureType Type of textures used when performing the post process. (default: 0)
  24278. * @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)
  24279. */
  24280. 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);
  24281. }
  24282. }
  24283. declare module BABYLON {
  24284. /**
  24285. * Specifies the level of max blur that should be applied when using the depth of field effect
  24286. */
  24287. enum DepthOfFieldEffectBlurLevel {
  24288. /**
  24289. * Subtle blur
  24290. */
  24291. Low = 0,
  24292. /**
  24293. * Medium blur
  24294. */
  24295. Medium = 1,
  24296. /**
  24297. * Large blur
  24298. */
  24299. High = 2
  24300. }
  24301. /**
  24302. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  24303. */
  24304. class DepthOfFieldEffect extends PostProcessRenderEffect {
  24305. private _circleOfConfusion;
  24306. /**
  24307. * @hidden Internal, blurs from high to low
  24308. */
  24309. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  24310. private _depthOfFieldBlurY;
  24311. private _dofMerge;
  24312. /**
  24313. * @hidden Internal post processes in depth of field effect
  24314. */
  24315. _effects: Array<PostProcess>;
  24316. /**
  24317. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  24318. */
  24319. focalLength: number;
  24320. /**
  24321. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  24322. */
  24323. fStop: number;
  24324. /**
  24325. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  24326. */
  24327. focusDistance: number;
  24328. /**
  24329. * 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.
  24330. */
  24331. lensSize: number;
  24332. /**
  24333. * Creates a new instance DepthOfFieldEffect
  24334. * @param scene The scene the effect belongs to.
  24335. * @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.
  24336. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  24337. * @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)
  24338. */
  24339. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  24340. /**
  24341. * 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.
  24342. */
  24343. depthTexture: RenderTargetTexture;
  24344. /**
  24345. * Disposes each of the internal effects for a given camera.
  24346. * @param camera The camera to dispose the effect on.
  24347. */
  24348. disposeEffects(camera: Camera): void;
  24349. /**
  24350. * @hidden Internal
  24351. */
  24352. _updateEffects(): void;
  24353. /**
  24354. * Internal
  24355. * @returns if all the contained post processes are ready.
  24356. * @hidden
  24357. */
  24358. _isReady(): boolean;
  24359. }
  24360. }
  24361. declare module BABYLON {
  24362. /**
  24363. * Options to be set when merging outputs from the default pipeline.
  24364. */
  24365. class DepthOfFieldMergePostProcessOptions {
  24366. /**
  24367. * The original image to merge on top of
  24368. */
  24369. originalFromInput: PostProcess;
  24370. /**
  24371. * Parameters to perform the merge of the depth of field effect
  24372. */
  24373. depthOfField?: {
  24374. circleOfConfusion: PostProcess;
  24375. blurSteps: Array<PostProcess>;
  24376. };
  24377. /**
  24378. * Parameters to perform the merge of bloom effect
  24379. */
  24380. bloom?: {
  24381. blurred: PostProcess;
  24382. weight: number;
  24383. };
  24384. }
  24385. /**
  24386. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  24387. */
  24388. class DepthOfFieldMergePostProcess extends PostProcess {
  24389. private blurSteps;
  24390. /**
  24391. * Creates a new instance of DepthOfFieldMergePostProcess
  24392. * @param name The name of the effect.
  24393. * @param originalFromInput Post process which's input will be used for the merge.
  24394. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  24395. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  24396. * @param options The required width/height ratio to downsize to before computing the render pass.
  24397. * @param camera The camera to apply the render pass to.
  24398. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24399. * @param engine The engine which the post process will be applied. (default: current engine)
  24400. * @param reusable If the post process can be reused on the same frame. (default: false)
  24401. * @param textureType Type of textures used when performing the post process. (default: 0)
  24402. * @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)
  24403. */
  24404. 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);
  24405. /**
  24406. * Updates the effect with the current post process compile time values and recompiles the shader.
  24407. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24408. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24409. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24410. * @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
  24411. * @param onCompiled Called when the shader has been compiled.
  24412. * @param onError Called if there is an error when compiling a shader.
  24413. */
  24414. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24415. }
  24416. }
  24417. declare module BABYLON {
  24418. class DisplayPassPostProcess extends PostProcess {
  24419. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  24420. }
  24421. }
  24422. declare module BABYLON {
  24423. /**
  24424. * 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.
  24425. */
  24426. class ExtractHighlightsPostProcess extends PostProcess {
  24427. /**
  24428. * The luminance threshold, pixels below this value will be set to black.
  24429. */
  24430. threshold: number;
  24431. /** @hidden */
  24432. _exposure: number;
  24433. /**
  24434. * Post process which has the input texture to be used when performing highlight extraction
  24435. * @hidden
  24436. */
  24437. _inputPostProcess: Nullable<PostProcess>;
  24438. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  24439. }
  24440. }
  24441. declare module BABYLON {
  24442. class FilterPostProcess extends PostProcess {
  24443. kernelMatrix: Matrix;
  24444. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  24445. }
  24446. }
  24447. declare module BABYLON {
  24448. class FxaaPostProcess extends PostProcess {
  24449. texelWidth: number;
  24450. texelHeight: number;
  24451. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24452. private _getDefines;
  24453. }
  24454. }
  24455. declare module BABYLON {
  24456. /**
  24457. * The GrainPostProcess adds noise to the image at mid luminance levels
  24458. */
  24459. class GrainPostProcess extends PostProcess {
  24460. /**
  24461. * The intensity of the grain added (default: 30)
  24462. */
  24463. intensity: number;
  24464. /**
  24465. * If the grain should be randomized on every frame
  24466. */
  24467. animated: boolean;
  24468. /**
  24469. * Creates a new instance of @see GrainPostProcess
  24470. * @param name The name of the effect.
  24471. * @param options The required width/height ratio to downsize to before computing the render pass.
  24472. * @param camera The camera to apply the render pass to.
  24473. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24474. * @param engine The engine which the post process will be applied. (default: current engine)
  24475. * @param reusable If the post process can be reused on the same frame. (default: false)
  24476. * @param textureType Type of textures used when performing the post process. (default: 0)
  24477. * @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)
  24478. */
  24479. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  24480. }
  24481. }
  24482. declare module BABYLON {
  24483. class HighlightsPostProcess extends PostProcess {
  24484. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24485. }
  24486. }
  24487. declare module BABYLON {
  24488. class ImageProcessingPostProcess extends PostProcess {
  24489. /**
  24490. * Default configuration related to image processing available in the PBR Material.
  24491. */
  24492. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24493. /**
  24494. * Gets the image processing configuration used either in this material.
  24495. */
  24496. /**
  24497. * Sets the Default image processing configuration used either in the this material.
  24498. *
  24499. * If sets to null, the scene one is in use.
  24500. */
  24501. imageProcessingConfiguration: ImageProcessingConfiguration;
  24502. /**
  24503. * Keep track of the image processing observer to allow dispose and replace.
  24504. */
  24505. private _imageProcessingObserver;
  24506. /**
  24507. * Attaches a new image processing configuration to the PBR Material.
  24508. * @param configuration
  24509. */
  24510. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24511. /**
  24512. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24513. */
  24514. /**
  24515. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24516. */
  24517. colorCurves: Nullable<ColorCurves>;
  24518. /**
  24519. * Gets wether the color curves effect is enabled.
  24520. */
  24521. /**
  24522. * Sets wether the color curves effect is enabled.
  24523. */
  24524. colorCurvesEnabled: boolean;
  24525. /**
  24526. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24527. */
  24528. /**
  24529. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24530. */
  24531. colorGradingTexture: Nullable<BaseTexture>;
  24532. /**
  24533. * Gets wether the color grading effect is enabled.
  24534. */
  24535. /**
  24536. * Gets wether the color grading effect is enabled.
  24537. */
  24538. colorGradingEnabled: boolean;
  24539. /**
  24540. * Gets exposure used in the effect.
  24541. */
  24542. /**
  24543. * Sets exposure used in the effect.
  24544. */
  24545. exposure: number;
  24546. /**
  24547. * Gets wether tonemapping is enabled or not.
  24548. */
  24549. /**
  24550. * Sets wether tonemapping is enabled or not
  24551. */
  24552. toneMappingEnabled: boolean;
  24553. /**
  24554. * Gets contrast used in the effect.
  24555. */
  24556. /**
  24557. * Sets contrast used in the effect.
  24558. */
  24559. contrast: number;
  24560. /**
  24561. * Gets Vignette stretch size.
  24562. */
  24563. /**
  24564. * Sets Vignette stretch size.
  24565. */
  24566. vignetteStretch: number;
  24567. /**
  24568. * Gets Vignette centre X Offset.
  24569. */
  24570. /**
  24571. * Sets Vignette centre X Offset.
  24572. */
  24573. vignetteCentreX: number;
  24574. /**
  24575. * Gets Vignette centre Y Offset.
  24576. */
  24577. /**
  24578. * Sets Vignette centre Y Offset.
  24579. */
  24580. vignetteCentreY: number;
  24581. /**
  24582. * Gets Vignette weight or intensity of the vignette effect.
  24583. */
  24584. /**
  24585. * Sets Vignette weight or intensity of the vignette effect.
  24586. */
  24587. vignetteWeight: number;
  24588. /**
  24589. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24590. * if vignetteEnabled is set to true.
  24591. */
  24592. /**
  24593. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24594. * if vignetteEnabled is set to true.
  24595. */
  24596. vignetteColor: Color4;
  24597. /**
  24598. * Gets Camera field of view used by the Vignette effect.
  24599. */
  24600. /**
  24601. * Sets Camera field of view used by the Vignette effect.
  24602. */
  24603. vignetteCameraFov: number;
  24604. /**
  24605. * Gets the vignette blend mode allowing different kind of effect.
  24606. */
  24607. /**
  24608. * Sets the vignette blend mode allowing different kind of effect.
  24609. */
  24610. vignetteBlendMode: number;
  24611. /**
  24612. * Gets wether the vignette effect is enabled.
  24613. */
  24614. /**
  24615. * Sets wether the vignette effect is enabled.
  24616. */
  24617. vignetteEnabled: boolean;
  24618. private _fromLinearSpace;
  24619. /**
  24620. * Gets wether the input of the processing is in Gamma or Linear Space.
  24621. */
  24622. /**
  24623. * Sets wether the input of the processing is in Gamma or Linear Space.
  24624. */
  24625. fromLinearSpace: boolean;
  24626. /**
  24627. * Defines cache preventing GC.
  24628. */
  24629. private _defines;
  24630. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24631. getClassName(): string;
  24632. protected _updateParameters(): void;
  24633. dispose(camera?: Camera): void;
  24634. }
  24635. }
  24636. declare module BABYLON {
  24637. class PassPostProcess extends PostProcess {
  24638. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  24639. }
  24640. }
  24641. declare module BABYLON {
  24642. type PostProcessOptions = {
  24643. width: number;
  24644. height: number;
  24645. };
  24646. /**
  24647. * PostProcess can be used to apply a shader to a texture after it has been rendered
  24648. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24649. */
  24650. class PostProcess {
  24651. /** Name of the PostProcess. */
  24652. name: string;
  24653. /**
  24654. * Width of the texture to apply the post process on
  24655. */
  24656. width: number;
  24657. /**
  24658. * Height of the texture to apply the post process on
  24659. */
  24660. height: number;
  24661. /**
  24662. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  24663. * @hidden
  24664. */
  24665. _outputTexture: Nullable<InternalTexture>;
  24666. /**
  24667. * Sampling mode used by the shader
  24668. * See https://doc.babylonjs.com/classes/3.1/texture
  24669. */
  24670. renderTargetSamplingMode: number;
  24671. /**
  24672. * Clear color to use when screen clearing
  24673. */
  24674. clearColor: Color4;
  24675. /**
  24676. * If the buffer needs to be cleared before applying the post process. (default: true)
  24677. * Should be set to false if shader will overwrite all previous pixels.
  24678. */
  24679. autoClear: boolean;
  24680. /**
  24681. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  24682. */
  24683. alphaMode: number;
  24684. /**
  24685. * Sets the setAlphaBlendConstants of the babylon engine
  24686. */
  24687. alphaConstants: Color4;
  24688. /**
  24689. * Animations to be used for the post processing
  24690. */
  24691. animations: Animation[];
  24692. /**
  24693. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  24694. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  24695. */
  24696. enablePixelPerfectMode: boolean;
  24697. /**
  24698. * Force the postprocess to be applied without taking in account viewport
  24699. */
  24700. forceFullscreenViewport: boolean;
  24701. /**
  24702. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  24703. *
  24704. * | Value | Type | Description |
  24705. * | ----- | ----------------------------------- | ----------- |
  24706. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  24707. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  24708. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  24709. *
  24710. */
  24711. scaleMode: number;
  24712. /**
  24713. * Force textures to be a power of two (default: false)
  24714. */
  24715. alwaysForcePOT: boolean;
  24716. /**
  24717. * Number of sample textures (default: 1)
  24718. */
  24719. samples: number;
  24720. /**
  24721. * Modify the scale of the post process to be the same as the viewport (default: false)
  24722. */
  24723. adaptScaleToCurrentViewport: boolean;
  24724. private _camera;
  24725. private _scene;
  24726. private _engine;
  24727. private _options;
  24728. private _reusable;
  24729. private _textureType;
  24730. /**
  24731. * Smart array of input and output textures for the post process.
  24732. * @hidden
  24733. */
  24734. _textures: SmartArray<InternalTexture>;
  24735. /**
  24736. * The index in _textures that corresponds to the output texture.
  24737. * @hidden
  24738. */
  24739. _currentRenderTextureInd: number;
  24740. private _effect;
  24741. private _samplers;
  24742. private _fragmentUrl;
  24743. private _vertexUrl;
  24744. private _parameters;
  24745. private _scaleRatio;
  24746. protected _indexParameters: any;
  24747. private _shareOutputWithPostProcess;
  24748. private _texelSize;
  24749. private _forcedOutputTexture;
  24750. /**
  24751. * An event triggered when the postprocess is activated.
  24752. */
  24753. onActivateObservable: Observable<Camera>;
  24754. private _onActivateObserver;
  24755. /**
  24756. * A function that is added to the onActivateObservable
  24757. */
  24758. onActivate: Nullable<(camera: Camera) => void>;
  24759. /**
  24760. * An event triggered when the postprocess changes its size.
  24761. */
  24762. onSizeChangedObservable: Observable<PostProcess>;
  24763. private _onSizeChangedObserver;
  24764. /**
  24765. * A function that is added to the onSizeChangedObservable
  24766. */
  24767. onSizeChanged: (postProcess: PostProcess) => void;
  24768. /**
  24769. * An event triggered when the postprocess applies its effect.
  24770. */
  24771. onApplyObservable: Observable<Effect>;
  24772. private _onApplyObserver;
  24773. /**
  24774. * A function that is added to the onApplyObservable
  24775. */
  24776. onApply: (effect: Effect) => void;
  24777. /**
  24778. * An event triggered before rendering the postprocess
  24779. */
  24780. onBeforeRenderObservable: Observable<Effect>;
  24781. private _onBeforeRenderObserver;
  24782. /**
  24783. * A function that is added to the onBeforeRenderObservable
  24784. */
  24785. onBeforeRender: (effect: Effect) => void;
  24786. /**
  24787. * An event triggered after rendering the postprocess
  24788. */
  24789. onAfterRenderObservable: Observable<Effect>;
  24790. private _onAfterRenderObserver;
  24791. /**
  24792. * A function that is added to the onAfterRenderObservable
  24793. */
  24794. onAfterRender: (efect: Effect) => void;
  24795. /**
  24796. * 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
  24797. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  24798. */
  24799. inputTexture: InternalTexture;
  24800. /**
  24801. * Gets the camera which post process is applied to.
  24802. * @returns The camera the post process is applied to.
  24803. */
  24804. getCamera(): Camera;
  24805. /**
  24806. * Gets the texel size of the postprocess.
  24807. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  24808. */
  24809. readonly texelSize: Vector2;
  24810. /**
  24811. * Creates a new instance PostProcess
  24812. * @param name The name of the PostProcess.
  24813. * @param fragmentUrl The url of the fragment shader to be used.
  24814. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  24815. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  24816. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24817. * @param camera The camera to apply the render pass to.
  24818. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24819. * @param engine The engine which the post process will be applied. (default: current engine)
  24820. * @param reusable If the post process can be reused on the same frame. (default: false)
  24821. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  24822. * @param textureType Type of textures used when performing the post process. (default: 0)
  24823. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  24824. * @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
  24825. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  24826. */
  24827. constructor(
  24828. /** Name of the PostProcess. */
  24829. 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);
  24830. /**
  24831. * Gets the engine which this post process belongs to.
  24832. * @returns The engine the post process was enabled with.
  24833. */
  24834. getEngine(): Engine;
  24835. /**
  24836. * The effect that is created when initializing the post process.
  24837. * @returns The created effect corrisponding the the postprocess.
  24838. */
  24839. getEffect(): Effect;
  24840. /**
  24841. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  24842. * @param postProcess The post process to share the output with.
  24843. * @returns This post process.
  24844. */
  24845. shareOutputWith(postProcess: PostProcess): PostProcess;
  24846. /**
  24847. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  24848. * This should be called if the post process that shares output with this post process is disabled/disposed.
  24849. */
  24850. useOwnOutput(): void;
  24851. /**
  24852. * Updates the effect with the current post process compile time values and recompiles the shader.
  24853. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24854. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24855. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24856. * @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
  24857. * @param onCompiled Called when the shader has been compiled.
  24858. * @param onError Called if there is an error when compiling a shader.
  24859. */
  24860. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24861. /**
  24862. * The post process is reusable if it can be used multiple times within one frame.
  24863. * @returns If the post process is reusable
  24864. */
  24865. isReusable(): boolean;
  24866. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  24867. markTextureDirty(): void;
  24868. /**
  24869. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  24870. * 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.
  24871. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  24872. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  24873. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  24874. * @returns The target texture that was bound to be written to.
  24875. */
  24876. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  24877. /**
  24878. * If the post process is supported.
  24879. */
  24880. readonly isSupported: boolean;
  24881. /**
  24882. * The aspect ratio of the output texture.
  24883. */
  24884. readonly aspectRatio: number;
  24885. /**
  24886. * Get a value indicating if the post-process is ready to be used
  24887. * @returns true if the post-process is ready (shader is compiled)
  24888. */
  24889. isReady(): boolean;
  24890. /**
  24891. * Binds all textures and uniforms to the shader, this will be run on every pass.
  24892. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  24893. */
  24894. apply(): Nullable<Effect>;
  24895. private _disposeTextures;
  24896. /**
  24897. * Disposes the post process.
  24898. * @param camera The camera to dispose the post process on.
  24899. */
  24900. dispose(camera?: Camera): void;
  24901. }
  24902. }
  24903. declare module BABYLON {
  24904. /**
  24905. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24906. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24907. */
  24908. class PostProcessManager {
  24909. private _scene;
  24910. private _indexBuffer;
  24911. private _vertexBuffers;
  24912. /**
  24913. * Creates a new instance PostProcess
  24914. * @param scene The scene that the post process is associated with.
  24915. */
  24916. constructor(scene: Scene);
  24917. private _prepareBuffers;
  24918. private _buildIndexBuffer;
  24919. /**
  24920. * Rebuilds the vertex buffers of the manager.
  24921. * @hidden
  24922. */
  24923. _rebuild(): void;
  24924. /**
  24925. * Prepares a frame to be run through a post process.
  24926. * @param sourceTexture The input texture to the post procesess. (default: null)
  24927. * @param postProcesses An array of post processes to be run. (default: null)
  24928. * @returns True if the post processes were able to be run.
  24929. * @hidden
  24930. */
  24931. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24932. /**
  24933. * Manually render a set of post processes to a texture.
  24934. * @param postProcesses An array of post processes to be run.
  24935. * @param targetTexture The target texture to render to.
  24936. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24937. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24938. * @param lodLevel defines which lod of the texture to render to
  24939. */
  24940. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  24941. /**
  24942. * Finalize the result of the output of the postprocesses.
  24943. * @param doNotPresent If true the result will not be displayed to the screen.
  24944. * @param targetTexture The target texture to render to.
  24945. * @param faceIndex The index of the face to bind the target texture to.
  24946. * @param postProcesses The array of post processes to render.
  24947. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24948. * @hidden
  24949. */
  24950. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24951. /**
  24952. * Disposes of the post process manager.
  24953. */
  24954. dispose(): void;
  24955. }
  24956. }
  24957. declare module BABYLON {
  24958. class RefractionPostProcess extends PostProcess {
  24959. color: Color3;
  24960. depth: number;
  24961. colorLevel: number;
  24962. private _refTexture;
  24963. private _ownRefractionTexture;
  24964. /**
  24965. * Gets or sets the refraction texture
  24966. * Please note that you are responsible for disposing the texture if you set it manually
  24967. */
  24968. refractionTexture: Texture;
  24969. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  24970. dispose(camera: Camera): void;
  24971. }
  24972. }
  24973. declare module BABYLON {
  24974. /**
  24975. * The SharpenPostProcess applies a sharpen kernel to every pixel
  24976. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  24977. */
  24978. class SharpenPostProcess extends PostProcess {
  24979. /**
  24980. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  24981. */
  24982. colorAmount: number;
  24983. /**
  24984. * How much sharpness should be applied (default: 0.3)
  24985. */
  24986. edgeAmount: number;
  24987. /**
  24988. * Creates a new instance ConvolutionPostProcess
  24989. * @param name The name of the effect.
  24990. * @param options The required width/height ratio to downsize to before computing the render pass.
  24991. * @param camera The camera to apply the render pass to.
  24992. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24993. * @param engine The engine which the post process will be applied. (default: current engine)
  24994. * @param reusable If the post process can be reused on the same frame. (default: false)
  24995. * @param textureType Type of textures used when performing the post process. (default: 0)
  24996. * @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)
  24997. */
  24998. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  24999. }
  25000. }
  25001. declare module BABYLON {
  25002. class StereoscopicInterlacePostProcess extends PostProcess {
  25003. private _stepSize;
  25004. private _passedProcess;
  25005. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25006. }
  25007. }
  25008. declare module BABYLON {
  25009. /** Defines operator used for tonemapping */
  25010. enum TonemappingOperator {
  25011. /** Hable */
  25012. Hable = 0,
  25013. /** Reinhard */
  25014. Reinhard = 1,
  25015. /** HejiDawson */
  25016. HejiDawson = 2,
  25017. /** Photographic */
  25018. Photographic = 3
  25019. }
  25020. /**
  25021. * Defines a post process to apply tone mapping
  25022. */
  25023. class TonemapPostProcess extends PostProcess {
  25024. private _operator;
  25025. /** Defines the required exposure adjustement */
  25026. exposureAdjustment: number;
  25027. /**
  25028. * Creates a new TonemapPostProcess
  25029. * @param name defines the name of the postprocess
  25030. * @param _operator defines the operator to use
  25031. * @param exposureAdjustment defines the required exposure adjustement
  25032. * @param camera defines the camera to use (can be null)
  25033. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  25034. * @param engine defines the hosting engine (can be ignore if camera is set)
  25035. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  25036. */
  25037. constructor(name: string, _operator: TonemappingOperator,
  25038. /** Defines the required exposure adjustement */
  25039. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  25040. }
  25041. }
  25042. declare module BABYLON {
  25043. class VolumetricLightScatteringPostProcess extends PostProcess {
  25044. private _volumetricLightScatteringPass;
  25045. private _volumetricLightScatteringRTT;
  25046. private _viewPort;
  25047. private _screenCoordinates;
  25048. private _cachedDefines;
  25049. /**
  25050. * If not undefined, the mesh position is computed from the attached node position
  25051. */
  25052. attachedNode: {
  25053. position: Vector3;
  25054. };
  25055. /**
  25056. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  25057. */
  25058. customMeshPosition: Vector3;
  25059. /**
  25060. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  25061. */
  25062. useCustomMeshPosition: boolean;
  25063. /**
  25064. * If the post-process should inverse the light scattering direction
  25065. */
  25066. invert: boolean;
  25067. /**
  25068. * The internal mesh used by the post-process
  25069. */
  25070. mesh: Mesh;
  25071. useDiffuseColor: boolean;
  25072. /**
  25073. * Array containing the excluded meshes not rendered in the internal pass
  25074. */
  25075. excludedMeshes: AbstractMesh[];
  25076. /**
  25077. * Controls the overall intensity of the post-process
  25078. */
  25079. exposure: number;
  25080. /**
  25081. * Dissipates each sample's contribution in range [0, 1]
  25082. */
  25083. decay: number;
  25084. /**
  25085. * Controls the overall intensity of each sample
  25086. */
  25087. weight: number;
  25088. /**
  25089. * Controls the density of each sample
  25090. */
  25091. density: number;
  25092. /**
  25093. * @constructor
  25094. * @param {string} name - The post-process name
  25095. * @param {any} 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)
  25096. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  25097. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  25098. * @param {number} samples - The post-process quality, default 100
  25099. * @param {number} samplingMode - The post-process filtering mode
  25100. * @param {BABYLON.Engine} engine - The babylon engine
  25101. * @param {boolean} reusable - If the post-process is reusable
  25102. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  25103. */
  25104. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  25105. getClassName(): string;
  25106. private _isReady;
  25107. /**
  25108. * Sets the new light position for light scattering effect
  25109. * @param {BABYLON.Vector3} The new custom light position
  25110. */
  25111. setCustomMeshPosition(position: Vector3): void;
  25112. /**
  25113. * Returns the light position for light scattering effect
  25114. * @return {BABYLON.Vector3} The custom light position
  25115. */
  25116. getCustomMeshPosition(): Vector3;
  25117. /**
  25118. * Disposes the internal assets and detaches the post-process from the camera
  25119. */
  25120. dispose(camera: Camera): void;
  25121. /**
  25122. * Returns the render target texture used by the post-process
  25123. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  25124. */
  25125. getPass(): RenderTargetTexture;
  25126. private _meshExcluded;
  25127. private _createPass;
  25128. private _updateMeshScreenCoordinates;
  25129. /**
  25130. * Creates a default mesh for the Volumeric Light Scattering post-process
  25131. * @param {string} The mesh name
  25132. * @param {BABYLON.Scene} The scene where to create the mesh
  25133. * @return {BABYLON.Mesh} the default mesh
  25134. */
  25135. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  25136. }
  25137. }
  25138. declare module BABYLON {
  25139. class VRDistortionCorrectionPostProcess extends PostProcess {
  25140. private _isRightEye;
  25141. private _distortionFactors;
  25142. private _postProcessScaleFactor;
  25143. private _lensCenterOffset;
  25144. private _scaleIn;
  25145. private _scaleFactor;
  25146. private _lensCenter;
  25147. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  25148. }
  25149. }
  25150. declare module BABYLON {
  25151. class Sprite {
  25152. name: string;
  25153. position: Vector3;
  25154. color: Color4;
  25155. width: number;
  25156. height: number;
  25157. angle: number;
  25158. cellIndex: number;
  25159. invertU: number;
  25160. invertV: number;
  25161. disposeWhenFinishedAnimating: boolean;
  25162. animations: Animation[];
  25163. isPickable: boolean;
  25164. actionManager: ActionManager;
  25165. private _animationStarted;
  25166. private _loopAnimation;
  25167. private _fromIndex;
  25168. private _toIndex;
  25169. private _delay;
  25170. private _direction;
  25171. private _manager;
  25172. private _time;
  25173. private _onAnimationEnd;
  25174. /**
  25175. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  25176. */
  25177. isVisible: boolean;
  25178. size: number;
  25179. constructor(name: string, manager: SpriteManager);
  25180. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  25181. stopAnimation(): void;
  25182. /** @hidden */
  25183. _animate(deltaTime: number): void;
  25184. dispose(): void;
  25185. }
  25186. }
  25187. declare module BABYLON {
  25188. class SpriteManager {
  25189. name: string;
  25190. sprites: Sprite[];
  25191. renderingGroupId: number;
  25192. layerMask: number;
  25193. fogEnabled: boolean;
  25194. isPickable: boolean;
  25195. cellWidth: number;
  25196. cellHeight: number;
  25197. /**
  25198. * An event triggered when the manager is disposed.
  25199. */
  25200. onDisposeObservable: Observable<SpriteManager>;
  25201. private _onDisposeObserver;
  25202. onDispose: () => void;
  25203. private _capacity;
  25204. private _spriteTexture;
  25205. private _epsilon;
  25206. private _scene;
  25207. private _vertexData;
  25208. private _buffer;
  25209. private _vertexBuffers;
  25210. private _indexBuffer;
  25211. private _effectBase;
  25212. private _effectFog;
  25213. texture: Texture;
  25214. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  25215. private _appendSpriteVertex;
  25216. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  25217. render(): void;
  25218. dispose(): void;
  25219. }
  25220. }
  25221. declare module BABYLON {
  25222. /**
  25223. * @hidden
  25224. **/
  25225. class _AlphaState {
  25226. private _isAlphaBlendDirty;
  25227. private _isBlendFunctionParametersDirty;
  25228. private _isBlendEquationParametersDirty;
  25229. private _isBlendConstantsDirty;
  25230. private _alphaBlend;
  25231. private _blendFunctionParameters;
  25232. private _blendEquationParameters;
  25233. private _blendConstants;
  25234. /**
  25235. * Initializes the state.
  25236. */
  25237. constructor();
  25238. readonly isDirty: boolean;
  25239. alphaBlend: boolean;
  25240. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  25241. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  25242. setAlphaEquationParameters(rgb: number, alpha: number): void;
  25243. reset(): void;
  25244. apply(gl: WebGLRenderingContext): void;
  25245. }
  25246. }
  25247. declare module BABYLON {
  25248. /**
  25249. * @hidden
  25250. **/
  25251. class _DepthCullingState {
  25252. private _isDepthTestDirty;
  25253. private _isDepthMaskDirty;
  25254. private _isDepthFuncDirty;
  25255. private _isCullFaceDirty;
  25256. private _isCullDirty;
  25257. private _isZOffsetDirty;
  25258. private _isFrontFaceDirty;
  25259. private _depthTest;
  25260. private _depthMask;
  25261. private _depthFunc;
  25262. private _cull;
  25263. private _cullFace;
  25264. private _zOffset;
  25265. private _frontFace;
  25266. /**
  25267. * Initializes the state.
  25268. */
  25269. constructor();
  25270. readonly isDirty: boolean;
  25271. zOffset: number;
  25272. cullFace: Nullable<number>;
  25273. cull: Nullable<boolean>;
  25274. depthFunc: Nullable<number>;
  25275. depthMask: boolean;
  25276. depthTest: boolean;
  25277. frontFace: Nullable<number>;
  25278. reset(): void;
  25279. apply(gl: WebGLRenderingContext): void;
  25280. }
  25281. }
  25282. declare module BABYLON {
  25283. /**
  25284. * @hidden
  25285. **/
  25286. class _StencilState {
  25287. private _isStencilTestDirty;
  25288. private _isStencilMaskDirty;
  25289. private _isStencilFuncDirty;
  25290. private _isStencilOpDirty;
  25291. private _stencilTest;
  25292. private _stencilMask;
  25293. private _stencilFunc;
  25294. private _stencilFuncRef;
  25295. private _stencilFuncMask;
  25296. private _stencilOpStencilFail;
  25297. private _stencilOpDepthFail;
  25298. private _stencilOpStencilDepthPass;
  25299. readonly isDirty: boolean;
  25300. stencilFunc: number;
  25301. stencilFuncRef: number;
  25302. stencilFuncMask: number;
  25303. stencilOpStencilFail: number;
  25304. stencilOpDepthFail: number;
  25305. stencilOpStencilDepthPass: number;
  25306. stencilMask: number;
  25307. stencilTest: boolean;
  25308. constructor();
  25309. reset(): void;
  25310. apply(gl: WebGLRenderingContext): void;
  25311. }
  25312. }
  25313. declare module BABYLON {
  25314. /**
  25315. * Class used to evalaute queries containing `and` and `or` operators
  25316. */
  25317. class AndOrNotEvaluator {
  25318. /**
  25319. * Evaluate a query
  25320. * @param query defines the query to evaluate
  25321. * @param evaluateCallback defines the callback used to filter result
  25322. * @returns true if the query matches
  25323. */
  25324. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  25325. private static _HandleParenthesisContent;
  25326. private static _SimplifyNegation;
  25327. }
  25328. }
  25329. declare module BABYLON {
  25330. /**
  25331. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  25332. */
  25333. enum AssetTaskState {
  25334. /**
  25335. * Initialization
  25336. */
  25337. INIT = 0,
  25338. /**
  25339. * Running
  25340. */
  25341. RUNNING = 1,
  25342. /**
  25343. * Done
  25344. */
  25345. DONE = 2,
  25346. /**
  25347. * Error
  25348. */
  25349. ERROR = 3
  25350. }
  25351. /**
  25352. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  25353. */
  25354. abstract class AbstractAssetTask {
  25355. /**
  25356. * Task name
  25357. */ name: string;
  25358. /**
  25359. * Callback called when the task is successful
  25360. */
  25361. onSuccess: (task: any) => void;
  25362. /**
  25363. * Callback called when the task is not successful
  25364. */
  25365. onError: (task: any, message?: string, exception?: any) => void;
  25366. /**
  25367. * Creates a new {BABYLON.AssetsManager}
  25368. * @param name defines the name of the task
  25369. */
  25370. constructor(
  25371. /**
  25372. * Task name
  25373. */ name: string);
  25374. private _isCompleted;
  25375. private _taskState;
  25376. private _errorObject;
  25377. /**
  25378. * Get if the task is completed
  25379. */
  25380. readonly isCompleted: boolean;
  25381. /**
  25382. * Gets the current state of the task
  25383. */
  25384. readonly taskState: AssetTaskState;
  25385. /**
  25386. * Gets the current error object (if task is in error)
  25387. */
  25388. readonly errorObject: {
  25389. message?: string;
  25390. exception?: any;
  25391. };
  25392. /**
  25393. * Internal only
  25394. * @hidden
  25395. */
  25396. _setErrorObject(message?: string, exception?: any): void;
  25397. /**
  25398. * Execute the current task
  25399. * @param scene defines the scene where you want your assets to be loaded
  25400. * @param onSuccess is a callback called when the task is successfully executed
  25401. * @param onError is a callback called if an error occurs
  25402. */
  25403. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  25404. /**
  25405. * Execute the current task
  25406. * @param scene defines the scene where you want your assets to be loaded
  25407. * @param onSuccess is a callback called when the task is successfully executed
  25408. * @param onError is a callback called if an error occurs
  25409. */
  25410. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  25411. /**
  25412. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  25413. * This can be used with failed tasks that have the reason for failure fixed.
  25414. */
  25415. reset(): void;
  25416. private onErrorCallback;
  25417. private onDoneCallback;
  25418. }
  25419. /**
  25420. * Define the interface used by progress events raised during assets loading
  25421. */
  25422. interface IAssetsProgressEvent {
  25423. /**
  25424. * Defines the number of remaining tasks to process
  25425. */
  25426. remainingCount: number;
  25427. /**
  25428. * Defines the total number of tasks
  25429. */
  25430. totalCount: number;
  25431. /**
  25432. * Defines the task that was just processed
  25433. */
  25434. task: AbstractAssetTask;
  25435. }
  25436. /**
  25437. * Class used to share progress information about assets loading
  25438. */
  25439. class AssetsProgressEvent implements IAssetsProgressEvent {
  25440. /**
  25441. * Defines the number of remaining tasks to process
  25442. */
  25443. remainingCount: number;
  25444. /**
  25445. * Defines the total number of tasks
  25446. */
  25447. totalCount: number;
  25448. /**
  25449. * Defines the task that was just processed
  25450. */
  25451. task: AbstractAssetTask;
  25452. /**
  25453. * Creates a {BABYLON.AssetsProgressEvent}
  25454. * @param remainingCount defines the number of remaining tasks to process
  25455. * @param totalCount defines the total number of tasks
  25456. * @param task defines the task that was just processed
  25457. */
  25458. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  25459. }
  25460. /**
  25461. * Define a task used by {BABYLON.AssetsManager} to load meshes
  25462. */
  25463. class MeshAssetTask extends AbstractAssetTask {
  25464. /**
  25465. * Defines the name of the task
  25466. */
  25467. name: string;
  25468. /**
  25469. * Defines the list of mesh's names you want to load
  25470. */
  25471. meshesNames: any;
  25472. /**
  25473. * Defines the root url to use as a base to load your meshes and associated resources
  25474. */
  25475. rootUrl: string;
  25476. /**
  25477. * Defines the filename of the scene to load from
  25478. */
  25479. sceneFilename: string;
  25480. /**
  25481. * Gets the list of loaded meshes
  25482. */
  25483. loadedMeshes: Array<AbstractMesh>;
  25484. /**
  25485. * Gets the list of loaded particle systems
  25486. */
  25487. loadedParticleSystems: Array<IParticleSystem>;
  25488. /**
  25489. * Gets the list of loaded skeletons
  25490. */
  25491. loadedSkeletons: Array<Skeleton>;
  25492. /**
  25493. * Callback called when the task is successful
  25494. */
  25495. onSuccess: (task: MeshAssetTask) => void;
  25496. /**
  25497. * Callback called when the task is successful
  25498. */
  25499. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  25500. /**
  25501. * Creates a new {BABYLON.MeshAssetTask}
  25502. * @param name defines the name of the task
  25503. * @param meshesNames defines the list of mesh's names you want to load
  25504. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  25505. * @param sceneFilename defines the filename of the scene to load from
  25506. */
  25507. constructor(
  25508. /**
  25509. * Defines the name of the task
  25510. */
  25511. name: string,
  25512. /**
  25513. * Defines the list of mesh's names you want to load
  25514. */
  25515. meshesNames: any,
  25516. /**
  25517. * Defines the root url to use as a base to load your meshes and associated resources
  25518. */
  25519. rootUrl: string,
  25520. /**
  25521. * Defines the filename of the scene to load from
  25522. */
  25523. sceneFilename: string);
  25524. /**
  25525. * Execute the current task
  25526. * @param scene defines the scene where you want your assets to be loaded
  25527. * @param onSuccess is a callback called when the task is successfully executed
  25528. * @param onError is a callback called if an error occurs
  25529. */
  25530. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  25531. }
  25532. /**
  25533. * Define a task used by {BABYLON.AssetsManager} to load text content
  25534. */
  25535. class TextFileAssetTask extends AbstractAssetTask {
  25536. /**
  25537. * Defines the name of the task
  25538. */
  25539. name: string;
  25540. /**
  25541. * Defines the location of the file to load
  25542. */
  25543. url: string;
  25544. /**
  25545. * Gets the loaded text string
  25546. */
  25547. text: string;
  25548. /**
  25549. * Callback called when the task is successful
  25550. */
  25551. onSuccess: (task: TextFileAssetTask) => void;
  25552. /**
  25553. * Callback called when the task is successful
  25554. */
  25555. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  25556. /**
  25557. * Creates a new TextFileAssetTask object
  25558. * @param name defines the name of the task
  25559. * @param url defines the location of the file to load
  25560. */
  25561. constructor(
  25562. /**
  25563. * Defines the name of the task
  25564. */
  25565. name: string,
  25566. /**
  25567. * Defines the location of the file to load
  25568. */
  25569. url: string);
  25570. /**
  25571. * Execute the current task
  25572. * @param scene defines the scene where you want your assets to be loaded
  25573. * @param onSuccess is a callback called when the task is successfully executed
  25574. * @param onError is a callback called if an error occurs
  25575. */
  25576. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  25577. }
  25578. /**
  25579. * Define a task used by {BABYLON.AssetsManager} to load binary data
  25580. */
  25581. class BinaryFileAssetTask extends AbstractAssetTask {
  25582. /**
  25583. * Defines the name of the task
  25584. */
  25585. name: string;
  25586. /**
  25587. * Defines the location of the file to load
  25588. */
  25589. url: string;
  25590. /**
  25591. * Gets the lodaded data (as an array buffer)
  25592. */
  25593. data: ArrayBuffer;
  25594. /**
  25595. * Callback called when the task is successful
  25596. */
  25597. onSuccess: (task: BinaryFileAssetTask) => void;
  25598. /**
  25599. * Callback called when the task is successful
  25600. */
  25601. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  25602. /**
  25603. * Creates a new BinaryFileAssetTask object
  25604. * @param name defines the name of the new task
  25605. * @param url defines the location of the file to load
  25606. */
  25607. constructor(
  25608. /**
  25609. * Defines the name of the task
  25610. */
  25611. name: string,
  25612. /**
  25613. * Defines the location of the file to load
  25614. */
  25615. url: string);
  25616. /**
  25617. * Execute the current task
  25618. * @param scene defines the scene where you want your assets to be loaded
  25619. * @param onSuccess is a callback called when the task is successfully executed
  25620. * @param onError is a callback called if an error occurs
  25621. */
  25622. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  25623. }
  25624. /**
  25625. * Define a task used by {BABYLON.AssetsManager} to load images
  25626. */
  25627. class ImageAssetTask extends AbstractAssetTask {
  25628. /**
  25629. * Defines the name of the task
  25630. */
  25631. name: string;
  25632. /**
  25633. * Defines the location of the image to load
  25634. */
  25635. url: string;
  25636. /**
  25637. * Gets the loaded images
  25638. */
  25639. image: HTMLImageElement;
  25640. /**
  25641. * Callback called when the task is successful
  25642. */
  25643. onSuccess: (task: ImageAssetTask) => void;
  25644. /**
  25645. * Callback called when the task is successful
  25646. */
  25647. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  25648. /**
  25649. * Creates a new ImageAssetTask
  25650. * @param name defines the name of the task
  25651. * @param url defines the location of the image to load
  25652. */
  25653. constructor(
  25654. /**
  25655. * Defines the name of the task
  25656. */
  25657. name: string,
  25658. /**
  25659. * Defines the location of the image to load
  25660. */
  25661. url: string);
  25662. /**
  25663. * Execute the current task
  25664. * @param scene defines the scene where you want your assets to be loaded
  25665. * @param onSuccess is a callback called when the task is successfully executed
  25666. * @param onError is a callback called if an error occurs
  25667. */
  25668. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  25669. }
  25670. /**
  25671. * Defines the interface used by texture loading tasks
  25672. */
  25673. interface ITextureAssetTask<TEX extends BaseTexture> {
  25674. /**
  25675. * Gets the loaded texture
  25676. */
  25677. texture: TEX;
  25678. }
  25679. /**
  25680. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  25681. */
  25682. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  25683. /**
  25684. * Defines the name of the task
  25685. */
  25686. name: string;
  25687. /**
  25688. * Defines the location of the file to load
  25689. */
  25690. url: string;
  25691. /**
  25692. * Defines if mipmap should not be generated (default is false)
  25693. */
  25694. noMipmap?: boolean | undefined;
  25695. /**
  25696. * Defines if texture must be inverted on Y axis (default is false)
  25697. */
  25698. invertY?: boolean | undefined;
  25699. /**
  25700. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  25701. */
  25702. samplingMode: number;
  25703. /**
  25704. * Gets the loaded texture
  25705. */
  25706. texture: Texture;
  25707. /**
  25708. * Callback called when the task is successful
  25709. */
  25710. onSuccess: (task: TextureAssetTask) => void;
  25711. /**
  25712. * Callback called when the task is successful
  25713. */
  25714. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  25715. /**
  25716. * Creates a new TextureAssetTask object
  25717. * @param name defines the name of the task
  25718. * @param url defines the location of the file to load
  25719. * @param noMipmap defines if mipmap should not be generated (default is false)
  25720. * @param invertY defines if texture must be inverted on Y axis (default is false)
  25721. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  25722. */
  25723. constructor(
  25724. /**
  25725. * Defines the name of the task
  25726. */
  25727. name: string,
  25728. /**
  25729. * Defines the location of the file to load
  25730. */
  25731. url: string,
  25732. /**
  25733. * Defines if mipmap should not be generated (default is false)
  25734. */
  25735. noMipmap?: boolean | undefined,
  25736. /**
  25737. * Defines if texture must be inverted on Y axis (default is false)
  25738. */
  25739. invertY?: boolean | undefined,
  25740. /**
  25741. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  25742. */
  25743. samplingMode?: number);
  25744. /**
  25745. * Execute the current task
  25746. * @param scene defines the scene where you want your assets to be loaded
  25747. * @param onSuccess is a callback called when the task is successfully executed
  25748. * @param onError is a callback called if an error occurs
  25749. */
  25750. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  25751. }
  25752. /**
  25753. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  25754. */
  25755. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  25756. /**
  25757. * Defines the name of the task
  25758. */
  25759. name: string;
  25760. /**
  25761. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  25762. */
  25763. url: string;
  25764. /**
  25765. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  25766. */
  25767. extensions?: string[] | undefined;
  25768. /**
  25769. * Defines if mipmaps should not be generated (default is false)
  25770. */
  25771. noMipmap?: boolean | undefined;
  25772. /**
  25773. * Defines the explicit list of files (undefined by default)
  25774. */
  25775. files?: string[] | undefined;
  25776. /**
  25777. * Gets the loaded texture
  25778. */
  25779. texture: CubeTexture;
  25780. /**
  25781. * Callback called when the task is successful
  25782. */
  25783. onSuccess: (task: CubeTextureAssetTask) => void;
  25784. /**
  25785. * Callback called when the task is successful
  25786. */
  25787. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  25788. /**
  25789. * Creates a new CubeTextureAssetTask
  25790. * @param name defines the name of the task
  25791. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  25792. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  25793. * @param noMipmap defines if mipmaps should not be generated (default is false)
  25794. * @param files defines the explicit list of files (undefined by default)
  25795. */
  25796. constructor(
  25797. /**
  25798. * Defines the name of the task
  25799. */
  25800. name: string,
  25801. /**
  25802. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  25803. */
  25804. url: string,
  25805. /**
  25806. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  25807. */
  25808. extensions?: string[] | undefined,
  25809. /**
  25810. * Defines if mipmaps should not be generated (default is false)
  25811. */
  25812. noMipmap?: boolean | undefined,
  25813. /**
  25814. * Defines the explicit list of files (undefined by default)
  25815. */
  25816. files?: string[] | undefined);
  25817. /**
  25818. * Execute the current task
  25819. * @param scene defines the scene where you want your assets to be loaded
  25820. * @param onSuccess is a callback called when the task is successfully executed
  25821. * @param onError is a callback called if an error occurs
  25822. */
  25823. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  25824. }
  25825. /**
  25826. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  25827. */
  25828. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  25829. /**
  25830. * Defines the name of the task
  25831. */
  25832. name: string;
  25833. /**
  25834. * Defines the location of the file to load
  25835. */
  25836. url: string;
  25837. /**
  25838. * Defines the desired size (the more it increases the longer the generation will be)
  25839. */
  25840. size: number;
  25841. /**
  25842. * Defines if mipmaps should not be generated (default is false)
  25843. */
  25844. noMipmap: boolean;
  25845. /**
  25846. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  25847. */
  25848. generateHarmonics: boolean;
  25849. /**
  25850. * 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)
  25851. */
  25852. gammaSpace: boolean;
  25853. /**
  25854. * Internal Use Only
  25855. */
  25856. reserved: boolean;
  25857. /**
  25858. * Gets the loaded texture
  25859. */
  25860. texture: HDRCubeTexture;
  25861. /**
  25862. * Callback called when the task is successful
  25863. */
  25864. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  25865. /**
  25866. * Callback called when the task is successful
  25867. */
  25868. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  25869. /**
  25870. * Creates a new HDRCubeTextureAssetTask object
  25871. * @param name defines the name of the task
  25872. * @param url defines the location of the file to load
  25873. * @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.
  25874. * @param noMipmap defines if mipmaps should not be generated (default is false)
  25875. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  25876. * @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)
  25877. * @param reserved Internal use only
  25878. */
  25879. constructor(
  25880. /**
  25881. * Defines the name of the task
  25882. */
  25883. name: string,
  25884. /**
  25885. * Defines the location of the file to load
  25886. */
  25887. url: string,
  25888. /**
  25889. * Defines the desired size (the more it increases the longer the generation will be)
  25890. */
  25891. size: number,
  25892. /**
  25893. * Defines if mipmaps should not be generated (default is false)
  25894. */
  25895. noMipmap?: boolean,
  25896. /**
  25897. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  25898. */
  25899. generateHarmonics?: boolean,
  25900. /**
  25901. * 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)
  25902. */
  25903. gammaSpace?: boolean,
  25904. /**
  25905. * Internal Use Only
  25906. */
  25907. reserved?: boolean);
  25908. /**
  25909. * Execute the current task
  25910. * @param scene defines the scene where you want your assets to be loaded
  25911. * @param onSuccess is a callback called when the task is successfully executed
  25912. * @param onError is a callback called if an error occurs
  25913. */
  25914. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  25915. }
  25916. /**
  25917. * This class can be used to easily import assets into a scene
  25918. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  25919. */
  25920. class AssetsManager {
  25921. private _scene;
  25922. private _isLoading;
  25923. protected _tasks: AbstractAssetTask[];
  25924. protected _waitingTasksCount: number;
  25925. protected _totalTasksCount: number;
  25926. /**
  25927. * Callback called when all tasks are processed
  25928. */
  25929. onFinish: (tasks: AbstractAssetTask[]) => void;
  25930. /**
  25931. * Callback called when a task is successful
  25932. */
  25933. onTaskSuccess: (task: AbstractAssetTask) => void;
  25934. /**
  25935. * Callback called when a task had an error
  25936. */
  25937. onTaskError: (task: AbstractAssetTask) => void;
  25938. /**
  25939. * Callback called when a task is done (whatever the result is)
  25940. */
  25941. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  25942. /**
  25943. * Observable called when all tasks are processed
  25944. */
  25945. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  25946. /**
  25947. * Observable called when a task had an error
  25948. */
  25949. onTaskErrorObservable: Observable<AbstractAssetTask>;
  25950. /**
  25951. * Observable called when a task is successful
  25952. */
  25953. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  25954. /**
  25955. * Observable called when a task is done (whatever the result is)
  25956. */
  25957. onProgressObservable: Observable<IAssetsProgressEvent>;
  25958. /**
  25959. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  25960. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  25961. */
  25962. useDefaultLoadingScreen: boolean;
  25963. /**
  25964. * Creates a new AssetsManager
  25965. * @param scene defines the scene to work on
  25966. */
  25967. constructor(scene: Scene);
  25968. /**
  25969. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  25970. * @param taskName defines the name of the new task
  25971. * @param meshesNames defines the name of meshes to load
  25972. * @param rootUrl defines the root url to use to locate files
  25973. * @param sceneFilename defines the filename of the scene file
  25974. * @returns a new {BABYLON.MeshAssetTask} object
  25975. */
  25976. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  25977. /**
  25978. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  25979. * @param taskName defines the name of the new task
  25980. * @param url defines the url of the file to load
  25981. * @returns a new {BABYLON.TextFileAssetTask} object
  25982. */
  25983. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  25984. /**
  25985. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  25986. * @param taskName defines the name of the new task
  25987. * @param url defines the url of the file to load
  25988. * @returns a new {BABYLON.BinaryFileAssetTask} object
  25989. */
  25990. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  25991. /**
  25992. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  25993. * @param taskName defines the name of the new task
  25994. * @param url defines the url of the file to load
  25995. * @returns a new {BABYLON.ImageAssetTask} object
  25996. */
  25997. addImageTask(taskName: string, url: string): ImageAssetTask;
  25998. /**
  25999. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  26000. * @param taskName defines the name of the new task
  26001. * @param url defines the url of the file to load
  26002. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  26003. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  26004. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  26005. * @returns a new {BABYLON.TextureAssetTask} object
  26006. */
  26007. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  26008. /**
  26009. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  26010. * @param taskName defines the name of the new task
  26011. * @param url defines the url of the file to load
  26012. * @param extensions defines the extension to use to load the cube map (can be null)
  26013. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  26014. * @param files defines the list of files to load (can be null)
  26015. * @returns a new {BABYLON.CubeTextureAssetTask} object
  26016. */
  26017. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  26018. /**
  26019. *
  26020. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  26021. * @param taskName defines the name of the new task
  26022. * @param url defines the url of the file to load
  26023. * @param size defines the size you want for the cubemap (can be null)
  26024. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  26025. * @param generateHarmonics defines if you want to automatically generate (true by default)
  26026. * @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)
  26027. * @param reserved Internal use only
  26028. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  26029. */
  26030. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  26031. /**
  26032. * Remove a task from the assets manager.
  26033. * @param task the task to remove
  26034. */
  26035. removeTask(task: AbstractAssetTask): void;
  26036. private _decreaseWaitingTasksCount;
  26037. private _runTask;
  26038. /**
  26039. * Reset the {BABYLON.AssetsManager} and remove all tasks
  26040. * @return the current instance of the {BABYLON.AssetsManager}
  26041. */
  26042. reset(): AssetsManager;
  26043. /**
  26044. * Start the loading process
  26045. * @return the current instance of the {BABYLON.AssetsManager}
  26046. */
  26047. load(): AssetsManager;
  26048. }
  26049. }
  26050. declare module BABYLON {
  26051. /**
  26052. * Class used to enable access to IndexedDB
  26053. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  26054. */
  26055. class Database {
  26056. private callbackManifestChecked;
  26057. private currentSceneUrl;
  26058. private db;
  26059. private _enableSceneOffline;
  26060. private _enableTexturesOffline;
  26061. private manifestVersionFound;
  26062. private mustUpdateRessources;
  26063. private hasReachedQuota;
  26064. private isSupported;
  26065. private idbFactory;
  26066. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  26067. static IsUASupportingBlobStorage: boolean;
  26068. /** Gets a boolean indicating if Database storate is enabled */
  26069. static IDBStorageEnabled: boolean;
  26070. /**
  26071. * Gets a boolean indicating if scene must be saved in the database
  26072. */
  26073. readonly enableSceneOffline: boolean;
  26074. /**
  26075. * Gets a boolean indicating if textures must be saved in the database
  26076. */
  26077. readonly enableTexturesOffline: boolean;
  26078. /**
  26079. * Creates a new Database
  26080. * @param urlToScene defines the url to load the scene
  26081. * @param callbackManifestChecked defines the callback to use when manifest is checked
  26082. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  26083. */
  26084. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  26085. private static _ParseURL;
  26086. private static _ReturnFullUrlLocation;
  26087. private _checkManifestFile;
  26088. /**
  26089. * Open the database and make it available
  26090. * @param successCallback defines the callback to call on success
  26091. * @param errorCallback defines the callback to call on error
  26092. */
  26093. openAsync(successCallback: () => void, errorCallback: () => void): void;
  26094. /**
  26095. * Loads an image from the database
  26096. * @param url defines the url to load from
  26097. * @param image defines the target DOM image
  26098. */
  26099. loadImageFromDB(url: string, image: HTMLImageElement): void;
  26100. private _loadImageFromDBAsync;
  26101. private _saveImageIntoDBAsync;
  26102. private _checkVersionFromDB;
  26103. private _loadVersionFromDBAsync;
  26104. private _saveVersionIntoDBAsync;
  26105. /**
  26106. * Loads a file from database
  26107. * @param url defines the URL to load from
  26108. * @param sceneLoaded defines a callback to call on success
  26109. * @param progressCallBack defines a callback to call when progress changed
  26110. * @param errorCallback defines a callback to call on error
  26111. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  26112. */
  26113. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  26114. private _loadFileFromDBAsync;
  26115. private _saveFileIntoDBAsync;
  26116. }
  26117. }
  26118. declare module BABYLON {
  26119. interface DDSInfo {
  26120. width: number;
  26121. height: number;
  26122. mipmapCount: number;
  26123. isFourCC: boolean;
  26124. isRGB: boolean;
  26125. isLuminance: boolean;
  26126. isCube: boolean;
  26127. isCompressed: boolean;
  26128. dxgiFormat: number;
  26129. textureType: number;
  26130. /** Sphericle polynomial created for the dds texture */
  26131. sphericalPolynomial?: SphericalPolynomial;
  26132. }
  26133. class DDSTools {
  26134. static StoreLODInAlphaChannel: boolean;
  26135. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  26136. private static _FloatView;
  26137. private static _Int32View;
  26138. private static _ToHalfFloat;
  26139. private static _FromHalfFloat;
  26140. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  26141. private static _GetHalfFloatRGBAArrayBuffer;
  26142. private static _GetFloatRGBAArrayBuffer;
  26143. private static _GetFloatAsUIntRGBAArrayBuffer;
  26144. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  26145. private static _GetRGBAArrayBuffer;
  26146. private static _ExtractLongWordOrder;
  26147. private static _GetRGBArrayBuffer;
  26148. private static _GetLuminanceArrayBuffer;
  26149. /**
  26150. * Uploads DDS Levels to a Babylon Texture
  26151. * @hidden
  26152. */
  26153. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  26154. }
  26155. }
  26156. declare module BABYLON {
  26157. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  26158. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26159. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26160. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26161. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26162. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26163. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26164. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26165. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26166. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26167. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26168. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26169. /**
  26170. * Decorator used to define property that can be serialized as reference to a camera
  26171. * @param sourceName defines the name of the property to decorate
  26172. */
  26173. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26174. class SerializationHelper {
  26175. static Serialize<T>(entity: T, serializationObject?: any): any;
  26176. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  26177. static Clone<T>(creationFunction: () => T, source: T): T;
  26178. static Instanciate<T>(creationFunction: () => T, source: T): T;
  26179. }
  26180. }
  26181. declare module BABYLON {
  26182. /**
  26183. * Wrapper class for promise with external resolve and reject.
  26184. */
  26185. class Deferred<T> {
  26186. /**
  26187. * The promise associated with this deferred object.
  26188. */
  26189. readonly promise: Promise<T>;
  26190. private _resolve;
  26191. private _reject;
  26192. /**
  26193. * The resolve method of the promise associated with this deferred object.
  26194. */
  26195. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  26196. /**
  26197. * The reject method of the promise associated with this deferred object.
  26198. */
  26199. readonly reject: (reason?: any) => void;
  26200. /**
  26201. * Constructor for this deferred object.
  26202. */
  26203. constructor();
  26204. }
  26205. }
  26206. declare module BABYLON {
  26207. /**
  26208. * Raw texture data and descriptor sufficient for WebGL texture upload
  26209. */
  26210. interface EnvironmentTextureInfo {
  26211. /**
  26212. * Version of the environment map
  26213. */
  26214. version: number;
  26215. /**
  26216. * Width of image
  26217. */
  26218. width: number;
  26219. /**
  26220. * Irradiance information stored in the file.
  26221. */
  26222. irradiance: any;
  26223. /**
  26224. * Specular information stored in the file.
  26225. */
  26226. specular: any;
  26227. }
  26228. /**
  26229. * Sets of helpers addressing the serialization and deserialization of environment texture
  26230. * stored in a BabylonJS env file.
  26231. * Those files are usually stored as .env files.
  26232. */
  26233. class EnvironmentTextureTools {
  26234. /**
  26235. * Magic number identifying the env file.
  26236. */
  26237. private static _MagicBytes;
  26238. /**
  26239. * Gets the environment info from an env file.
  26240. * @param data The array buffer containing the .env bytes.
  26241. * @returns the environment file info (the json header) if successfully parsed.
  26242. */
  26243. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  26244. /**
  26245. * Creates an environment texture from a loaded cube texture.
  26246. * @param texture defines the cube texture to convert in env file
  26247. * @return a promise containing the environment data if succesfull.
  26248. */
  26249. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  26250. /**
  26251. * Creates a JSON representation of the spherical data.
  26252. * @param texture defines the texture containing the polynomials
  26253. * @return the JSON representation of the spherical info
  26254. */
  26255. private static _CreateEnvTextureIrradiance;
  26256. /**
  26257. * Uploads the texture info contained in the env file to the GPU.
  26258. * @param texture defines the internal texture to upload to
  26259. * @param arrayBuffer defines the buffer cotaining the data to load
  26260. * @param info defines the texture info retrieved through the GetEnvInfo method
  26261. * @returns a promise
  26262. */
  26263. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  26264. /**
  26265. * Uploads the levels of image data to the GPU.
  26266. * @param texture defines the internal texture to upload to
  26267. * @param imageData defines the array buffer views of image data [mipmap][face]
  26268. * @returns a promise
  26269. */
  26270. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  26271. /**
  26272. * Uploads spherical polynomials information to the texture.
  26273. * @param texture defines the texture we are trying to upload the information to
  26274. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  26275. */
  26276. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  26277. }
  26278. }
  26279. declare module BABYLON {
  26280. class FilesInput {
  26281. static FilesToLoad: {
  26282. [key: string]: File;
  26283. };
  26284. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  26285. private _engine;
  26286. private _currentScene;
  26287. private _sceneLoadedCallback;
  26288. private _progressCallback;
  26289. private _additionalRenderLoopLogicCallback;
  26290. private _textureLoadingCallback;
  26291. private _startingProcessingFilesCallback;
  26292. private _onReloadCallback;
  26293. private _errorCallback;
  26294. private _elementToMonitor;
  26295. private _sceneFileToLoad;
  26296. private _filesToLoad;
  26297. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: () => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  26298. private _dragEnterHandler;
  26299. private _dragOverHandler;
  26300. private _dropHandler;
  26301. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  26302. dispose(): void;
  26303. private renderFunction;
  26304. private drag;
  26305. private drop;
  26306. private _traverseFolder;
  26307. private _processFiles;
  26308. loadFiles(event: any): void;
  26309. private _processReload;
  26310. reload(): void;
  26311. }
  26312. }
  26313. declare module BABYLON {
  26314. /**
  26315. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  26316. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  26317. */
  26318. class KhronosTextureContainer {
  26319. arrayBuffer: any;
  26320. static HEADER_LEN: number;
  26321. static COMPRESSED_2D: number;
  26322. static COMPRESSED_3D: number;
  26323. static TEX_2D: number;
  26324. static TEX_3D: number;
  26325. glType: number;
  26326. glTypeSize: number;
  26327. glFormat: number;
  26328. glInternalFormat: number;
  26329. glBaseInternalFormat: number;
  26330. pixelWidth: number;
  26331. pixelHeight: number;
  26332. pixelDepth: number;
  26333. numberOfArrayElements: number;
  26334. numberOfFaces: number;
  26335. numberOfMipmapLevels: number;
  26336. bytesOfKeyValueData: number;
  26337. loadType: number;
  26338. /**
  26339. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  26340. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  26341. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  26342. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  26343. */
  26344. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  26345. switchEndainness(val: number): number;
  26346. /**
  26347. * Uploads KTX content to a Babylon Texture.
  26348. * It is assumed that the texture has already been created & is currently bound
  26349. * @hidden
  26350. */
  26351. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  26352. private _upload2DCompressedLevels;
  26353. }
  26354. }
  26355. declare module BABYLON {
  26356. /**
  26357. * A class serves as a medium between the observable and its observers
  26358. */
  26359. class EventState {
  26360. /**
  26361. * Create a new EventState
  26362. * @param mask defines the mask associated with this state
  26363. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  26364. * @param target defines the original target of the state
  26365. * @param currentTarget defines the current target of the state
  26366. */
  26367. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  26368. /**
  26369. * Initialize the current event state
  26370. * @param mask defines the mask associated with this state
  26371. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  26372. * @param target defines the original target of the state
  26373. * @param currentTarget defines the current target of the state
  26374. * @returns the current event state
  26375. */
  26376. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  26377. /**
  26378. * An Observer can set this property to true to prevent subsequent observers of being notified
  26379. */
  26380. skipNextObservers: boolean;
  26381. /**
  26382. * Get the mask value that were used to trigger the event corresponding to this EventState object
  26383. */
  26384. mask: number;
  26385. /**
  26386. * The object that originally notified the event
  26387. */
  26388. target?: any;
  26389. /**
  26390. * The current object in the bubbling phase
  26391. */
  26392. currentTarget?: any;
  26393. /**
  26394. * This will be populated with the return value of the last function that was executed.
  26395. * If it is the first function in the callback chain it will be the event data.
  26396. */
  26397. lastReturnValue?: any;
  26398. }
  26399. /**
  26400. * Represent an Observer registered to a given Observable object.
  26401. */
  26402. class Observer<T> {
  26403. /**
  26404. * Defines the callback to call when the observer is notified
  26405. */
  26406. callback: (eventData: T, eventState: EventState) => void;
  26407. /**
  26408. * Defines the mask of the observer (used to filter notifications)
  26409. */
  26410. mask: number;
  26411. /**
  26412. * Defines the current scope used to restore the JS context
  26413. */
  26414. scope: any;
  26415. /** @hidden */
  26416. _willBeUnregistered: boolean;
  26417. /**
  26418. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  26419. */
  26420. unregisterOnNextCall: boolean;
  26421. /**
  26422. * Creates a new observer
  26423. * @param callback defines the callback to call when the observer is notified
  26424. * @param mask defines the mask of the observer (used to filter notifications)
  26425. * @param scope defines the current scope used to restore the JS context
  26426. */
  26427. constructor(
  26428. /**
  26429. * Defines the callback to call when the observer is notified
  26430. */
  26431. callback: (eventData: T, eventState: EventState) => void,
  26432. /**
  26433. * Defines the mask of the observer (used to filter notifications)
  26434. */
  26435. mask: number,
  26436. /**
  26437. * Defines the current scope used to restore the JS context
  26438. */
  26439. scope?: any);
  26440. }
  26441. /**
  26442. * Represent a list of observers registered to multiple Observables object.
  26443. */
  26444. class MultiObserver<T> {
  26445. private _observers;
  26446. private _observables;
  26447. /**
  26448. * Release associated resources
  26449. */
  26450. dispose(): void;
  26451. /**
  26452. * Raise a callback when one of the observable will notify
  26453. * @param observables defines a list of observables to watch
  26454. * @param callback defines the callback to call on notification
  26455. * @param mask defines the mask used to filter notifications
  26456. * @param scope defines the current scope used to restore the JS context
  26457. * @returns the new MultiObserver
  26458. */
  26459. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  26460. }
  26461. /**
  26462. * The Observable class is a simple implementation of the Observable pattern.
  26463. *
  26464. * 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.
  26465. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  26466. * 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).
  26467. * 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.
  26468. */
  26469. class Observable<T> {
  26470. private _observers;
  26471. private _eventState;
  26472. private _onObserverAdded;
  26473. /**
  26474. * Creates a new observable
  26475. * @param onObserverAdded defines a callback to call when a new observer is added
  26476. */
  26477. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  26478. /**
  26479. * Create a new Observer with the specified callback
  26480. * @param callback the callback that will be executed for that Observer
  26481. * @param mask the mask used to filter observers
  26482. * @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.
  26483. * @param scope optional scope for the callback to be called from
  26484. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  26485. * @returns the new observer created for the callback
  26486. */
  26487. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  26488. /**
  26489. * Create a new Observer with the specified callback and unregisters after the next notification
  26490. * @param callback the callback that will be executed for that Observer
  26491. * @returns the new observer created for the callback
  26492. */
  26493. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  26494. /**
  26495. * Remove an Observer from the Observable object
  26496. * @param observer the instance of the Observer to remove
  26497. * @returns false if it doesn't belong to this Observable
  26498. */
  26499. remove(observer: Nullable<Observer<T>>): boolean;
  26500. /**
  26501. * Remove a callback from the Observable object
  26502. * @param callback the callback to remove
  26503. * @param scope optional scope. If used only the callbacks with this scope will be removed
  26504. * @returns false if it doesn't belong to this Observable
  26505. */
  26506. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  26507. private _deferUnregister;
  26508. private _remove;
  26509. /**
  26510. * Notify all Observers by calling their respective callback with the given data
  26511. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  26512. * @param eventData defines the data to send to all observers
  26513. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  26514. * @param target defines the original target of the state
  26515. * @param currentTarget defines the current target of the state
  26516. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  26517. */
  26518. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  26519. /**
  26520. * Calling this will execute each callback, expecting it to be a promise or return a value.
  26521. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  26522. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  26523. * and it is crucial that all callbacks will be executed.
  26524. * The order of the callbacks is kept, callbacks are not executed parallel.
  26525. *
  26526. * @param eventData The data to be sent to each callback
  26527. * @param mask is used to filter observers defaults to -1
  26528. * @param target defines the callback target (see EventState)
  26529. * @param currentTarget defines he current object in the bubbling phase
  26530. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  26531. */
  26532. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  26533. /**
  26534. * Notify a specific observer
  26535. * @param observer defines the observer to notify
  26536. * @param eventData defines the data to be sent to each callback
  26537. * @param mask is used to filter observers defaults to -1
  26538. */
  26539. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  26540. /**
  26541. * Gets a boolean indicating if the observable has at least one observer
  26542. * @returns true is the Observable has at least one Observer registered
  26543. */
  26544. hasObservers(): boolean;
  26545. /**
  26546. * Clear the list of observers
  26547. */
  26548. clear(): void;
  26549. /**
  26550. * Clone the current observable
  26551. * @returns a new observable
  26552. */
  26553. clone(): Observable<T>;
  26554. /**
  26555. * Does this observable handles observer registered with a given mask
  26556. * @param mask defines the mask to be tested
  26557. * @return whether or not one observer registered with the given mask is handeled
  26558. **/
  26559. hasSpecificMask(mask?: number): boolean;
  26560. }
  26561. }
  26562. declare module BABYLON {
  26563. /**
  26564. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  26565. */
  26566. class PerformanceMonitor {
  26567. private _enabled;
  26568. private _rollingFrameTime;
  26569. private _lastFrameTimeMs;
  26570. /**
  26571. * constructor
  26572. * @param frameSampleSize The number of samples required to saturate the sliding window
  26573. */
  26574. constructor(frameSampleSize?: number);
  26575. /**
  26576. * Samples current frame
  26577. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  26578. */
  26579. sampleFrame(timeMs?: number): void;
  26580. /**
  26581. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  26582. * @return Average frame time in milliseconds
  26583. */
  26584. readonly averageFrameTime: number;
  26585. /**
  26586. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  26587. * @return Frame time variance in milliseconds squared
  26588. */
  26589. readonly averageFrameTimeVariance: number;
  26590. /**
  26591. * Returns the frame time of the most recent frame
  26592. * @return Frame time in milliseconds
  26593. */
  26594. readonly instantaneousFrameTime: number;
  26595. /**
  26596. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  26597. * @return Framerate in frames per second
  26598. */
  26599. readonly averageFPS: number;
  26600. /**
  26601. * Returns the average framerate in frames per second using the most recent frame time
  26602. * @return Framerate in frames per second
  26603. */
  26604. readonly instantaneousFPS: number;
  26605. /**
  26606. * Returns true if enough samples have been taken to completely fill the sliding window
  26607. * @return true if saturated
  26608. */
  26609. readonly isSaturated: boolean;
  26610. /**
  26611. * Enables contributions to the sliding window sample set
  26612. */
  26613. enable(): void;
  26614. /**
  26615. * Disables contributions to the sliding window sample set
  26616. * Samples will not be interpolated over the disabled period
  26617. */
  26618. disable(): void;
  26619. /**
  26620. * Returns true if sampling is enabled
  26621. * @return true if enabled
  26622. */
  26623. readonly isEnabled: boolean;
  26624. /**
  26625. * Resets performance monitor
  26626. */
  26627. reset(): void;
  26628. }
  26629. /**
  26630. * RollingAverage
  26631. *
  26632. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  26633. */
  26634. class RollingAverage {
  26635. /**
  26636. * Current average
  26637. */
  26638. average: number;
  26639. /**
  26640. * Current variance
  26641. */
  26642. variance: number;
  26643. protected _samples: Array<number>;
  26644. protected _sampleCount: number;
  26645. protected _pos: number;
  26646. protected _m2: number;
  26647. /**
  26648. * constructor
  26649. * @param length The number of samples required to saturate the sliding window
  26650. */
  26651. constructor(length: number);
  26652. /**
  26653. * Adds a sample to the sample set
  26654. * @param v The sample value
  26655. */
  26656. add(v: number): void;
  26657. /**
  26658. * Returns previously added values or null if outside of history or outside the sliding window domain
  26659. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  26660. * @return Value previously recorded with add() or null if outside of range
  26661. */
  26662. history(i: number): number;
  26663. /**
  26664. * Returns true if enough samples have been taken to completely fill the sliding window
  26665. * @return true if sample-set saturated
  26666. */
  26667. isSaturated(): boolean;
  26668. /**
  26669. * Resets the rolling average (equivalent to 0 samples taken so far)
  26670. */
  26671. reset(): void;
  26672. /**
  26673. * Wraps a value around the sample range boundaries
  26674. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  26675. * @return Wrapped position in sample range
  26676. */
  26677. protected _wrapPosition(i: number): number;
  26678. }
  26679. }
  26680. declare module BABYLON {
  26681. /**
  26682. * Helper class that provides a small promise polyfill
  26683. */
  26684. class PromisePolyfill {
  26685. /**
  26686. * Static function used to check if the polyfill is required
  26687. * If this is the case then the function will inject the polyfill to window.Promise
  26688. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  26689. */
  26690. static Apply(force?: boolean): void;
  26691. }
  26692. }
  26693. declare module BABYLON {
  26694. /**
  26695. * Defines the root class used to create scene optimization to use with SceneOptimizer
  26696. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26697. */
  26698. class SceneOptimization {
  26699. /**
  26700. * Defines the priority of this optimization (0 by default which means first in the list)
  26701. */
  26702. priority: number;
  26703. /**
  26704. * Gets a string describing the action executed by the current optimization
  26705. * @returns description string
  26706. */
  26707. getDescription(): string;
  26708. /**
  26709. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  26710. * @param scene defines the current scene where to apply this optimization
  26711. * @param optimizer defines the current optimizer
  26712. * @returns true if everything that can be done was applied
  26713. */
  26714. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  26715. /**
  26716. * Creates the SceneOptimization object
  26717. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  26718. * @param desc defines the description associated with the optimization
  26719. */
  26720. constructor(
  26721. /**
  26722. * Defines the priority of this optimization (0 by default which means first in the list)
  26723. */
  26724. priority?: number);
  26725. }
  26726. /**
  26727. * Defines an optimization used to reduce the size of render target textures
  26728. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26729. */
  26730. class TextureOptimization extends SceneOptimization {
  26731. /**
  26732. * Defines the priority of this optimization (0 by default which means first in the list)
  26733. */
  26734. priority: number;
  26735. /**
  26736. * 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
  26737. */
  26738. maximumSize: number;
  26739. /**
  26740. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  26741. */
  26742. step: number;
  26743. /**
  26744. * Gets a string describing the action executed by the current optimization
  26745. * @returns description string
  26746. */
  26747. getDescription(): string;
  26748. /**
  26749. * Creates the TextureOptimization object
  26750. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  26751. * @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
  26752. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  26753. */
  26754. constructor(
  26755. /**
  26756. * Defines the priority of this optimization (0 by default which means first in the list)
  26757. */
  26758. priority?: number,
  26759. /**
  26760. * 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
  26761. */
  26762. maximumSize?: number,
  26763. /**
  26764. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  26765. */
  26766. step?: number);
  26767. /**
  26768. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  26769. * @param scene defines the current scene where to apply this optimization
  26770. * @param optimizer defines the current optimizer
  26771. * @returns true if everything that can be done was applied
  26772. */
  26773. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  26774. }
  26775. /**
  26776. * Defines an optimization used to increase or decrease the rendering resolution
  26777. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26778. */
  26779. class HardwareScalingOptimization extends SceneOptimization {
  26780. /**
  26781. * Defines the priority of this optimization (0 by default which means first in the list)
  26782. */
  26783. priority: number;
  26784. /**
  26785. * Defines the maximum scale to use (2 by default)
  26786. */
  26787. maximumScale: number;
  26788. /**
  26789. * Defines the step to use between two passes (0.5 by default)
  26790. */
  26791. step: number;
  26792. private _currentScale;
  26793. private _directionOffset;
  26794. /**
  26795. * Gets a string describing the action executed by the current optimization
  26796. * @return description string
  26797. */
  26798. getDescription(): string;
  26799. /**
  26800. * Creates the HardwareScalingOptimization object
  26801. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  26802. * @param maximumScale defines the maximum scale to use (2 by default)
  26803. * @param step defines the step to use between two passes (0.5 by default)
  26804. */
  26805. constructor(
  26806. /**
  26807. * Defines the priority of this optimization (0 by default which means first in the list)
  26808. */
  26809. priority?: number,
  26810. /**
  26811. * Defines the maximum scale to use (2 by default)
  26812. */
  26813. maximumScale?: number,
  26814. /**
  26815. * Defines the step to use between two passes (0.5 by default)
  26816. */
  26817. step?: number);
  26818. /**
  26819. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  26820. * @param scene defines the current scene where to apply this optimization
  26821. * @param optimizer defines the current optimizer
  26822. * @returns true if everything that can be done was applied
  26823. */
  26824. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  26825. }
  26826. /**
  26827. * Defines an optimization used to remove shadows
  26828. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26829. */
  26830. class ShadowsOptimization extends SceneOptimization {
  26831. /**
  26832. * Gets a string describing the action executed by the current optimization
  26833. * @return description string
  26834. */
  26835. getDescription(): string;
  26836. /**
  26837. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  26838. * @param scene defines the current scene where to apply this optimization
  26839. * @param optimizer defines the current optimizer
  26840. * @returns true if everything that can be done was applied
  26841. */
  26842. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  26843. }
  26844. /**
  26845. * Defines an optimization used to turn post-processes off
  26846. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26847. */
  26848. class PostProcessesOptimization extends SceneOptimization {
  26849. /**
  26850. * Gets a string describing the action executed by the current optimization
  26851. * @return description string
  26852. */
  26853. getDescription(): string;
  26854. /**
  26855. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  26856. * @param scene defines the current scene where to apply this optimization
  26857. * @param optimizer defines the current optimizer
  26858. * @returns true if everything that can be done was applied
  26859. */
  26860. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  26861. }
  26862. /**
  26863. * Defines an optimization used to turn lens flares off
  26864. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26865. */
  26866. class LensFlaresOptimization extends SceneOptimization {
  26867. /**
  26868. * Gets a string describing the action executed by the current optimization
  26869. * @return description string
  26870. */
  26871. getDescription(): string;
  26872. /**
  26873. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  26874. * @param scene defines the current scene where to apply this optimization
  26875. * @param optimizer defines the current optimizer
  26876. * @returns true if everything that can be done was applied
  26877. */
  26878. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  26879. }
  26880. /**
  26881. * Defines an optimization based on user defined callback.
  26882. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26883. */
  26884. class CustomOptimization extends SceneOptimization {
  26885. /**
  26886. * Callback called to apply the custom optimization.
  26887. */
  26888. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  26889. /**
  26890. * Callback called to get custom description
  26891. */
  26892. onGetDescription: () => string;
  26893. /**
  26894. * Gets a string describing the action executed by the current optimization
  26895. * @returns description string
  26896. */
  26897. getDescription(): string;
  26898. /**
  26899. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  26900. * @param scene defines the current scene where to apply this optimization
  26901. * @param optimizer defines the current optimizer
  26902. * @returns true if everything that can be done was applied
  26903. */
  26904. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  26905. }
  26906. /**
  26907. * Defines an optimization used to turn particles off
  26908. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26909. */
  26910. class ParticlesOptimization extends SceneOptimization {
  26911. /**
  26912. * Gets a string describing the action executed by the current optimization
  26913. * @return description string
  26914. */
  26915. getDescription(): string;
  26916. /**
  26917. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  26918. * @param scene defines the current scene where to apply this optimization
  26919. * @param optimizer defines the current optimizer
  26920. * @returns true if everything that can be done was applied
  26921. */
  26922. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  26923. }
  26924. /**
  26925. * Defines an optimization used to turn render targets off
  26926. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26927. */
  26928. class RenderTargetsOptimization extends SceneOptimization {
  26929. /**
  26930. * Gets a string describing the action executed by the current optimization
  26931. * @return description string
  26932. */
  26933. getDescription(): string;
  26934. /**
  26935. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  26936. * @param scene defines the current scene where to apply this optimization
  26937. * @param optimizer defines the current optimizer
  26938. * @returns true if everything that can be done was applied
  26939. */
  26940. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  26941. }
  26942. /**
  26943. * Defines an optimization used to merge meshes with compatible materials
  26944. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26945. */
  26946. class MergeMeshesOptimization extends SceneOptimization {
  26947. private static _UpdateSelectionTree;
  26948. /**
  26949. * Gets or sets a boolean which defines if optimization octree has to be updated
  26950. */
  26951. /**
  26952. * Gets or sets a boolean which defines if optimization octree has to be updated
  26953. */
  26954. static UpdateSelectionTree: boolean;
  26955. /**
  26956. * Gets a string describing the action executed by the current optimization
  26957. * @return description string
  26958. */
  26959. getDescription(): string;
  26960. private _canBeMerged;
  26961. /**
  26962. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  26963. * @param scene defines the current scene where to apply this optimization
  26964. * @param optimizer defines the current optimizer
  26965. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  26966. * @returns true if everything that can be done was applied
  26967. */
  26968. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  26969. }
  26970. /**
  26971. * Defines a list of options used by SceneOptimizer
  26972. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26973. */
  26974. class SceneOptimizerOptions {
  26975. /**
  26976. * Defines the target frame rate to reach (60 by default)
  26977. */
  26978. targetFrameRate: number;
  26979. /**
  26980. * Defines the interval between two checkes (2000ms by default)
  26981. */
  26982. trackerDuration: number;
  26983. /**
  26984. * Gets the list of optimizations to apply
  26985. */
  26986. optimizations: SceneOptimization[];
  26987. /**
  26988. * Creates a new list of options used by SceneOptimizer
  26989. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  26990. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  26991. */
  26992. constructor(
  26993. /**
  26994. * Defines the target frame rate to reach (60 by default)
  26995. */
  26996. targetFrameRate?: number,
  26997. /**
  26998. * Defines the interval between two checkes (2000ms by default)
  26999. */
  27000. trackerDuration?: number);
  27001. /**
  27002. * Add a new optimization
  27003. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  27004. * @returns the current SceneOptimizerOptions
  27005. */
  27006. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  27007. /**
  27008. * Add a new custom optimization
  27009. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  27010. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  27011. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  27012. * @returns the current SceneOptimizerOptions
  27013. */
  27014. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  27015. /**
  27016. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  27017. * @param targetFrameRate defines the target frame rate (60 by default)
  27018. * @returns a SceneOptimizerOptions object
  27019. */
  27020. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  27021. /**
  27022. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  27023. * @param targetFrameRate defines the target frame rate (60 by default)
  27024. * @returns a SceneOptimizerOptions object
  27025. */
  27026. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  27027. /**
  27028. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  27029. * @param targetFrameRate defines the target frame rate (60 by default)
  27030. * @returns a SceneOptimizerOptions object
  27031. */
  27032. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  27033. }
  27034. /**
  27035. * Class used to run optimizations in order to reach a target frame rate
  27036. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27037. */
  27038. class SceneOptimizer implements IDisposable {
  27039. private _isRunning;
  27040. private _options;
  27041. private _scene;
  27042. private _currentPriorityLevel;
  27043. private _targetFrameRate;
  27044. private _trackerDuration;
  27045. private _currentFrameRate;
  27046. private _sceneDisposeObserver;
  27047. private _improvementMode;
  27048. /**
  27049. * Defines an observable called when the optimizer reaches the target frame rate
  27050. */
  27051. onSuccessObservable: Observable<SceneOptimizer>;
  27052. /**
  27053. * Defines an observable called when the optimizer enables an optimization
  27054. */
  27055. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  27056. /**
  27057. * Defines an observable called when the optimizer is not able to reach the target frame rate
  27058. */
  27059. onFailureObservable: Observable<SceneOptimizer>;
  27060. /**
  27061. * Gets a boolean indicating if the optimizer is in improvement mode
  27062. */
  27063. readonly isInImprovementMode: boolean;
  27064. /**
  27065. * Gets the current priority level (0 at start)
  27066. */
  27067. readonly currentPriorityLevel: number;
  27068. /**
  27069. * Gets the current frame rate checked by the SceneOptimizer
  27070. */
  27071. readonly currentFrameRate: number;
  27072. /**
  27073. * Gets or sets the current target frame rate (60 by default)
  27074. */
  27075. /**
  27076. * Gets or sets the current target frame rate (60 by default)
  27077. */
  27078. targetFrameRate: number;
  27079. /**
  27080. * Gets or sets the current interval between two checks (every 2000ms by default)
  27081. */
  27082. /**
  27083. * Gets or sets the current interval between two checks (every 2000ms by default)
  27084. */
  27085. trackerDuration: number;
  27086. /**
  27087. * Gets the list of active optimizations
  27088. */
  27089. readonly optimizations: SceneOptimization[];
  27090. /**
  27091. * Creates a new SceneOptimizer
  27092. * @param scene defines the scene to work on
  27093. * @param options defines the options to use with the SceneOptimizer
  27094. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  27095. * @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)
  27096. */
  27097. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  27098. /**
  27099. * Stops the current optimizer
  27100. */
  27101. stop(): void;
  27102. /**
  27103. * Reset the optimizer to initial step (current priority level = 0)
  27104. */
  27105. reset(): void;
  27106. /**
  27107. * Start the optimizer. By default it will try to reach a specific framerate
  27108. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  27109. */
  27110. start(): void;
  27111. private _checkCurrentState;
  27112. /**
  27113. * Release all resources
  27114. */
  27115. dispose(): void;
  27116. /**
  27117. * Helper function to create a SceneOptimizer with one single line of code
  27118. * @param scene defines the scene to work on
  27119. * @param options defines the options to use with the SceneOptimizer
  27120. * @param onSuccess defines a callback to call on success
  27121. * @param onFailure defines a callback to call on failure
  27122. * @returns the new SceneOptimizer object
  27123. */
  27124. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  27125. }
  27126. }
  27127. declare module BABYLON {
  27128. class SceneSerializer {
  27129. static ClearCache(): void;
  27130. static Serialize(scene: Scene): any;
  27131. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  27132. }
  27133. }
  27134. declare module BABYLON {
  27135. class SmartArray<T> {
  27136. data: Array<T>;
  27137. length: number;
  27138. protected _id: number;
  27139. [index: number]: T;
  27140. constructor(capacity: number);
  27141. push(value: T): void;
  27142. forEach(func: (content: T) => void): void;
  27143. sort(compareFn: (a: T, b: T) => number): void;
  27144. reset(): void;
  27145. dispose(): void;
  27146. concat(array: any): void;
  27147. indexOf(value: T): number;
  27148. contains(value: T): boolean;
  27149. private static _GlobalId;
  27150. }
  27151. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  27152. private _duplicateId;
  27153. [index: number]: T;
  27154. push(value: T): void;
  27155. pushNoDuplicate(value: T): boolean;
  27156. reset(): void;
  27157. concatWithNoDuplicate(array: any): void;
  27158. }
  27159. }
  27160. declare module BABYLON {
  27161. /**
  27162. * This class implement a typical dictionary using a string as key and the generic type T as value.
  27163. * The underlying implementation relies on an associative array to ensure the best performances.
  27164. * The value can be anything including 'null' but except 'undefined'
  27165. */
  27166. class StringDictionary<T> {
  27167. /**
  27168. * This will clear this dictionary and copy the content from the 'source' one.
  27169. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  27170. * @param source the dictionary to take the content from and copy to this dictionary
  27171. */
  27172. copyFrom(source: StringDictionary<T>): void;
  27173. /**
  27174. * Get a value based from its key
  27175. * @param key the given key to get the matching value from
  27176. * @return the value if found, otherwise undefined is returned
  27177. */
  27178. get(key: string): T | undefined;
  27179. /**
  27180. * Get a value from its key or add it if it doesn't exist.
  27181. * This method will ensure you that a given key/data will be present in the dictionary.
  27182. * @param key the given key to get the matching value from
  27183. * @param factory the factory that will create the value if the key is not present in the dictionary.
  27184. * The factory will only be invoked if there's no data for the given key.
  27185. * @return the value corresponding to the key.
  27186. */
  27187. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  27188. /**
  27189. * Get a value from its key if present in the dictionary otherwise add it
  27190. * @param key the key to get the value from
  27191. * @param val if there's no such key/value pair in the dictionary add it with this value
  27192. * @return the value corresponding to the key
  27193. */
  27194. getOrAdd(key: string, val: T): T;
  27195. /**
  27196. * Check if there's a given key in the dictionary
  27197. * @param key the key to check for
  27198. * @return true if the key is present, false otherwise
  27199. */
  27200. contains(key: string): boolean;
  27201. /**
  27202. * Add a new key and its corresponding value
  27203. * @param key the key to add
  27204. * @param value the value corresponding to the key
  27205. * @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
  27206. */
  27207. add(key: string, value: T): boolean;
  27208. set(key: string, value: T): boolean;
  27209. /**
  27210. * Get the element of the given key and remove it from the dictionary
  27211. * @param key
  27212. */
  27213. getAndRemove(key: string): Nullable<T>;
  27214. /**
  27215. * Remove a key/value from the dictionary.
  27216. * @param key the key to remove
  27217. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  27218. */
  27219. remove(key: string): boolean;
  27220. /**
  27221. * Clear the whole content of the dictionary
  27222. */
  27223. clear(): void;
  27224. readonly count: number;
  27225. /**
  27226. * Execute a callback on each key/val of the dictionary.
  27227. * Note that you can remove any element in this dictionary in the callback implementation
  27228. * @param callback the callback to execute on a given key/value pair
  27229. */
  27230. forEach(callback: (key: string, val: T) => void): void;
  27231. /**
  27232. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  27233. * If the callback returns null or undefined the method will iterate to the next key/value pair
  27234. * Note that you can remove any element in this dictionary in the callback implementation
  27235. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  27236. */
  27237. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  27238. private _count;
  27239. private _data;
  27240. }
  27241. }
  27242. declare module BABYLON {
  27243. class Tags {
  27244. static EnableFor(obj: any): void;
  27245. static DisableFor(obj: any): void;
  27246. static HasTags(obj: any): boolean;
  27247. static GetTags(obj: any, asString?: boolean): any;
  27248. static AddTagsTo(obj: any, tagsString: string): void;
  27249. static _AddTagTo(obj: any, tag: string): void;
  27250. static RemoveTagsFrom(obj: any, tagsString: string): void;
  27251. static _RemoveTagFrom(obj: any, tag: string): void;
  27252. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  27253. }
  27254. }
  27255. declare module BABYLON {
  27256. class TextureTools {
  27257. /**
  27258. * Uses the GPU to create a copy texture rescaled at a given size
  27259. * @param texture Texture to copy from
  27260. * @param width Desired width
  27261. * @param height Desired height
  27262. * @return Generated texture
  27263. */
  27264. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  27265. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  27266. private static _environmentBRDFBase64Texture;
  27267. }
  27268. }
  27269. declare module BABYLON {
  27270. class TGATools {
  27271. private static _TYPE_INDEXED;
  27272. private static _TYPE_RGB;
  27273. private static _TYPE_GREY;
  27274. private static _TYPE_RLE_INDEXED;
  27275. private static _TYPE_RLE_RGB;
  27276. private static _TYPE_RLE_GREY;
  27277. private static _ORIGIN_MASK;
  27278. private static _ORIGIN_SHIFT;
  27279. private static _ORIGIN_BL;
  27280. private static _ORIGIN_BR;
  27281. private static _ORIGIN_UL;
  27282. private static _ORIGIN_UR;
  27283. static GetTGAHeader(data: Uint8Array): any;
  27284. /**
  27285. * Uploads TGA content to a Babylon Texture
  27286. * @hidden
  27287. */
  27288. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  27289. 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;
  27290. 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;
  27291. 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;
  27292. 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;
  27293. 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;
  27294. 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;
  27295. }
  27296. }
  27297. declare module BABYLON {
  27298. interface IAnimatable {
  27299. animations: Array<Animation>;
  27300. }
  27301. /** Interface used by value gradients (color, factor, ...) */
  27302. interface IValueGradient {
  27303. /**
  27304. * Gets or sets the gradient value (between 0 and 1)
  27305. */
  27306. gradient: number;
  27307. }
  27308. /** Class used to store color gradient */
  27309. class ColorGradient implements IValueGradient {
  27310. /**
  27311. * Gets or sets the gradient value (between 0 and 1)
  27312. */
  27313. gradient: number;
  27314. /**
  27315. * Gets or sets first associated color
  27316. */
  27317. color1: Color4;
  27318. /**
  27319. * Gets or sets second associated color
  27320. */
  27321. color2?: Color4;
  27322. /**
  27323. * Will get a color picked randomly between color1 and color2.
  27324. * If color2 is undefined then color1 will be used
  27325. * @param result defines the target Color4 to store the result in
  27326. */
  27327. getColorToRef(result: Color4): void;
  27328. }
  27329. /** Class used to store factor gradient */
  27330. class FactorGradient implements IValueGradient {
  27331. /**
  27332. * Gets or sets the gradient value (between 0 and 1)
  27333. */
  27334. gradient: number;
  27335. /**
  27336. * Gets or sets first associated factor
  27337. */
  27338. factor1: number;
  27339. /**
  27340. * Gets or sets second associated factor
  27341. */
  27342. factor2?: number;
  27343. /**
  27344. * Will get a number picked randomly between factor1 and factor2.
  27345. * If factor2 is undefined then factor1 will be used
  27346. * @returns the picked number
  27347. */
  27348. getFactor(): number;
  27349. }
  27350. class LoadFileError extends Error {
  27351. request?: XMLHttpRequest | undefined;
  27352. private static _setPrototypeOf;
  27353. constructor(message: string, request?: XMLHttpRequest | undefined);
  27354. }
  27355. class RetryStrategy {
  27356. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  27357. }
  27358. interface IFileRequest {
  27359. /**
  27360. * Raised when the request is complete (success or error).
  27361. */
  27362. onCompleteObservable: Observable<IFileRequest>;
  27363. /**
  27364. * Aborts the request for a file.
  27365. */
  27366. abort: () => void;
  27367. }
  27368. class Tools {
  27369. static BaseUrl: string;
  27370. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  27371. /**
  27372. * Default behaviour for cors in the application.
  27373. * It can be a string if the expected behavior is identical in the entire app.
  27374. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  27375. */
  27376. static CorsBehavior: string | ((url: string | string[]) => string);
  27377. static UseFallbackTexture: boolean;
  27378. /**
  27379. * Use this object to register external classes like custom textures or material
  27380. * to allow the laoders to instantiate them
  27381. */
  27382. static RegisteredExternalClasses: {
  27383. [key: string]: Object;
  27384. };
  27385. static fallbackTexture: string;
  27386. /**
  27387. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  27388. * @param u defines the coordinate on X axis
  27389. * @param v defines the coordinate on Y axis
  27390. * @param width defines the width of the source data
  27391. * @param height defines the height of the source data
  27392. * @param pixels defines the source byte array
  27393. * @param color defines the output color
  27394. */
  27395. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  27396. /**
  27397. * Interpolates between a and b via alpha
  27398. * @param a The lower value (returned when alpha = 0)
  27399. * @param b The upper value (returned when alpha = 1)
  27400. * @param alpha The interpolation-factor
  27401. * @return The mixed value
  27402. */
  27403. static Mix(a: number, b: number, alpha: number): number;
  27404. static Instantiate(className: string): any;
  27405. /**
  27406. * Provides a slice function that will work even on IE
  27407. * @param data defines the array to slice
  27408. * @param start defines the start of the data (optional)
  27409. * @param end defines the end of the data (optional)
  27410. * @returns the new sliced array
  27411. */
  27412. static Slice<T>(data: T, start?: number, end?: number): T;
  27413. static SetImmediate(action: () => void): void;
  27414. static IsExponentOfTwo(value: number): boolean;
  27415. private static _tmpFloatArray;
  27416. /**
  27417. * Returns the nearest 32-bit single precision float representation of a Number
  27418. * @param value A Number. If the parameter is of a different type, it will get converted
  27419. * to a number or to NaN if it cannot be converted
  27420. * @returns number
  27421. */
  27422. static FloatRound(value: number): number;
  27423. /**
  27424. * Find the next highest power of two.
  27425. * @param x Number to start search from.
  27426. * @return Next highest power of two.
  27427. */
  27428. static CeilingPOT(x: number): number;
  27429. /**
  27430. * Find the next lowest power of two.
  27431. * @param x Number to start search from.
  27432. * @return Next lowest power of two.
  27433. */
  27434. static FloorPOT(x: number): number;
  27435. /**
  27436. * Find the nearest power of two.
  27437. * @param x Number to start search from.
  27438. * @return Next nearest power of two.
  27439. */
  27440. static NearestPOT(x: number): number;
  27441. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  27442. static GetFilename(path: string): string;
  27443. /**
  27444. * Extracts the "folder" part of a path (everything before the filename).
  27445. * @param uri The URI to extract the info from
  27446. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  27447. * @returns The "folder" part of the path
  27448. */
  27449. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  27450. static GetDOMTextContent(element: HTMLElement): string;
  27451. static ToDegrees(angle: number): number;
  27452. static ToRadians(angle: number): number;
  27453. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  27454. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  27455. minimum: Vector3;
  27456. maximum: Vector3;
  27457. };
  27458. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  27459. minimum: Vector3;
  27460. maximum: Vector3;
  27461. };
  27462. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  27463. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  27464. minimum: Vector2;
  27465. maximum: Vector2;
  27466. };
  27467. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  27468. static GetPointerPrefix(): string;
  27469. /**
  27470. * @param func - the function to be called
  27471. * @param requester - the object that will request the next frame. Falls back to window.
  27472. */
  27473. static QueueNewFrame(func: () => void, requester?: any): number;
  27474. static RequestFullscreen(element: HTMLElement): void;
  27475. static ExitFullscreen(): void;
  27476. static SetCorsBehavior(url: string | string[], element: {
  27477. crossOrigin: string | null;
  27478. }): void;
  27479. static CleanUrl(url: string): string;
  27480. static PreprocessUrl: (url: string) => string;
  27481. /**
  27482. * Loads an image as an HTMLImageElement.
  27483. * @param input url string, ArrayBuffer, or Blob to load
  27484. * @param onLoad callback called when the image successfully loads
  27485. * @param onError callback called when the image fails to load
  27486. * @param database database for caching
  27487. * @returns the HTMLImageElement of the loaded image
  27488. */
  27489. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  27490. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, database?: Database, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  27491. /**
  27492. * Load a script (identified by an url). When the url returns, the
  27493. * content of this file is added into a new script element, attached to the DOM (body element)
  27494. */
  27495. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  27496. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  27497. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  27498. static FileAsURL(content: string): string;
  27499. static Format(value: number, decimals?: number): string;
  27500. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  27501. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  27502. static IsEmpty(obj: any): boolean;
  27503. static RegisterTopRootEvents(events: {
  27504. name: string;
  27505. handler: Nullable<(e: FocusEvent) => any>;
  27506. }[]): void;
  27507. static UnregisterTopRootEvents(events: {
  27508. name: string;
  27509. handler: Nullable<(e: FocusEvent) => any>;
  27510. }[]): void;
  27511. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  27512. /**
  27513. * Converts the canvas data to blob.
  27514. * This acts as a polyfill for browsers not supporting the to blob function.
  27515. * @param canvas Defines the canvas to extract the data from
  27516. * @param successCallback Defines the callback triggered once the data are available
  27517. * @param mimeType Defines the mime type of the result
  27518. */
  27519. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  27520. /**
  27521. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  27522. * @param successCallback Defines the callback triggered once the data are available
  27523. * @param mimeType Defines the mime type of the result
  27524. * @param fileName The filename to download. If present, the result will automatically be downloaded
  27525. */
  27526. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  27527. /**
  27528. * Downloads a blob in the browser
  27529. * @param blob defines the blob to download
  27530. * @param fileName defines the name of the downloaded file
  27531. */
  27532. static Download(blob: Blob, fileName: string): void;
  27533. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  27534. /**
  27535. * Generates an image screenshot from the specified camera.
  27536. *
  27537. * @param engine The engine to use for rendering
  27538. * @param camera The camera to use for rendering
  27539. * @param size This parameter can be set to a single number or to an object with the
  27540. * following (optional) properties: precision, width, height. If a single number is passed,
  27541. * it will be used for both width and height. If an object is passed, the screenshot size
  27542. * will be derived from the parameters. The precision property is a multiplier allowing
  27543. * rendering at a higher or lower resolution.
  27544. * @param successCallback The callback receives a single parameter which contains the
  27545. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  27546. * src parameter of an <img> to display it.
  27547. * @param mimeType The MIME type of the screenshot image (default: image/png).
  27548. * Check your browser for supported MIME types.
  27549. * @param samples Texture samples (default: 1)
  27550. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  27551. * @param fileName A name for for the downloaded file.
  27552. * @constructor
  27553. */
  27554. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  27555. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  27556. /**
  27557. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27558. * Be aware Math.random() could cause collisions, but:
  27559. * "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"
  27560. */
  27561. static RandomId(): string;
  27562. /**
  27563. * Test if the given uri is a base64 string.
  27564. * @param uri The uri to test
  27565. * @return True if the uri is a base64 string or false otherwise.
  27566. */
  27567. static IsBase64(uri: string): boolean;
  27568. /**
  27569. * Decode the given base64 uri.
  27570. * @param uri The uri to decode
  27571. * @return The decoded base64 data.
  27572. */
  27573. static DecodeBase64(uri: string): ArrayBuffer;
  27574. private static _NoneLogLevel;
  27575. private static _MessageLogLevel;
  27576. private static _WarningLogLevel;
  27577. private static _ErrorLogLevel;
  27578. private static _LogCache;
  27579. static errorsCount: number;
  27580. static OnNewCacheEntry: (entry: string) => void;
  27581. static readonly NoneLogLevel: number;
  27582. static readonly MessageLogLevel: number;
  27583. static readonly WarningLogLevel: number;
  27584. static readonly ErrorLogLevel: number;
  27585. static readonly AllLogLevel: number;
  27586. private static _AddLogEntry;
  27587. private static _FormatMessage;
  27588. private static _LogDisabled;
  27589. private static _LogEnabled;
  27590. private static _WarnDisabled;
  27591. private static _WarnEnabled;
  27592. private static _ErrorDisabled;
  27593. private static _ErrorEnabled;
  27594. static Log: (message: string) => void;
  27595. static Warn: (message: string) => void;
  27596. static Error: (message: string) => void;
  27597. static readonly LogCache: string;
  27598. static ClearLogCache(): void;
  27599. static LogLevels: number;
  27600. static IsWindowObjectExist(): boolean;
  27601. private static _PerformanceNoneLogLevel;
  27602. private static _PerformanceUserMarkLogLevel;
  27603. private static _PerformanceConsoleLogLevel;
  27604. private static _performance;
  27605. static readonly PerformanceNoneLogLevel: number;
  27606. static readonly PerformanceUserMarkLogLevel: number;
  27607. static readonly PerformanceConsoleLogLevel: number;
  27608. static PerformanceLogLevel: number;
  27609. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  27610. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  27611. static _StartUserMark(counterName: string, condition?: boolean): void;
  27612. static _EndUserMark(counterName: string, condition?: boolean): void;
  27613. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  27614. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  27615. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  27616. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  27617. static readonly Now: number;
  27618. /**
  27619. * This method will return the name of the class used to create the instance of the given object.
  27620. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  27621. * @param object the object to get the class name from
  27622. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  27623. */
  27624. static GetClassName(object: any, isType?: boolean): string;
  27625. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  27626. /**
  27627. * This method will return the name of the full name of the class, including its owning module (if any).
  27628. * 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).
  27629. * @param object the object to get the class name from
  27630. * @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.
  27631. */
  27632. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  27633. /**
  27634. * This method can be used with hashCodeFromStream when your input is an array of values that are either: number, string, boolean or custom type implementing the getHashCode():number method.
  27635. * @param array
  27636. */
  27637. static arrayOrStringFeeder(array: any): (i: number) => number;
  27638. /**
  27639. * Compute the hashCode of a stream of number
  27640. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  27641. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  27642. * @return the hash code computed
  27643. */
  27644. static hashCodeFromStream(feeder: (index: number) => number): number;
  27645. /**
  27646. * Returns a promise that resolves after the given amount of time.
  27647. * @param delay Number of milliseconds to delay
  27648. * @returns Promise that resolves after the given amount of time
  27649. */
  27650. static DelayAsync(delay: number): Promise<void>;
  27651. /**
  27652. * Gets the current gradient from an array of IValueGradient
  27653. * @param ratio defines the current ratio to get
  27654. * @param gradients defines the array of IValueGradient
  27655. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  27656. */
  27657. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  27658. }
  27659. /**
  27660. * This class is used to track a performance counter which is number based.
  27661. * The user has access to many properties which give statistics of different nature
  27662. *
  27663. * The implementer can track two kinds of Performance Counter: time and count
  27664. * 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.
  27665. * 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.
  27666. */
  27667. class PerfCounter {
  27668. static Enabled: boolean;
  27669. /**
  27670. * Returns the smallest value ever
  27671. */
  27672. readonly min: number;
  27673. /**
  27674. * Returns the biggest value ever
  27675. */
  27676. readonly max: number;
  27677. /**
  27678. * Returns the average value since the performance counter is running
  27679. */
  27680. readonly average: number;
  27681. /**
  27682. * Returns the average value of the last second the counter was monitored
  27683. */
  27684. readonly lastSecAverage: number;
  27685. /**
  27686. * Returns the current value
  27687. */
  27688. readonly current: number;
  27689. readonly total: number;
  27690. readonly count: number;
  27691. constructor();
  27692. /**
  27693. * Call this method to start monitoring a new frame.
  27694. * 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.
  27695. */
  27696. fetchNewFrame(): void;
  27697. /**
  27698. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  27699. * @param newCount the count value to add to the monitored count
  27700. * @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.
  27701. */
  27702. addCount(newCount: number, fetchResult: boolean): void;
  27703. /**
  27704. * Start monitoring this performance counter
  27705. */
  27706. beginMonitoring(): void;
  27707. /**
  27708. * Compute the time lapsed since the previous beginMonitoring() call.
  27709. * @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
  27710. */
  27711. endMonitoring(newFrame?: boolean): void;
  27712. private _fetchResult;
  27713. private _startMonitoringTime;
  27714. private _min;
  27715. private _max;
  27716. private _average;
  27717. private _current;
  27718. private _totalValueCount;
  27719. private _totalAccumulated;
  27720. private _lastSecAverage;
  27721. private _lastSecAccumulated;
  27722. private _lastSecTime;
  27723. private _lastSecValueCount;
  27724. }
  27725. /**
  27726. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  27727. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  27728. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  27729. * @param name The name of the class, case should be preserved
  27730. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  27731. */
  27732. function className(name: string, module?: string): (target: Object) => void;
  27733. /**
  27734. * An implementation of a loop for asynchronous functions.
  27735. */
  27736. class AsyncLoop {
  27737. iterations: number;
  27738. private _fn;
  27739. private _successCallback;
  27740. index: number;
  27741. private _done;
  27742. /**
  27743. * Constroctor.
  27744. * @param iterations the number of iterations.
  27745. * @param _fn the function to run each iteration
  27746. * @param _successCallback the callback that will be called upon succesful execution
  27747. * @param offset starting offset.
  27748. */
  27749. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  27750. /**
  27751. * Execute the next iteration. Must be called after the last iteration was finished.
  27752. */
  27753. executeNext(): void;
  27754. /**
  27755. * Break the loop and run the success callback.
  27756. */
  27757. breakLoop(): void;
  27758. /**
  27759. * Helper function
  27760. */
  27761. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  27762. /**
  27763. * A for-loop that will run a given number of iterations synchronous and the rest async.
  27764. * @param iterations total number of iterations
  27765. * @param syncedIterations number of synchronous iterations in each async iteration.
  27766. * @param fn the function to call each iteration.
  27767. * @param callback a success call back that will be called when iterating stops.
  27768. * @param breakFunction a break condition (optional)
  27769. * @param timeout timeout settings for the setTimeout function. default - 0.
  27770. * @constructor
  27771. */
  27772. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  27773. }
  27774. }
  27775. interface HTMLCanvasElement {
  27776. /** Track wether a record is in progress */
  27777. isRecording: boolean;
  27778. /** Capture Stream method defined by some browsers */
  27779. captureStream(fps?: number): MediaStream;
  27780. }
  27781. interface MediaRecorder {
  27782. /** Starts recording */
  27783. start(timeSlice: number): void;
  27784. /** Stops recording */
  27785. stop(): void;
  27786. /** Event raised when an error arised. */
  27787. onerror: (event: ErrorEvent) => void;
  27788. /** Event raised when the recording stops. */
  27789. onstop: (event: Event) => void;
  27790. /** Event raised when a new chunk of data is available and should be tracked. */
  27791. ondataavailable: (event: Event) => void;
  27792. }
  27793. interface MediaRecorderOptions {
  27794. /** The mime type you want to use as the recording container for the new MediaRecorder */
  27795. mimeType?: string;
  27796. /** The chosen bitrate for the audio component of the media. */
  27797. audioBitsPerSecond?: number;
  27798. /** The chosen bitrate for the video component of the media. */
  27799. videoBitsPerSecond?: number;
  27800. /** 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. */
  27801. bitsPerSecond?: number;
  27802. }
  27803. interface MediaRecorderConstructor {
  27804. /**
  27805. * A reference to the prototype.
  27806. */
  27807. readonly prototype: MediaRecorder;
  27808. /**
  27809. * Creates a new MediaRecorder.
  27810. * @param stream Defines the stream to record.
  27811. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  27812. */
  27813. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  27814. }
  27815. /**
  27816. * MediaRecoreder object available in some browsers.
  27817. */
  27818. declare var MediaRecorder: MediaRecorderConstructor;
  27819. declare module BABYLON {
  27820. /**
  27821. * This represents the different options avilable for the video capture.
  27822. */
  27823. interface VideoRecorderOptions {
  27824. /** Defines the mime type of the video */
  27825. mimeType: string;
  27826. /** Defines the video the video should be recorded at */
  27827. fps: number;
  27828. /** Defines the chunk size for the recording data */
  27829. recordChunckSize: number;
  27830. }
  27831. /**
  27832. * This can helps recording videos from BabylonJS.
  27833. * This is based on the available WebRTC functionalities of the browser.
  27834. *
  27835. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  27836. */
  27837. class VideoRecorder {
  27838. private static readonly _defaultOptions;
  27839. /**
  27840. * Returns wehther or not the VideoRecorder is available in your browser.
  27841. * @param engine Defines the Babylon Engine to check the support for
  27842. * @returns true if supported otherwise false
  27843. */
  27844. static IsSupported(engine: Engine): boolean;
  27845. private readonly _options;
  27846. private _canvas;
  27847. private _mediaRecorder;
  27848. private _recordedChunks;
  27849. private _fileName;
  27850. private _resolve;
  27851. private _reject;
  27852. /**
  27853. * True wether a recording is already in progress.
  27854. */
  27855. readonly isRecording: boolean;
  27856. /**
  27857. * Create a new VideoCapture object which can help converting what you see in Babylon to
  27858. * a video file.
  27859. * @param engine Defines the BabylonJS Engine you wish to record
  27860. * @param options Defines options that can be used to customized the capture
  27861. */
  27862. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  27863. /**
  27864. * Stops the current recording before the default capture timeout passed in the startRecording
  27865. * functions.
  27866. */
  27867. stopRecording(): void;
  27868. /**
  27869. * Starts recording the canvas for a max duration specified in parameters.
  27870. * @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.
  27871. * @param maxDuration Defines the maximum recording time in seconds.
  27872. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  27873. * @return a promise callback at the end of the recording with the video data in Blob.
  27874. */
  27875. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  27876. /**
  27877. * Releases internal resources used during the recording.
  27878. */
  27879. dispose(): void;
  27880. private _handleDataAvailable;
  27881. private _handleError;
  27882. private _handleStop;
  27883. }
  27884. }
  27885. declare module BABYLON {
  27886. /**
  27887. * Defines the potential axis of a Joystick
  27888. */
  27889. enum JoystickAxis {
  27890. /** X axis */
  27891. X = 0,
  27892. /** Y axis */
  27893. Y = 1,
  27894. /** Z axis */
  27895. Z = 2
  27896. }
  27897. /**
  27898. * Class used to define virtual joystick (used in touch mode)
  27899. */
  27900. class VirtualJoystick {
  27901. /**
  27902. * Gets or sets a boolean indicating that left and right values must be inverted
  27903. */
  27904. reverseLeftRight: boolean;
  27905. /**
  27906. * Gets or sets a boolean indicating that up and down values must be inverted
  27907. */
  27908. reverseUpDown: boolean;
  27909. /**
  27910. * Gets the offset value for the position (ie. the change of the position value)
  27911. */
  27912. deltaPosition: Vector3;
  27913. /**
  27914. * Gets a boolean indicating if the virtual joystick was pressed
  27915. */
  27916. pressed: boolean;
  27917. private static _globalJoystickIndex;
  27918. private static vjCanvas;
  27919. private static vjCanvasContext;
  27920. private static vjCanvasWidth;
  27921. private static vjCanvasHeight;
  27922. private static halfWidth;
  27923. private _action;
  27924. private _axisTargetedByLeftAndRight;
  27925. private _axisTargetedByUpAndDown;
  27926. private _joystickSensibility;
  27927. private _inversedSensibility;
  27928. private _joystickPointerID;
  27929. private _joystickColor;
  27930. private _joystickPointerPos;
  27931. private _joystickPreviousPointerPos;
  27932. private _joystickPointerStartPos;
  27933. private _deltaJoystickVector;
  27934. private _leftJoystick;
  27935. private _touches;
  27936. private _onPointerDownHandlerRef;
  27937. private _onPointerMoveHandlerRef;
  27938. private _onPointerUpHandlerRef;
  27939. private _onResize;
  27940. /**
  27941. * Creates a new virtual joystick
  27942. * @param leftJoystick defines that the joystick is for left hand (false by default)
  27943. */
  27944. constructor(leftJoystick?: boolean);
  27945. /**
  27946. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  27947. * @param newJoystickSensibility defines the new sensibility
  27948. */
  27949. setJoystickSensibility(newJoystickSensibility: number): void;
  27950. private _onPointerDown;
  27951. private _onPointerMove;
  27952. private _onPointerUp;
  27953. /**
  27954. * Change the color of the virtual joystick
  27955. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  27956. */
  27957. setJoystickColor(newColor: string): void;
  27958. /**
  27959. * Defines a callback to call when the joystick is touched
  27960. * @param action defines the callback
  27961. */
  27962. setActionOnTouch(action: () => any): void;
  27963. /**
  27964. * Defines which axis you'd like to control for left & right
  27965. * @param axis defines the axis to use
  27966. */
  27967. setAxisForLeftRight(axis: JoystickAxis): void;
  27968. /**
  27969. * Defines which axis you'd like to control for up & down
  27970. * @param axis defines the axis to use
  27971. */
  27972. setAxisForUpDown(axis: JoystickAxis): void;
  27973. private _drawVirtualJoystick;
  27974. /**
  27975. * Release internal HTML canvas
  27976. */
  27977. releaseCanvas(): void;
  27978. }
  27979. }
  27980. declare module BABYLON {
  27981. /**
  27982. * Helper class to push actions to a pool of workers.
  27983. */
  27984. class WorkerPool implements IDisposable {
  27985. private _workerInfos;
  27986. private _pendingActions;
  27987. /**
  27988. * Constructor
  27989. * @param workers Array of workers to use for actions
  27990. */
  27991. constructor(workers: Array<Worker>);
  27992. /**
  27993. * Terminates all workers and clears any pending actions.
  27994. */
  27995. dispose(): void;
  27996. /**
  27997. * Pushes an action to the worker pool. If all the workers are active, the action will be
  27998. * pended until a worker has completed its action.
  27999. * @param action The action to perform. Call onComplete when the action is complete.
  28000. */
  28001. push(action: (worker: Worker, onComplete: () => void) => void): void;
  28002. private _execute;
  28003. }
  28004. }
  28005. declare module BABYLON {
  28006. class Scalar {
  28007. /**
  28008. * Two pi constants convenient for computation.
  28009. */
  28010. static TwoPi: number;
  28011. /**
  28012. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  28013. */
  28014. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  28015. /**
  28016. * Returns a string : the upper case translation of the number i to hexadecimal.
  28017. */
  28018. static ToHex(i: number): string;
  28019. /**
  28020. * Returns -1 if value is negative and +1 is value is positive.
  28021. * Returns the value itself if it's equal to zero.
  28022. */
  28023. static Sign(value: number): number;
  28024. /**
  28025. * Returns the value itself if it's between min and max.
  28026. * Returns min if the value is lower than min.
  28027. * Returns max if the value is greater than max.
  28028. */
  28029. static Clamp(value: number, min?: number, max?: number): number;
  28030. /**
  28031. * Returns the log2 of value.
  28032. */
  28033. static Log2(value: number): number;
  28034. /**
  28035. * Loops the value, so that it is never larger than length and never smaller than 0.
  28036. *
  28037. * This is similar to the modulo operator but it works with floating point numbers.
  28038. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  28039. * With t = 5 and length = 2.5, the result would be 0.0.
  28040. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  28041. */
  28042. static Repeat(value: number, length: number): number;
  28043. /**
  28044. * Normalize the value between 0.0 and 1.0 using min and max values
  28045. */
  28046. static Normalize(value: number, min: number, max: number): number;
  28047. /**
  28048. * Denormalize the value from 0.0 and 1.0 using min and max values
  28049. */
  28050. static Denormalize(normalized: number, min: number, max: number): number;
  28051. /**
  28052. * Calculates the shortest difference between two given angles given in degrees.
  28053. */
  28054. static DeltaAngle(current: number, target: number): number;
  28055. /**
  28056. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  28057. *
  28058. * The returned value will move back and forth between 0 and length
  28059. */
  28060. static PingPong(tx: number, length: number): number;
  28061. /**
  28062. * Interpolates between min and max with smoothing at the limits.
  28063. *
  28064. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  28065. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  28066. */
  28067. static SmoothStep(from: number, to: number, tx: number): number;
  28068. /**
  28069. * Moves a value current towards target.
  28070. *
  28071. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  28072. * Negative values of maxDelta pushes the value away from target.
  28073. */
  28074. static MoveTowards(current: number, target: number, maxDelta: number): number;
  28075. /**
  28076. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  28077. *
  28078. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  28079. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  28080. */
  28081. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  28082. /**
  28083. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  28084. */
  28085. static Lerp(start: number, end: number, amount: number): number;
  28086. /**
  28087. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  28088. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  28089. */
  28090. static LerpAngle(start: number, end: number, amount: number): number;
  28091. /**
  28092. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  28093. */
  28094. static InverseLerp(a: number, b: number, value: number): number;
  28095. /**
  28096. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  28097. */
  28098. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  28099. /**
  28100. * Returns a random float number between and min and max values
  28101. */
  28102. static RandomRange(min: number, max: number): number;
  28103. /**
  28104. * This function returns percentage of a number in a given range.
  28105. *
  28106. * RangeToPercent(40,20,60) will return 0.5 (50%)
  28107. * RangeToPercent(34,0,100) will return 0.34 (34%)
  28108. */
  28109. static RangeToPercent(number: number, min: number, max: number): number;
  28110. /**
  28111. * This function returns number that corresponds to the percentage in a given range.
  28112. *
  28113. * PercentToRange(0.34,0,100) will return 34.
  28114. */
  28115. static PercentToRange(percent: number, min: number, max: number): number;
  28116. /**
  28117. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  28118. * @param angle The angle to normalize in radian.
  28119. * @return The converted angle.
  28120. */
  28121. static NormalizeRadians(angle: number): number;
  28122. }
  28123. }
  28124. declare module BABYLON {
  28125. const ToGammaSpace: number;
  28126. const ToLinearSpace = 2.2;
  28127. const Epsilon = 0.001;
  28128. /**
  28129. * Class used to hold a RBG color
  28130. */
  28131. class Color3 {
  28132. /**
  28133. * Defines the red component (between 0 and 1, default is 0)
  28134. */
  28135. r: number;
  28136. /**
  28137. * Defines the green component (between 0 and 1, default is 0)
  28138. */
  28139. g: number;
  28140. /**
  28141. * Defines the blue component (between 0 and 1, default is 0)
  28142. */
  28143. b: number;
  28144. /**
  28145. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  28146. * @param r defines the red component (between 0 and 1, default is 0)
  28147. * @param g defines the green component (between 0 and 1, default is 0)
  28148. * @param b defines the blue component (between 0 and 1, default is 0)
  28149. */
  28150. constructor(
  28151. /**
  28152. * Defines the red component (between 0 and 1, default is 0)
  28153. */
  28154. r?: number,
  28155. /**
  28156. * Defines the green component (between 0 and 1, default is 0)
  28157. */
  28158. g?: number,
  28159. /**
  28160. * Defines the blue component (between 0 and 1, default is 0)
  28161. */
  28162. b?: number);
  28163. /**
  28164. * Creates a string with the Color3 current values
  28165. * @returns the string representation of the Color3 object
  28166. */
  28167. toString(): string;
  28168. /**
  28169. * Returns the string "Color3"
  28170. * @returns "Color3"
  28171. */
  28172. getClassName(): string;
  28173. /**
  28174. * Compute the Color3 hash code
  28175. * @returns an unique number that can be used to hash Color3 objects
  28176. */
  28177. getHashCode(): number;
  28178. /**
  28179. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  28180. * @param array defines the array where to store the r,g,b components
  28181. * @param index defines an optional index in the target array to define where to start storing values
  28182. * @returns the current Color3 object
  28183. */
  28184. toArray(array: FloatArray, index?: number): Color3;
  28185. /**
  28186. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  28187. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  28188. * @returns a new {BABYLON.Color4} object
  28189. */
  28190. toColor4(alpha?: number): Color4;
  28191. /**
  28192. * Returns a new array populated with 3 numeric elements : red, green and blue values
  28193. * @returns the new array
  28194. */
  28195. asArray(): number[];
  28196. /**
  28197. * Returns the luminance value
  28198. * @returns a float value
  28199. */
  28200. toLuminance(): number;
  28201. /**
  28202. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  28203. * @param otherColor defines the second operand
  28204. * @returns the new Color3 object
  28205. */
  28206. multiply(otherColor: Color3): Color3;
  28207. /**
  28208. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  28209. * @param otherColor defines the second operand
  28210. * @param result defines the Color3 object where to store the result
  28211. * @returns the current Color3
  28212. */
  28213. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  28214. /**
  28215. * Determines equality between Color3 objects
  28216. * @param otherColor defines the second operand
  28217. * @returns true if the rgb values are equal to the given ones
  28218. */
  28219. equals(otherColor: Color3): boolean;
  28220. /**
  28221. * Determines equality between the current Color3 object and a set of r,b,g values
  28222. * @param r defines the red component to check
  28223. * @param g defines the green component to check
  28224. * @param b defines the blue component to check
  28225. * @returns true if the rgb values are equal to the given ones
  28226. */
  28227. equalsFloats(r: number, g: number, b: number): boolean;
  28228. /**
  28229. * Multiplies in place each rgb value by scale
  28230. * @param scale defines the scaling factor
  28231. * @returns the updated Color3
  28232. */
  28233. scale(scale: number): Color3;
  28234. /**
  28235. * Multiplies the rgb values by scale and stores the result into "result"
  28236. * @param scale defines the scaling factor
  28237. * @param result defines the Color3 object where to store the result
  28238. * @returns the unmodified current Color3
  28239. */
  28240. scaleToRef(scale: number, result: Color3): Color3;
  28241. /**
  28242. * Scale the current Color3 values by a factor and add the result to a given Color3
  28243. * @param scale defines the scale factor
  28244. * @param result defines color to store the result into
  28245. * @returns the unmodified current Color3
  28246. */
  28247. scaleAndAddToRef(scale: number, result: Color3): Color3;
  28248. /**
  28249. * Clamps the rgb values by the min and max values and stores the result into "result"
  28250. * @param min defines minimum clamping value (default is 0)
  28251. * @param max defines maximum clamping value (default is 1)
  28252. * @param result defines color to store the result into
  28253. * @returns the original Color3
  28254. */
  28255. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  28256. /**
  28257. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  28258. * @param otherColor defines the second operand
  28259. * @returns the new Color3
  28260. */
  28261. add(otherColor: Color3): Color3;
  28262. /**
  28263. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  28264. * @param otherColor defines the second operand
  28265. * @param result defines Color3 object to store the result into
  28266. * @returns the unmodified current Color3
  28267. */
  28268. addToRef(otherColor: Color3, result: Color3): Color3;
  28269. /**
  28270. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  28271. * @param otherColor defines the second operand
  28272. * @returns the new Color3
  28273. */
  28274. subtract(otherColor: Color3): Color3;
  28275. /**
  28276. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  28277. * @param otherColor defines the second operand
  28278. * @param result defines Color3 object to store the result into
  28279. * @returns the unmodified current Color3
  28280. */
  28281. subtractToRef(otherColor: Color3, result: Color3): Color3;
  28282. /**
  28283. * Copy the current object
  28284. * @returns a new Color3 copied the current one
  28285. */
  28286. clone(): Color3;
  28287. /**
  28288. * Copies the rgb values from the source in the current Color3
  28289. * @param source defines the source Color3 object
  28290. * @returns the updated Color3 object
  28291. */
  28292. copyFrom(source: Color3): Color3;
  28293. /**
  28294. * Updates the Color3 rgb values from the given floats
  28295. * @param r defines the red component to read from
  28296. * @param g defines the green component to read from
  28297. * @param b defines the blue component to read from
  28298. * @returns the current Color3 object
  28299. */
  28300. copyFromFloats(r: number, g: number, b: number): Color3;
  28301. /**
  28302. * Updates the Color3 rgb values from the given floats
  28303. * @param r defines the red component to read from
  28304. * @param g defines the green component to read from
  28305. * @param b defines the blue component to read from
  28306. * @returns the current Color3 object
  28307. */
  28308. set(r: number, g: number, b: number): Color3;
  28309. /**
  28310. * Compute the Color3 hexadecimal code as a string
  28311. * @returns a string containing the hexadecimal representation of the Color3 object
  28312. */
  28313. toHexString(): string;
  28314. /**
  28315. * Computes a new Color3 converted from the current one to linear space
  28316. * @returns a new Color3 object
  28317. */
  28318. toLinearSpace(): Color3;
  28319. /**
  28320. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  28321. * @param convertedColor defines the Color3 object where to store the linear space version
  28322. * @returns the unmodified Color3
  28323. */
  28324. toLinearSpaceToRef(convertedColor: Color3): Color3;
  28325. /**
  28326. * Computes a new Color3 converted from the current one to gamma space
  28327. * @returns a new Color3 object
  28328. */
  28329. toGammaSpace(): Color3;
  28330. /**
  28331. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  28332. * @param convertedColor defines the Color3 object where to store the gamma space version
  28333. * @returns the unmodified Color3
  28334. */
  28335. toGammaSpaceToRef(convertedColor: Color3): Color3;
  28336. /**
  28337. * Creates a new Color3 from the string containing valid hexadecimal values
  28338. * @param hex defines a string containing valid hexadecimal values
  28339. * @returns a new Color3 object
  28340. */
  28341. static FromHexString(hex: string): Color3;
  28342. /**
  28343. * Creates a new Vector3 from the starting index of the given array
  28344. * @param array defines the source array
  28345. * @param offset defines an offset in the source array
  28346. * @returns a new Color3 object
  28347. */
  28348. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  28349. /**
  28350. * Creates a new Color3 from integer values (< 256)
  28351. * @param r defines the red component to read from (value between 0 and 255)
  28352. * @param g defines the green component to read from (value between 0 and 255)
  28353. * @param b defines the blue component to read from (value between 0 and 255)
  28354. * @returns a new Color3 object
  28355. */
  28356. static FromInts(r: number, g: number, b: number): Color3;
  28357. /**
  28358. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  28359. * @param start defines the start Color3 value
  28360. * @param end defines the end Color3 value
  28361. * @param amount defines the gradient value between start and end
  28362. * @returns a new Color3 object
  28363. */
  28364. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  28365. /**
  28366. * Returns a Color3 value containing a red color
  28367. * @returns a new Color3 object
  28368. */
  28369. static Red(): Color3;
  28370. /**
  28371. * Returns a Color3 value containing a green color
  28372. * @returns a new Color3 object
  28373. */
  28374. static Green(): Color3;
  28375. /**
  28376. * Returns a Color3 value containing a blue color
  28377. * @returns a new Color3 object
  28378. */
  28379. static Blue(): Color3;
  28380. /**
  28381. * Returns a Color3 value containing a black color
  28382. * @returns a new Color3 object
  28383. */
  28384. static Black(): Color3;
  28385. /**
  28386. * Returns a Color3 value containing a white color
  28387. * @returns a new Color3 object
  28388. */
  28389. static White(): Color3;
  28390. /**
  28391. * Returns a Color3 value containing a purple color
  28392. * @returns a new Color3 object
  28393. */
  28394. static Purple(): Color3;
  28395. /**
  28396. * Returns a Color3 value containing a magenta color
  28397. * @returns a new Color3 object
  28398. */
  28399. static Magenta(): Color3;
  28400. /**
  28401. * Returns a Color3 value containing a yellow color
  28402. * @returns a new Color3 object
  28403. */
  28404. static Yellow(): Color3;
  28405. /**
  28406. * Returns a Color3 value containing a gray color
  28407. * @returns a new Color3 object
  28408. */
  28409. static Gray(): Color3;
  28410. /**
  28411. * Returns a Color3 value containing a teal color
  28412. * @returns a new Color3 object
  28413. */
  28414. static Teal(): Color3;
  28415. /**
  28416. * Returns a Color3 value containing a random color
  28417. * @returns a new Color3 object
  28418. */
  28419. static Random(): Color3;
  28420. }
  28421. /**
  28422. * Class used to hold a RBGA color
  28423. */
  28424. class Color4 {
  28425. /**
  28426. * Defines the red component (between 0 and 1, default is 0)
  28427. */
  28428. r: number;
  28429. /**
  28430. * Defines the green component (between 0 and 1, default is 0)
  28431. */
  28432. g: number;
  28433. /**
  28434. * Defines the blue component (between 0 and 1, default is 0)
  28435. */
  28436. b: number;
  28437. /**
  28438. * Defines the alpha component (between 0 and 1, default is 1)
  28439. */
  28440. a: number;
  28441. /**
  28442. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  28443. * @param r defines the red component (between 0 and 1, default is 0)
  28444. * @param g defines the green component (between 0 and 1, default is 0)
  28445. * @param b defines the blue component (between 0 and 1, default is 0)
  28446. * @param a defines the alpha component (between 0 and 1, default is 1)
  28447. */
  28448. constructor(
  28449. /**
  28450. * Defines the red component (between 0 and 1, default is 0)
  28451. */
  28452. r?: number,
  28453. /**
  28454. * Defines the green component (between 0 and 1, default is 0)
  28455. */
  28456. g?: number,
  28457. /**
  28458. * Defines the blue component (between 0 and 1, default is 0)
  28459. */
  28460. b?: number,
  28461. /**
  28462. * Defines the alpha component (between 0 and 1, default is 1)
  28463. */
  28464. a?: number);
  28465. /**
  28466. * Adds in place the given Color4 values to the current Color4 object
  28467. * @param right defines the second operand
  28468. * @returns the current updated Color4 object
  28469. */
  28470. addInPlace(right: Color4): Color4;
  28471. /**
  28472. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  28473. * @returns the new array
  28474. */
  28475. asArray(): number[];
  28476. /**
  28477. * Stores from the starting index in the given array the Color4 successive values
  28478. * @param array defines the array where to store the r,g,b components
  28479. * @param index defines an optional index in the target array to define where to start storing values
  28480. * @returns the current Color4 object
  28481. */
  28482. toArray(array: number[], index?: number): Color4;
  28483. /**
  28484. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  28485. * @param right defines the second operand
  28486. * @returns a new Color4 object
  28487. */
  28488. add(right: Color4): Color4;
  28489. /**
  28490. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  28491. * @param right defines the second operand
  28492. * @returns a new Color4 object
  28493. */
  28494. subtract(right: Color4): Color4;
  28495. /**
  28496. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  28497. * @param right defines the second operand
  28498. * @param result defines the Color4 object where to store the result
  28499. * @returns the current Color4 object
  28500. */
  28501. subtractToRef(right: Color4, result: Color4): Color4;
  28502. /**
  28503. * Creates a new Color4 with the current Color4 values multiplied by scale
  28504. * @param scale defines the scaling factor to apply
  28505. * @returns a new Color4 object
  28506. */
  28507. scale(scale: number): Color4;
  28508. /**
  28509. * Multiplies the current Color4 values by scale and stores the result in "result"
  28510. * @param scale defines the scaling factor to apply
  28511. * @param result defines the Color4 object where to store the result
  28512. * @returns the current unmodified Color4
  28513. */
  28514. scaleToRef(scale: number, result: Color4): Color4;
  28515. /**
  28516. * Scale the current Color4 values by a factor and add the result to a given Color4
  28517. * @param scale defines the scale factor
  28518. * @param result defines the Color4 object where to store the result
  28519. * @returns the unmodified current Color4
  28520. */
  28521. scaleAndAddToRef(scale: number, result: Color4): Color4;
  28522. /**
  28523. * Clamps the rgb values by the min and max values and stores the result into "result"
  28524. * @param min defines minimum clamping value (default is 0)
  28525. * @param max defines maximum clamping value (default is 1)
  28526. * @param result defines color to store the result into.
  28527. * @returns the cuurent Color4
  28528. */
  28529. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  28530. /**
  28531. * Multipy an Color4 value by another and return a new Color4 object
  28532. * @param color defines the Color4 value to multiply by
  28533. * @returns a new Color4 object
  28534. */
  28535. multiply(color: Color4): Color4;
  28536. /**
  28537. * Multipy a Color4 value by another and push the result in a reference value
  28538. * @param color defines the Color4 value to multiply by
  28539. * @param result defines the Color4 to fill the result in
  28540. * @returns the result Color4
  28541. */
  28542. multiplyToRef(color: Color4, result: Color4): Color4;
  28543. /**
  28544. * Creates a string with the Color4 current values
  28545. * @returns the string representation of the Color4 object
  28546. */
  28547. toString(): string;
  28548. /**
  28549. * Returns the string "Color4"
  28550. * @returns "Color4"
  28551. */
  28552. getClassName(): string;
  28553. /**
  28554. * Compute the Color4 hash code
  28555. * @returns an unique number that can be used to hash Color4 objects
  28556. */
  28557. getHashCode(): number;
  28558. /**
  28559. * Creates a new Color4 copied from the current one
  28560. * @returns a new Color4 object
  28561. */
  28562. clone(): Color4;
  28563. /**
  28564. * Copies the given Color4 values into the current one
  28565. * @param source defines the source Color4 object
  28566. * @returns the current updated Color4 object
  28567. */
  28568. copyFrom(source: Color4): Color4;
  28569. /**
  28570. * Copies the given float values into the current one
  28571. * @param r defines the red component to read from
  28572. * @param g defines the green component to read from
  28573. * @param b defines the blue component to read from
  28574. * @param a defines the alpha component to read from
  28575. * @returns the current updated Color4 object
  28576. */
  28577. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  28578. /**
  28579. * Copies the given float values into the current one
  28580. * @param r defines the red component to read from
  28581. * @param g defines the green component to read from
  28582. * @param b defines the blue component to read from
  28583. * @param a defines the alpha component to read from
  28584. * @returns the current updated Color4 object
  28585. */
  28586. set(r: number, g: number, b: number, a: number): Color4;
  28587. /**
  28588. * Compute the Color4 hexadecimal code as a string
  28589. * @returns a string containing the hexadecimal representation of the Color4 object
  28590. */
  28591. toHexString(): string;
  28592. /**
  28593. * Computes a new Color4 converted from the current one to linear space
  28594. * @returns a new Color4 object
  28595. */
  28596. toLinearSpace(): Color4;
  28597. /**
  28598. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  28599. * @param convertedColor defines the Color4 object where to store the linear space version
  28600. * @returns the unmodified Color4
  28601. */
  28602. toLinearSpaceToRef(convertedColor: Color4): Color4;
  28603. /**
  28604. * Computes a new Color4 converted from the current one to gamma space
  28605. * @returns a new Color4 object
  28606. */
  28607. toGammaSpace(): Color4;
  28608. /**
  28609. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  28610. * @param convertedColor defines the Color4 object where to store the gamma space version
  28611. * @returns the unmodified Color4
  28612. */
  28613. toGammaSpaceToRef(convertedColor: Color4): Color4;
  28614. /**
  28615. * Creates a new Color4 from the string containing valid hexadecimal values
  28616. * @param hex defines a string containing valid hexadecimal values
  28617. * @returns a new Color4 object
  28618. */
  28619. static FromHexString(hex: string): Color4;
  28620. /**
  28621. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  28622. * @param left defines the start value
  28623. * @param right defines the end value
  28624. * @param amount defines the gradient factor
  28625. * @returns a new Color4 object
  28626. */
  28627. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  28628. /**
  28629. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  28630. * @param left defines the start value
  28631. * @param right defines the end value
  28632. * @param amount defines the gradient factor
  28633. * @param result defines the Color4 object where to store data
  28634. */
  28635. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  28636. /**
  28637. * Creates a new Color4 from the starting index element of the given array
  28638. * @param array defines the source array to read from
  28639. * @param offset defines the offset in the source array
  28640. * @returns a new Color4 object
  28641. */
  28642. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  28643. /**
  28644. * Creates a new Color3 from integer values (< 256)
  28645. * @param r defines the red component to read from (value between 0 and 255)
  28646. * @param g defines the green component to read from (value between 0 and 255)
  28647. * @param b defines the blue component to read from (value between 0 and 255)
  28648. * @param a defines the alpha component to read from (value between 0 and 255)
  28649. * @returns a new Color3 object
  28650. */
  28651. static FromInts(r: number, g: number, b: number, a: number): Color4;
  28652. /**
  28653. * Check the content of a given array and convert it to an array containing RGBA data
  28654. * If the original array was already containing count * 4 values then it is returned directly
  28655. * @param colors defines the array to check
  28656. * @param count defines the number of RGBA data to expect
  28657. * @returns an array containing count * 4 values (RGBA)
  28658. */
  28659. static CheckColors4(colors: number[], count: number): number[];
  28660. }
  28661. /**
  28662. * Class representing a vector containing 2 coordinates
  28663. */
  28664. class Vector2 {
  28665. /** defines the first coordinate */
  28666. x: number;
  28667. /** defines the second coordinate */
  28668. y: number;
  28669. /**
  28670. * Creates a new Vector2 from the given x and y coordinates
  28671. * @param x defines the first coordinate
  28672. * @param y defines the second coordinate
  28673. */
  28674. constructor(
  28675. /** defines the first coordinate */
  28676. x?: number,
  28677. /** defines the second coordinate */
  28678. y?: number);
  28679. /**
  28680. * Gets a string with the Vector2 coordinates
  28681. * @returns a string with the Vector2 coordinates
  28682. */
  28683. toString(): string;
  28684. /**
  28685. * Gets class name
  28686. * @returns the string "Vector2"
  28687. */
  28688. getClassName(): string;
  28689. /**
  28690. * Gets current vector hash code
  28691. * @returns the Vector2 hash code as a number
  28692. */
  28693. getHashCode(): number;
  28694. /**
  28695. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  28696. * @param array defines the source array
  28697. * @param index defines the offset in source array
  28698. * @returns the current Vector2
  28699. */
  28700. toArray(array: FloatArray, index?: number): Vector2;
  28701. /**
  28702. * Copy the current vector to an array
  28703. * @returns a new array with 2 elements: the Vector2 coordinates.
  28704. */
  28705. asArray(): number[];
  28706. /**
  28707. * Sets the Vector2 coordinates with the given Vector2 coordinates
  28708. * @param source defines the source Vector2
  28709. * @returns the current updated Vector2
  28710. */
  28711. copyFrom(source: Vector2): Vector2;
  28712. /**
  28713. * Sets the Vector2 coordinates with the given floats
  28714. * @param x defines the first coordinate
  28715. * @param y defines the second coordinate
  28716. * @returns the current updated Vector2
  28717. */
  28718. copyFromFloats(x: number, y: number): Vector2;
  28719. /**
  28720. * Sets the Vector2 coordinates with the given floats
  28721. * @param x defines the first coordinate
  28722. * @param y defines the second coordinate
  28723. * @returns the current updated Vector2
  28724. */
  28725. set(x: number, y: number): Vector2;
  28726. /**
  28727. * Add another vector with the current one
  28728. * @param otherVector defines the other vector
  28729. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  28730. */
  28731. add(otherVector: Vector2): Vector2;
  28732. /**
  28733. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  28734. * @param otherVector defines the other vector
  28735. * @param result defines the target vector
  28736. * @returns the unmodified current Vector2
  28737. */
  28738. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  28739. /**
  28740. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  28741. * @param otherVector defines the other vector
  28742. * @returns the current updated Vector2
  28743. */
  28744. addInPlace(otherVector: Vector2): Vector2;
  28745. /**
  28746. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  28747. * @param otherVector defines the other vector
  28748. * @returns a new Vector2
  28749. */
  28750. addVector3(otherVector: Vector3): Vector2;
  28751. /**
  28752. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  28753. * @param otherVector defines the other vector
  28754. * @returns a new Vector2
  28755. */
  28756. subtract(otherVector: Vector2): Vector2;
  28757. /**
  28758. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  28759. * @param otherVector defines the other vector
  28760. * @param result defines the target vector
  28761. * @returns the unmodified current Vector2
  28762. */
  28763. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  28764. /**
  28765. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  28766. * @param otherVector defines the other vector
  28767. * @returns the current updated Vector2
  28768. */
  28769. subtractInPlace(otherVector: Vector2): Vector2;
  28770. /**
  28771. * Multiplies in place the current Vector2 coordinates by the given ones
  28772. * @param otherVector defines the other vector
  28773. * @returns the current updated Vector2
  28774. */
  28775. multiplyInPlace(otherVector: Vector2): Vector2;
  28776. /**
  28777. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  28778. * @param otherVector defines the other vector
  28779. * @returns a new Vector2
  28780. */
  28781. multiply(otherVector: Vector2): Vector2;
  28782. /**
  28783. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  28784. * @param otherVector defines the other vector
  28785. * @param result defines the target vector
  28786. * @returns the unmodified current Vector2
  28787. */
  28788. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  28789. /**
  28790. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  28791. * @param x defines the first coordinate
  28792. * @param y defines the second coordinate
  28793. * @returns a new Vector2
  28794. */
  28795. multiplyByFloats(x: number, y: number): Vector2;
  28796. /**
  28797. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  28798. * @param otherVector defines the other vector
  28799. * @returns a new Vector2
  28800. */
  28801. divide(otherVector: Vector2): Vector2;
  28802. /**
  28803. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  28804. * @param otherVector defines the other vector
  28805. * @param result defines the target vector
  28806. * @returns the unmodified current Vector2
  28807. */
  28808. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  28809. /**
  28810. * Divides the current Vector2 coordinates by the given ones
  28811. * @param otherVector defines the other vector
  28812. * @returns the current updated Vector2
  28813. */
  28814. divideInPlace(otherVector: Vector2): Vector2;
  28815. /**
  28816. * Gets a new Vector2 with current Vector2 negated coordinates
  28817. * @returns a new Vector2
  28818. */
  28819. negate(): Vector2;
  28820. /**
  28821. * Multiply the Vector2 coordinates by scale
  28822. * @param scale defines the scaling factor
  28823. * @returns the current updated Vector2
  28824. */
  28825. scaleInPlace(scale: number): Vector2;
  28826. /**
  28827. * Returns a new Vector2 scaled by "scale" from the current Vector2
  28828. * @param scale defines the scaling factor
  28829. * @returns a new Vector2
  28830. */
  28831. scale(scale: number): Vector2;
  28832. /**
  28833. * Scale the current Vector2 values by a factor to a given Vector2
  28834. * @param scale defines the scale factor
  28835. * @param result defines the Vector2 object where to store the result
  28836. * @returns the unmodified current Vector2
  28837. */
  28838. scaleToRef(scale: number, result: Vector2): Vector2;
  28839. /**
  28840. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  28841. * @param scale defines the scale factor
  28842. * @param result defines the Vector2 object where to store the result
  28843. * @returns the unmodified current Vector2
  28844. */
  28845. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  28846. /**
  28847. * Gets a boolean if two vectors are equals
  28848. * @param otherVector defines the other vector
  28849. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  28850. */
  28851. equals(otherVector: Vector2): boolean;
  28852. /**
  28853. * Gets a boolean if two vectors are equals (using an epsilon value)
  28854. * @param otherVector defines the other vector
  28855. * @param epsilon defines the minimal distance to consider equality
  28856. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  28857. */
  28858. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  28859. /**
  28860. * Gets a new Vector2 from current Vector2 floored values
  28861. * @returns a new Vector2
  28862. */
  28863. floor(): Vector2;
  28864. /**
  28865. * Gets a new Vector2 from current Vector2 floored values
  28866. * @returns a new Vector2
  28867. */
  28868. fract(): Vector2;
  28869. /**
  28870. * Gets the length of the vector
  28871. * @returns the vector length (float)
  28872. */
  28873. length(): number;
  28874. /**
  28875. * Gets the vector squared length
  28876. * @returns the vector squared length (float)
  28877. */
  28878. lengthSquared(): number;
  28879. /**
  28880. * Normalize the vector
  28881. * @returns the current updated Vector2
  28882. */
  28883. normalize(): Vector2;
  28884. /**
  28885. * Gets a new Vector2 copied from the Vector2
  28886. * @returns a new Vector2
  28887. */
  28888. clone(): Vector2;
  28889. /**
  28890. * Gets a new Vector2(0, 0)
  28891. * @returns a new Vector2
  28892. */
  28893. static Zero(): Vector2;
  28894. /**
  28895. * Gets a new Vector2(1, 1)
  28896. * @returns a new Vector2
  28897. */
  28898. static One(): Vector2;
  28899. /**
  28900. * Gets a new Vector2 set from the given index element of the given array
  28901. * @param array defines the data source
  28902. * @param offset defines the offset in the data source
  28903. * @returns a new Vector2
  28904. */
  28905. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  28906. /**
  28907. * Sets "result" from the given index element of the given array
  28908. * @param array defines the data source
  28909. * @param offset defines the offset in the data source
  28910. * @param result defines the target vector
  28911. */
  28912. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  28913. /**
  28914. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  28915. * @param value1 defines 1st point of control
  28916. * @param value2 defines 2nd point of control
  28917. * @param value3 defines 3rd point of control
  28918. * @param value4 defines 4th point of control
  28919. * @param amount defines the interpolation factor
  28920. * @returns a new Vector2
  28921. */
  28922. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  28923. /**
  28924. * 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".
  28925. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  28926. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  28927. * @param value defines the value to clamp
  28928. * @param min defines the lower limit
  28929. * @param max defines the upper limit
  28930. * @returns a new Vector2
  28931. */
  28932. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  28933. /**
  28934. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  28935. * @param value1 defines the 1st control point
  28936. * @param tangent1 defines the outgoing tangent
  28937. * @param value2 defines the 2nd control point
  28938. * @param tangent2 defines the incoming tangent
  28939. * @param amount defines the interpolation factor
  28940. * @returns a new Vector2
  28941. */
  28942. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  28943. /**
  28944. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  28945. * @param start defines the start vector
  28946. * @param end defines the end vector
  28947. * @param amount defines the interpolation factor
  28948. * @returns a new Vector2
  28949. */
  28950. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  28951. /**
  28952. * Gets the dot product of the vector "left" and the vector "right"
  28953. * @param left defines first vector
  28954. * @param right defines second vector
  28955. * @returns the dot product (float)
  28956. */
  28957. static Dot(left: Vector2, right: Vector2): number;
  28958. /**
  28959. * Returns a new Vector2 equal to the normalized given vector
  28960. * @param vector defines the vector to normalize
  28961. * @returns a new Vector2
  28962. */
  28963. static Normalize(vector: Vector2): Vector2;
  28964. /**
  28965. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  28966. * @param left defines 1st vector
  28967. * @param right defines 2nd vector
  28968. * @returns a new Vector2
  28969. */
  28970. static Minimize(left: Vector2, right: Vector2): Vector2;
  28971. /**
  28972. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  28973. * @param left defines 1st vector
  28974. * @param right defines 2nd vector
  28975. * @returns a new Vector2
  28976. */
  28977. static Maximize(left: Vector2, right: Vector2): Vector2;
  28978. /**
  28979. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  28980. * @param vector defines the vector to transform
  28981. * @param transformation defines the matrix to apply
  28982. * @returns a new Vector2
  28983. */
  28984. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  28985. /**
  28986. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  28987. * @param vector defines the vector to transform
  28988. * @param transformation defines the matrix to apply
  28989. * @param result defines the target vector
  28990. */
  28991. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  28992. /**
  28993. * Determines if a given vector is included in a triangle
  28994. * @param p defines the vector to test
  28995. * @param p0 defines 1st triangle point
  28996. * @param p1 defines 2nd triangle point
  28997. * @param p2 defines 3rd triangle point
  28998. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  28999. */
  29000. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  29001. /**
  29002. * Gets the distance between the vectors "value1" and "value2"
  29003. * @param value1 defines first vector
  29004. * @param value2 defines second vector
  29005. * @returns the distance between vectors
  29006. */
  29007. static Distance(value1: Vector2, value2: Vector2): number;
  29008. /**
  29009. * Returns the squared distance between the vectors "value1" and "value2"
  29010. * @param value1 defines first vector
  29011. * @param value2 defines second vector
  29012. * @returns the squared distance between vectors
  29013. */
  29014. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  29015. /**
  29016. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  29017. * @param value1 defines first vector
  29018. * @param value2 defines second vector
  29019. * @returns a new Vector2
  29020. */
  29021. static Center(value1: Vector2, value2: Vector2): Vector2;
  29022. /**
  29023. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  29024. * @param p defines the middle point
  29025. * @param segA defines one point of the segment
  29026. * @param segB defines the other point of the segment
  29027. * @returns the shortest distance
  29028. */
  29029. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  29030. }
  29031. /**
  29032. * Classed used to store (x,y,z) vector representation
  29033. * A Vector3 is the main object used in 3D geometry
  29034. * It can represent etiher the coordinates of a point the space, either a direction
  29035. * Reminder: Babylon.js uses a left handed forward facing system
  29036. */
  29037. class Vector3 {
  29038. /**
  29039. * Defines the first coordinates (on X axis)
  29040. */
  29041. x: number;
  29042. /**
  29043. * Defines the second coordinates (on Y axis)
  29044. */
  29045. y: number;
  29046. /**
  29047. * Defines the third coordinates (on Z axis)
  29048. */
  29049. z: number;
  29050. /**
  29051. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  29052. * @param x defines the first coordinates (on X axis)
  29053. * @param y defines the second coordinates (on Y axis)
  29054. * @param z defines the third coordinates (on Z axis)
  29055. */
  29056. constructor(
  29057. /**
  29058. * Defines the first coordinates (on X axis)
  29059. */
  29060. x?: number,
  29061. /**
  29062. * Defines the second coordinates (on Y axis)
  29063. */
  29064. y?: number,
  29065. /**
  29066. * Defines the third coordinates (on Z axis)
  29067. */
  29068. z?: number);
  29069. /**
  29070. * Creates a string representation of the Vector3
  29071. * @returns a string with the Vector3 coordinates.
  29072. */
  29073. toString(): string;
  29074. /**
  29075. * Gets the class name
  29076. * @returns the string "Vector3"
  29077. */
  29078. getClassName(): string;
  29079. /**
  29080. * Creates the Vector3 hash code
  29081. * @returns a number which tends to be unique between Vector3 instances
  29082. */
  29083. getHashCode(): number;
  29084. /**
  29085. * Creates an array containing three elements : the coordinates of the Vector3
  29086. * @returns a new array of numbers
  29087. */
  29088. asArray(): number[];
  29089. /**
  29090. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  29091. * @param array defines the destination array
  29092. * @param index defines the offset in the destination array
  29093. * @returns the current Vector3
  29094. */
  29095. toArray(array: FloatArray, index?: number): Vector3;
  29096. /**
  29097. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  29098. * @returns a new Quaternion object, computed from the Vector3 coordinates
  29099. */
  29100. toQuaternion(): Quaternion;
  29101. /**
  29102. * Adds the given vector to the current Vector3
  29103. * @param otherVector defines the second operand
  29104. * @returns the current updated Vector3
  29105. */
  29106. addInPlace(otherVector: Vector3): Vector3;
  29107. /**
  29108. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  29109. * @param otherVector defines the second operand
  29110. * @returns the resulting Vector3
  29111. */
  29112. add(otherVector: Vector3): Vector3;
  29113. /**
  29114. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  29115. * @param otherVector defines the second operand
  29116. * @param result defines the Vector3 object where to store the result
  29117. * @returns the current Vector3
  29118. */
  29119. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  29120. /**
  29121. * Subtract the given vector from the current Vector3
  29122. * @param otherVector defines the second operand
  29123. * @returns the current updated Vector3
  29124. */
  29125. subtractInPlace(otherVector: Vector3): Vector3;
  29126. /**
  29127. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  29128. * @param otherVector defines the second operand
  29129. * @returns the resulting Vector3
  29130. */
  29131. subtract(otherVector: Vector3): Vector3;
  29132. /**
  29133. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  29134. * @param otherVector defines the second operand
  29135. * @param result defines the Vector3 object where to store the result
  29136. * @returns the current Vector3
  29137. */
  29138. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  29139. /**
  29140. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  29141. * @param x defines the x coordinate of the operand
  29142. * @param y defines the y coordinate of the operand
  29143. * @param z defines the z coordinate of the operand
  29144. * @returns the resulting Vector3
  29145. */
  29146. subtractFromFloats(x: number, y: number, z: number): Vector3;
  29147. /**
  29148. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  29149. * @param x defines the x coordinate of the operand
  29150. * @param y defines the y coordinate of the operand
  29151. * @param z defines the z coordinate of the operand
  29152. * @param result defines the Vector3 object where to store the result
  29153. * @returns the current Vector3
  29154. */
  29155. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  29156. /**
  29157. * Gets a new Vector3 set with the current Vector3 negated coordinates
  29158. * @returns a new Vector3
  29159. */
  29160. negate(): Vector3;
  29161. /**
  29162. * Multiplies the Vector3 coordinates by the float "scale"
  29163. * @param scale defines the multiplier factor
  29164. * @returns the current updated Vector3
  29165. */
  29166. scaleInPlace(scale: number): Vector3;
  29167. /**
  29168. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  29169. * @param scale defines the multiplier factor
  29170. * @returns a new Vector3
  29171. */
  29172. scale(scale: number): Vector3;
  29173. /**
  29174. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  29175. * @param scale defines the multiplier factor
  29176. * @param result defines the Vector3 object where to store the result
  29177. * @returns the current Vector3
  29178. */
  29179. scaleToRef(scale: number, result: Vector3): Vector3;
  29180. /**
  29181. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  29182. * @param scale defines the scale factor
  29183. * @param result defines the Vector3 object where to store the result
  29184. * @returns the unmodified current Vector3
  29185. */
  29186. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  29187. /**
  29188. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  29189. * @param otherVector defines the second operand
  29190. * @returns true if both vectors are equals
  29191. */
  29192. equals(otherVector: Vector3): boolean;
  29193. /**
  29194. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  29195. * @param otherVector defines the second operand
  29196. * @param epsilon defines the minimal distance to define values as equals
  29197. * @returns true if both vectors are distant less than epsilon
  29198. */
  29199. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  29200. /**
  29201. * Returns true if the current Vector3 coordinates equals the given floats
  29202. * @param x defines the x coordinate of the operand
  29203. * @param y defines the y coordinate of the operand
  29204. * @param z defines the z coordinate of the operand
  29205. * @returns true if both vectors are equals
  29206. */
  29207. equalsToFloats(x: number, y: number, z: number): boolean;
  29208. /**
  29209. * Multiplies the current Vector3 coordinates by the given ones
  29210. * @param otherVector defines the second operand
  29211. * @returns the current updated Vector3
  29212. */
  29213. multiplyInPlace(otherVector: Vector3): Vector3;
  29214. /**
  29215. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  29216. * @param otherVector defines the second operand
  29217. * @returns the new Vector3
  29218. */
  29219. multiply(otherVector: Vector3): Vector3;
  29220. /**
  29221. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  29222. * @param otherVector defines the second operand
  29223. * @param result defines the Vector3 object where to store the result
  29224. * @returns the current Vector3
  29225. */
  29226. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  29227. /**
  29228. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  29229. * @param x defines the x coordinate of the operand
  29230. * @param y defines the y coordinate of the operand
  29231. * @param z defines the z coordinate of the operand
  29232. * @returns the new Vector3
  29233. */
  29234. multiplyByFloats(x: number, y: number, z: number): Vector3;
  29235. /**
  29236. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  29237. * @param otherVector defines the second operand
  29238. * @returns the new Vector3
  29239. */
  29240. divide(otherVector: Vector3): Vector3;
  29241. /**
  29242. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  29243. * @param otherVector defines the second operand
  29244. * @param result defines the Vector3 object where to store the result
  29245. * @returns the current Vector3
  29246. */
  29247. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  29248. /**
  29249. * Divides the current Vector3 coordinates by the given ones.
  29250. * @param otherVector defines the second operand
  29251. * @returns the current updated Vector3
  29252. */
  29253. divideInPlace(otherVector: Vector3): Vector3;
  29254. /**
  29255. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  29256. * @param other defines the second operand
  29257. * @returns the current updated Vector3
  29258. */
  29259. minimizeInPlace(other: Vector3): Vector3;
  29260. /**
  29261. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  29262. * @param other defines the second operand
  29263. * @returns the current updated Vector3
  29264. */
  29265. maximizeInPlace(other: Vector3): Vector3;
  29266. /**
  29267. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  29268. */
  29269. readonly isNonUniform: boolean;
  29270. /**
  29271. * Gets a new Vector3 from current Vector3 floored values
  29272. * @returns a new Vector3
  29273. */
  29274. floor(): Vector3;
  29275. /**
  29276. * Gets a new Vector3 from current Vector3 floored values
  29277. * @returns a new Vector3
  29278. */
  29279. fract(): Vector3;
  29280. /**
  29281. * Gets the length of the Vector3
  29282. * @returns the length of the Vecto3
  29283. */
  29284. length(): number;
  29285. /**
  29286. * Gets the squared length of the Vector3
  29287. * @returns squared length of the Vector3
  29288. */
  29289. lengthSquared(): number;
  29290. /**
  29291. * Normalize the current Vector3.
  29292. * Please note that this is an in place operation.
  29293. * @returns the current updated Vector3
  29294. */
  29295. normalize(): Vector3;
  29296. /**
  29297. * Normalize the current Vector3 to a new vector
  29298. * @returns the new Vector3
  29299. */
  29300. normalizeToNew(): Vector3;
  29301. /**
  29302. * Normalize the current Vector3 to the reference
  29303. * @param reference define the Vector3 to update
  29304. * @returns the updated Vector3
  29305. */
  29306. normalizeToRef(reference: Vector3): Vector3;
  29307. /**
  29308. * Creates a new Vector3 copied from the current Vector3
  29309. * @returns the new Vector3
  29310. */
  29311. clone(): Vector3;
  29312. /**
  29313. * Copies the given vector coordinates to the current Vector3 ones
  29314. * @param source defines the source Vector3
  29315. * @returns the current updated Vector3
  29316. */
  29317. copyFrom(source: Vector3): Vector3;
  29318. /**
  29319. * Copies the given floats to the current Vector3 coordinates
  29320. * @param x defines the x coordinate of the operand
  29321. * @param y defines the y coordinate of the operand
  29322. * @param z defines the z coordinate of the operand
  29323. * @returns the current updated Vector3
  29324. */
  29325. copyFromFloats(x: number, y: number, z: number): Vector3;
  29326. /**
  29327. * Copies the given floats to the current Vector3 coordinates
  29328. * @param x defines the x coordinate of the operand
  29329. * @param y defines the y coordinate of the operand
  29330. * @param z defines the z coordinate of the operand
  29331. * @returns the current updated Vector3
  29332. */
  29333. set(x: number, y: number, z: number): Vector3;
  29334. /**
  29335. * Get the clip factor between two vectors
  29336. * @param vector0 defines the first operand
  29337. * @param vector1 defines the second operand
  29338. * @param axis defines the axis to use
  29339. * @param size defines the size along the axis
  29340. * @returns the clip factor
  29341. */
  29342. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  29343. /**
  29344. * Get angle between two vectors
  29345. * @param vector0 angle between vector0 and vector1
  29346. * @param vector1 angle between vector0 and vector1
  29347. * @param normal direction of the normal
  29348. * @return the angle between vector0 and vector1
  29349. */
  29350. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  29351. /**
  29352. * Returns a new Vector3 set from the index "offset" of the given array
  29353. * @param array defines the source array
  29354. * @param offset defines the offset in the source array
  29355. * @returns the new Vector3
  29356. */
  29357. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  29358. /**
  29359. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  29360. * This function is deprecated. Use FromArray instead
  29361. * @param array defines the source array
  29362. * @param offset defines the offset in the source array
  29363. * @returns the new Vector3
  29364. */
  29365. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  29366. /**
  29367. * Sets the given vector "result" with the element values from the index "offset" of the given array
  29368. * @param array defines the source array
  29369. * @param offset defines the offset in the source array
  29370. * @param result defines the Vector3 where to store the result
  29371. */
  29372. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  29373. /**
  29374. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  29375. * This function is deprecated. Use FromArrayToRef instead.
  29376. * @param array defines the source array
  29377. * @param offset defines the offset in the source array
  29378. * @param result defines the Vector3 where to store the result
  29379. */
  29380. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  29381. /**
  29382. * Sets the given vector "result" with the given floats.
  29383. * @param x defines the x coordinate of the source
  29384. * @param y defines the y coordinate of the source
  29385. * @param z defines the z coordinate of the source
  29386. * @param result defines the Vector3 where to store the result
  29387. */
  29388. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  29389. /**
  29390. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  29391. * @returns a new empty Vector3
  29392. */
  29393. static Zero(): Vector3;
  29394. /**
  29395. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  29396. * @returns a new unit Vector3
  29397. */
  29398. static One(): Vector3;
  29399. /**
  29400. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  29401. * @returns a new up Vector3
  29402. */
  29403. static Up(): Vector3;
  29404. /**
  29405. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  29406. * @returns a new down Vector3
  29407. */
  29408. static Down(): Vector3;
  29409. /**
  29410. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  29411. * @returns a new forward Vector3
  29412. */
  29413. static Forward(): Vector3;
  29414. /**
  29415. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  29416. * @returns a new right Vector3
  29417. */
  29418. static Right(): Vector3;
  29419. /**
  29420. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  29421. * @returns a new left Vector3
  29422. */
  29423. static Left(): Vector3;
  29424. /**
  29425. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  29426. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  29427. * @param vector defines the Vector3 to transform
  29428. * @param transformation defines the transformation matrix
  29429. * @returns the transformed Vector3
  29430. */
  29431. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  29432. /**
  29433. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  29434. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  29435. * @param vector defines the Vector3 to transform
  29436. * @param transformation defines the transformation matrix
  29437. * @param result defines the Vector3 where to store the result
  29438. */
  29439. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  29440. /**
  29441. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  29442. * This method computes tranformed coordinates only, not transformed direction vectors
  29443. * @param x define the x coordinate of the source vector
  29444. * @param y define the y coordinate of the source vector
  29445. * @param z define the z coordinate of the source vector
  29446. * @param transformation defines the transformation matrix
  29447. * @param result defines the Vector3 where to store the result
  29448. */
  29449. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  29450. /**
  29451. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  29452. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  29453. * @param vector defines the Vector3 to transform
  29454. * @param transformation defines the transformation matrix
  29455. * @returns the new Vector3
  29456. */
  29457. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  29458. /**
  29459. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  29460. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  29461. * @param vector defines the Vector3 to transform
  29462. * @param transformation defines the transformation matrix
  29463. * @param result defines the Vector3 where to store the result
  29464. */
  29465. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  29466. /**
  29467. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  29468. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  29469. * @param x define the x coordinate of the source vector
  29470. * @param y define the y coordinate of the source vector
  29471. * @param z define the z coordinate of the source vector
  29472. * @param transformation defines the transformation matrix
  29473. * @param result defines the Vector3 where to store the result
  29474. */
  29475. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  29476. /**
  29477. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  29478. * @param value1 defines the first control point
  29479. * @param value2 defines the second control point
  29480. * @param value3 defines the third control point
  29481. * @param value4 defines the fourth control point
  29482. * @param amount defines the amount on the spline to use
  29483. * @returns the new Vector3
  29484. */
  29485. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  29486. /**
  29487. * 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"
  29488. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  29489. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  29490. * @param value defines the current value
  29491. * @param min defines the lower range value
  29492. * @param max defines the upper range value
  29493. * @returns the new Vector3
  29494. */
  29495. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  29496. /**
  29497. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  29498. * @param value1 defines the first control point
  29499. * @param tangent1 defines the first tangent vector
  29500. * @param value2 defines the second control point
  29501. * @param tangent2 defines the second tangent vector
  29502. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  29503. * @returns the new Vector3
  29504. */
  29505. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  29506. /**
  29507. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  29508. * @param start defines the start value
  29509. * @param end defines the end value
  29510. * @param amount max defines amount between both (between 0 and 1)
  29511. * @returns the new Vector3
  29512. */
  29513. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  29514. /**
  29515. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  29516. * @param start defines the start value
  29517. * @param end defines the end value
  29518. * @param amount max defines amount between both (between 0 and 1)
  29519. * @param result defines the Vector3 where to store the result
  29520. */
  29521. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  29522. /**
  29523. * Returns the dot product (float) between the vectors "left" and "right"
  29524. * @param left defines the left operand
  29525. * @param right defines the right operand
  29526. * @returns the dot product
  29527. */
  29528. static Dot(left: Vector3, right: Vector3): number;
  29529. /**
  29530. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  29531. * The cross product is then orthogonal to both "left" and "right"
  29532. * @param left defines the left operand
  29533. * @param right defines the right operand
  29534. * @returns the cross product
  29535. */
  29536. static Cross(left: Vector3, right: Vector3): Vector3;
  29537. /**
  29538. * Sets the given vector "result" with the cross product of "left" and "right"
  29539. * The cross product is then orthogonal to both "left" and "right"
  29540. * @param left defines the left operand
  29541. * @param right defines the right operand
  29542. * @param result defines the Vector3 where to store the result
  29543. */
  29544. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  29545. /**
  29546. * Returns a new Vector3 as the normalization of the given vector
  29547. * @param vector defines the Vector3 to normalize
  29548. * @returns the new Vector3
  29549. */
  29550. static Normalize(vector: Vector3): Vector3;
  29551. /**
  29552. * Sets the given vector "result" with the normalization of the given first vector
  29553. * @param vector defines the Vector3 to normalize
  29554. * @param result defines the Vector3 where to store the result
  29555. */
  29556. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  29557. private static _viewportMatrixCache;
  29558. /**
  29559. * Project a Vector3 onto screen space
  29560. * @param vector defines the Vector3 to project
  29561. * @param world defines the world matrix to use
  29562. * @param transform defines the transform (view x projection) matrix to use
  29563. * @param viewport defines the screen viewport to use
  29564. * @returns the new Vector3
  29565. */
  29566. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  29567. /**
  29568. * Unproject from screen space to object space
  29569. * @param source defines the screen space Vector3 to use
  29570. * @param viewportWidth defines the current width of the viewport
  29571. * @param viewportHeight defines the current height of the viewport
  29572. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  29573. * @param transform defines the transform (view x projection) matrix to use
  29574. * @returns the new Vector3
  29575. */
  29576. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  29577. /**
  29578. * Unproject from screen space to object space
  29579. * @param source defines the screen space Vector3 to use
  29580. * @param viewportWidth defines the current width of the viewport
  29581. * @param viewportHeight defines the current height of the viewport
  29582. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  29583. * @param view defines the view matrix to use
  29584. * @param projection defines the projection matrix to use
  29585. * @returns the new Vector3
  29586. */
  29587. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  29588. /**
  29589. * Unproject from screen space to object space
  29590. * @param source defines the screen space Vector3 to use
  29591. * @param viewportWidth defines the current width of the viewport
  29592. * @param viewportHeight defines the current height of the viewport
  29593. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  29594. * @param view defines the view matrix to use
  29595. * @param projection defines the projection matrix to use
  29596. * @param result defines the Vector3 where to store the result
  29597. */
  29598. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  29599. /**
  29600. * Unproject from screen space to object space
  29601. * @param sourceX defines the screen space x coordinate to use
  29602. * @param sourceY defines the screen space y coordinate to use
  29603. * @param sourceZ defines the screen space z coordinate to use
  29604. * @param viewportWidth defines the current width of the viewport
  29605. * @param viewportHeight defines the current height of the viewport
  29606. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  29607. * @param view defines the view matrix to use
  29608. * @param projection defines the projection matrix to use
  29609. * @param result defines the Vector3 where to store the result
  29610. */
  29611. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  29612. /**
  29613. * Gets the minimal coordinate values between two Vector3
  29614. * @param left defines the first operand
  29615. * @param right defines the second operand
  29616. * @returns the new Vector3
  29617. */
  29618. static Minimize(left: Vector3, right: Vector3): Vector3;
  29619. /**
  29620. * Gets the maximal coordinate values between two Vector3
  29621. * @param left defines the first operand
  29622. * @param right defines the second operand
  29623. * @returns the new Vector3
  29624. */
  29625. static Maximize(left: Vector3, right: Vector3): Vector3;
  29626. /**
  29627. * Returns the distance between the vectors "value1" and "value2"
  29628. * @param value1 defines the first operand
  29629. * @param value2 defines the second operand
  29630. * @returns the distance
  29631. */
  29632. static Distance(value1: Vector3, value2: Vector3): number;
  29633. /**
  29634. * Returns the squared distance between the vectors "value1" and "value2"
  29635. * @param value1 defines the first operand
  29636. * @param value2 defines the second operand
  29637. * @returns the squared distance
  29638. */
  29639. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  29640. /**
  29641. * Returns a new Vector3 located at the center between "value1" and "value2"
  29642. * @param value1 defines the first operand
  29643. * @param value2 defines the second operand
  29644. * @returns the new Vector3
  29645. */
  29646. static Center(value1: Vector3, value2: Vector3): Vector3;
  29647. /**
  29648. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  29649. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  29650. * to something in order to rotate it from its local system to the given target system
  29651. * Note: axis1, axis2 and axis3 are normalized during this operation
  29652. * @param axis1 defines the first axis
  29653. * @param axis2 defines the second axis
  29654. * @param axis3 defines the third axis
  29655. * @returns a new Vector3
  29656. */
  29657. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  29658. /**
  29659. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  29660. * @param axis1 defines the first axis
  29661. * @param axis2 defines the second axis
  29662. * @param axis3 defines the third axis
  29663. * @param ref defines the Vector3 where to store the result
  29664. */
  29665. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  29666. }
  29667. class Vector4 {
  29668. x: number;
  29669. y: number;
  29670. z: number;
  29671. w: number;
  29672. /**
  29673. * Creates a Vector4 object from the given floats.
  29674. */
  29675. constructor(x: number, y: number, z: number, w: number);
  29676. /**
  29677. * Returns the string with the Vector4 coordinates.
  29678. */
  29679. toString(): string;
  29680. /**
  29681. * Returns the string "Vector4".
  29682. */
  29683. getClassName(): string;
  29684. /**
  29685. * Returns the Vector4 hash code.
  29686. */
  29687. getHashCode(): number;
  29688. /**
  29689. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  29690. */
  29691. asArray(): number[];
  29692. /**
  29693. * Populates the given array from the given index with the Vector4 coordinates.
  29694. * Returns the Vector4.
  29695. */
  29696. toArray(array: FloatArray, index?: number): Vector4;
  29697. /**
  29698. * Adds the given vector to the current Vector4.
  29699. * Returns the updated Vector4.
  29700. */
  29701. addInPlace(otherVector: Vector4): Vector4;
  29702. /**
  29703. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  29704. */
  29705. add(otherVector: Vector4): Vector4;
  29706. /**
  29707. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  29708. * Returns the current Vector4.
  29709. */
  29710. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  29711. /**
  29712. * Subtract in place the given vector from the current Vector4.
  29713. * Returns the updated Vector4.
  29714. */
  29715. subtractInPlace(otherVector: Vector4): Vector4;
  29716. /**
  29717. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  29718. */
  29719. subtract(otherVector: Vector4): Vector4;
  29720. /**
  29721. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  29722. * Returns the current Vector4.
  29723. */
  29724. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  29725. /**
  29726. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  29727. */
  29728. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  29729. /**
  29730. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  29731. * Returns the current Vector4.
  29732. */
  29733. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  29734. /**
  29735. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  29736. */
  29737. negate(): Vector4;
  29738. /**
  29739. * Multiplies the current Vector4 coordinates by scale (float).
  29740. * Returns the updated Vector4.
  29741. */
  29742. scaleInPlace(scale: number): Vector4;
  29743. /**
  29744. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  29745. */
  29746. scale(scale: number): Vector4;
  29747. /**
  29748. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  29749. * Returns the current Vector4.
  29750. */
  29751. scaleToRef(scale: number, result: Vector4): Vector4;
  29752. /**
  29753. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  29754. * @param scale defines the scale factor
  29755. * @param result defines the Vector4 object where to store the result
  29756. * @returns the unmodified current Vector4
  29757. */
  29758. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  29759. /**
  29760. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  29761. */
  29762. equals(otherVector: Vector4): boolean;
  29763. /**
  29764. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  29765. */
  29766. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  29767. /**
  29768. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  29769. */
  29770. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  29771. /**
  29772. * Multiplies in place the current Vector4 by the given one.
  29773. * Returns the updated Vector4.
  29774. */
  29775. multiplyInPlace(otherVector: Vector4): Vector4;
  29776. /**
  29777. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  29778. */
  29779. multiply(otherVector: Vector4): Vector4;
  29780. /**
  29781. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  29782. * Returns the current Vector4.
  29783. */
  29784. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  29785. /**
  29786. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  29787. */
  29788. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  29789. /**
  29790. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  29791. */
  29792. divide(otherVector: Vector4): Vector4;
  29793. /**
  29794. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  29795. * Returns the current Vector4.
  29796. */
  29797. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  29798. /**
  29799. * Divides the current Vector3 coordinates by the given ones.
  29800. * @returns the updated Vector3.
  29801. */
  29802. divideInPlace(otherVector: Vector4): Vector4;
  29803. /**
  29804. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  29805. * @param other defines the second operand
  29806. * @returns the current updated Vector4
  29807. */
  29808. minimizeInPlace(other: Vector4): Vector4;
  29809. /**
  29810. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  29811. * @param other defines the second operand
  29812. * @returns the current updated Vector4
  29813. */
  29814. maximizeInPlace(other: Vector4): Vector4;
  29815. /**
  29816. * Gets a new Vector4 from current Vector4 floored values
  29817. * @returns a new Vector4
  29818. */
  29819. floor(): Vector4;
  29820. /**
  29821. * Gets a new Vector4 from current Vector3 floored values
  29822. * @returns a new Vector4
  29823. */
  29824. fract(): Vector4;
  29825. /**
  29826. * Returns the Vector4 length (float).
  29827. */
  29828. length(): number;
  29829. /**
  29830. * Returns the Vector4 squared length (float).
  29831. */
  29832. lengthSquared(): number;
  29833. /**
  29834. * Normalizes in place the Vector4.
  29835. * Returns the updated Vector4.
  29836. */
  29837. normalize(): Vector4;
  29838. /**
  29839. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  29840. */
  29841. toVector3(): Vector3;
  29842. /**
  29843. * Returns a new Vector4 copied from the current one.
  29844. */
  29845. clone(): Vector4;
  29846. /**
  29847. * Updates the current Vector4 with the given one coordinates.
  29848. * Returns the updated Vector4.
  29849. */
  29850. copyFrom(source: Vector4): Vector4;
  29851. /**
  29852. * Updates the current Vector4 coordinates with the given floats.
  29853. * Returns the updated Vector4.
  29854. */
  29855. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  29856. /**
  29857. * Updates the current Vector4 coordinates with the given floats.
  29858. * Returns the updated Vector4.
  29859. */
  29860. set(x: number, y: number, z: number, w: number): Vector4;
  29861. /**
  29862. * Returns a new Vector4 set from the starting index of the given array.
  29863. */
  29864. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  29865. /**
  29866. * Updates the given vector "result" from the starting index of the given array.
  29867. */
  29868. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  29869. /**
  29870. * Updates the given vector "result" from the starting index of the given Float32Array.
  29871. */
  29872. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  29873. /**
  29874. * Updates the given vector "result" coordinates from the given floats.
  29875. */
  29876. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  29877. /**
  29878. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  29879. */
  29880. static Zero(): Vector4;
  29881. /**
  29882. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  29883. */
  29884. static One(): Vector4;
  29885. /**
  29886. * Returns a new normalized Vector4 from the given one.
  29887. */
  29888. static Normalize(vector: Vector4): Vector4;
  29889. /**
  29890. * Updates the given vector "result" from the normalization of the given one.
  29891. */
  29892. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  29893. static Minimize(left: Vector4, right: Vector4): Vector4;
  29894. static Maximize(left: Vector4, right: Vector4): Vector4;
  29895. /**
  29896. * Returns the distance (float) between the vectors "value1" and "value2".
  29897. */
  29898. static Distance(value1: Vector4, value2: Vector4): number;
  29899. /**
  29900. * Returns the squared distance (float) between the vectors "value1" and "value2".
  29901. */
  29902. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  29903. /**
  29904. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  29905. */
  29906. static Center(value1: Vector4, value2: Vector4): Vector4;
  29907. /**
  29908. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  29909. * This methods computes transformed normalized direction vectors only.
  29910. */
  29911. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  29912. /**
  29913. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  29914. * This methods computes transformed normalized direction vectors only.
  29915. */
  29916. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  29917. /**
  29918. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  29919. * This methods computes transformed normalized direction vectors only.
  29920. */
  29921. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  29922. }
  29923. interface ISize {
  29924. width: number;
  29925. height: number;
  29926. }
  29927. class Size implements ISize {
  29928. width: number;
  29929. height: number;
  29930. /**
  29931. * Creates a Size object from the given width and height (floats).
  29932. */
  29933. constructor(width: number, height: number);
  29934. toString(): string;
  29935. /**
  29936. * Returns the string "Size"
  29937. */
  29938. getClassName(): string;
  29939. /**
  29940. * Returns the Size hash code.
  29941. */
  29942. getHashCode(): number;
  29943. /**
  29944. * Updates the current size from the given one.
  29945. * Returns the updated Size.
  29946. */
  29947. copyFrom(src: Size): void;
  29948. /**
  29949. * Updates in place the current Size from the given floats.
  29950. * Returns the updated Size.
  29951. */
  29952. copyFromFloats(width: number, height: number): Size;
  29953. /**
  29954. * Updates in place the current Size from the given floats.
  29955. * Returns the updated Size.
  29956. */
  29957. set(width: number, height: number): Size;
  29958. /**
  29959. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  29960. */
  29961. multiplyByFloats(w: number, h: number): Size;
  29962. /**
  29963. * Returns a new Size copied from the given one.
  29964. */
  29965. clone(): Size;
  29966. /**
  29967. * Boolean : True if the current Size and the given one width and height are strictly equal.
  29968. */
  29969. equals(other: Size): boolean;
  29970. /**
  29971. * Returns the surface of the Size : width * height (float).
  29972. */
  29973. readonly surface: number;
  29974. /**
  29975. * Returns a new Size set to (0.0, 0.0)
  29976. */
  29977. static Zero(): Size;
  29978. /**
  29979. * Returns a new Size set as the addition result of the current Size and the given one.
  29980. */
  29981. add(otherSize: Size): Size;
  29982. /**
  29983. * Returns a new Size set as the subtraction result of the given one from the current Size.
  29984. */
  29985. subtract(otherSize: Size): Size;
  29986. /**
  29987. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  29988. */
  29989. static Lerp(start: Size, end: Size, amount: number): Size;
  29990. }
  29991. /**
  29992. * Class used to store quaternion data
  29993. * @see https://en.wikipedia.org/wiki/Quaternion
  29994. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  29995. */
  29996. class Quaternion {
  29997. /** defines the first component (0 by default) */
  29998. x: number;
  29999. /** defines the second component (0 by default) */
  30000. y: number;
  30001. /** defines the third component (0 by default) */
  30002. z: number;
  30003. /** defines the fourth component (1.0 by default) */
  30004. w: number;
  30005. /**
  30006. * Creates a new Quaternion from the given floats
  30007. * @param x defines the first component (0 by default)
  30008. * @param y defines the second component (0 by default)
  30009. * @param z defines the third component (0 by default)
  30010. * @param w defines the fourth component (1.0 by default)
  30011. */
  30012. constructor(
  30013. /** defines the first component (0 by default) */
  30014. x?: number,
  30015. /** defines the second component (0 by default) */
  30016. y?: number,
  30017. /** defines the third component (0 by default) */
  30018. z?: number,
  30019. /** defines the fourth component (1.0 by default) */
  30020. w?: number);
  30021. /**
  30022. * Gets a string representation for the current quaternion
  30023. * @returns a string with the Quaternion coordinates
  30024. */
  30025. toString(): string;
  30026. /**
  30027. * Gets the class name of the quaternion
  30028. * @returns the string "Quaternion"
  30029. */
  30030. getClassName(): string;
  30031. /**
  30032. * Gets a hash code for this quaternion
  30033. * @returns the quaternion hash code
  30034. */
  30035. getHashCode(): number;
  30036. /**
  30037. * Copy the quaternion to an array
  30038. * @returns a new array populated with 4 elements from the quaternion coordinates
  30039. */
  30040. asArray(): number[];
  30041. /**
  30042. * Check if two quaternions are equals
  30043. * @param otherQuaternion defines the second operand
  30044. * @return true if the current quaternion and the given one coordinates are strictly equals
  30045. */
  30046. equals(otherQuaternion: Quaternion): boolean;
  30047. /**
  30048. * Clone the current quaternion
  30049. * @returns a new quaternion copied from the current one
  30050. */
  30051. clone(): Quaternion;
  30052. /**
  30053. * Copy a quaternion to the current one
  30054. * @param other defines the other quaternion
  30055. * @returns the updated current quaternion
  30056. */
  30057. copyFrom(other: Quaternion): Quaternion;
  30058. /**
  30059. * Updates the current quaternion with the given float coordinates
  30060. * @param x defines the x coordinate
  30061. * @param y defines the y coordinate
  30062. * @param z defines the z coordinate
  30063. * @param w defines the w coordinate
  30064. * @returns the updated current quaternion
  30065. */
  30066. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  30067. /**
  30068. * Updates the current quaternion from the given float coordinates
  30069. * @param x defines the x coordinate
  30070. * @param y defines the y coordinate
  30071. * @param z defines the z coordinate
  30072. * @param w defines the w coordinate
  30073. * @returns the updated current quaternion
  30074. */
  30075. set(x: number, y: number, z: number, w: number): Quaternion;
  30076. /**
  30077. * Adds two quaternions
  30078. * @param other defines the second operand
  30079. * @returns a new quaternion as the addition result of the given one and the current quaternion
  30080. */
  30081. add(other: Quaternion): Quaternion;
  30082. /**
  30083. * Add a quaternion to the current one
  30084. * @param other defines the quaternion to add
  30085. * @returns the current quaternion
  30086. */
  30087. addInPlace(other: Quaternion): Quaternion;
  30088. /**
  30089. * Subtract two quaternions
  30090. * @param other defines the second operand
  30091. * @returns a new quaternion as the subtraction result of the given one from the current one
  30092. */
  30093. subtract(other: Quaternion): Quaternion;
  30094. /**
  30095. * Multiplies the current quaternion by a scale factor
  30096. * @param value defines the scale factor
  30097. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  30098. */
  30099. scale(value: number): Quaternion;
  30100. /**
  30101. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  30102. * @param scale defines the scale factor
  30103. * @param result defines the Quaternion object where to store the result
  30104. * @returns the unmodified current quaternion
  30105. */
  30106. scaleToRef(scale: number, result: Quaternion): Quaternion;
  30107. /**
  30108. * Multiplies in place the current quaternion by a scale factor
  30109. * @param value defines the scale factor
  30110. * @returns the current modified quaternion
  30111. */
  30112. scaleInPlace(value: number): Quaternion;
  30113. /**
  30114. * Scale the current quaternion values by a factor and add the result to a given quaternion
  30115. * @param scale defines the scale factor
  30116. * @param result defines the Quaternion object where to store the result
  30117. * @returns the unmodified current quaternion
  30118. */
  30119. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  30120. /**
  30121. * Multiplies two quaternions
  30122. * @param q1 defines the second operand
  30123. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  30124. */
  30125. multiply(q1: Quaternion): Quaternion;
  30126. /**
  30127. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  30128. * @param q1 defines the second operand
  30129. * @param result defines the target quaternion
  30130. * @returns the current quaternion
  30131. */
  30132. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  30133. /**
  30134. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  30135. * @param q1 defines the second operand
  30136. * @returns the currentupdated quaternion
  30137. */
  30138. multiplyInPlace(q1: Quaternion): Quaternion;
  30139. /**
  30140. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  30141. * @param ref defines the target quaternion
  30142. * @returns the current quaternion
  30143. */
  30144. conjugateToRef(ref: Quaternion): Quaternion;
  30145. /**
  30146. * Conjugates in place (1-q) the current quaternion
  30147. * @returns the current updated quaternion
  30148. */
  30149. conjugateInPlace(): Quaternion;
  30150. /**
  30151. * Conjugates in place (1-q) the current quaternion
  30152. * @returns a new quaternion
  30153. */
  30154. conjugate(): Quaternion;
  30155. /**
  30156. * Gets length of current quaternion
  30157. * @returns the quaternion length (float)
  30158. */
  30159. length(): number;
  30160. /**
  30161. * Normalize in place the current quaternion
  30162. * @returns the current updated quaternion
  30163. */
  30164. normalize(): Quaternion;
  30165. /**
  30166. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  30167. * @param order is a reserved parameter and is ignore for now
  30168. * @returns a new Vector3 containing the Euler angles
  30169. */
  30170. toEulerAngles(order?: string): Vector3;
  30171. /**
  30172. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  30173. * @param result defines the vector which will be filled with the Euler angles
  30174. * @param order is a reserved parameter and is ignore for now
  30175. * @returns the current unchanged quaternion
  30176. */
  30177. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  30178. /**
  30179. * Updates the given rotation matrix with the current quaternion values
  30180. * @param result defines the target matrix
  30181. * @returns the current unchanged quaternion
  30182. */
  30183. toRotationMatrix(result: Matrix): Quaternion;
  30184. /**
  30185. * Updates the current quaternion from the given rotation matrix values
  30186. * @param matrix defines the source matrix
  30187. * @returns the current updated quaternion
  30188. */
  30189. fromRotationMatrix(matrix: Matrix): Quaternion;
  30190. /**
  30191. * Creates a new quaternion from a rotation matrix
  30192. * @param matrix defines the source matrix
  30193. * @returns a new quaternion created from the given rotation matrix values
  30194. */
  30195. static FromRotationMatrix(matrix: Matrix): Quaternion;
  30196. /**
  30197. * Updates the given quaternion with the given rotation matrix values
  30198. * @param matrix defines the source matrix
  30199. * @param result defines the target quaternion
  30200. */
  30201. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  30202. /**
  30203. * Returns the dot product (float) between the quaternions "left" and "right"
  30204. * @param left defines the left operand
  30205. * @param right defines the right operand
  30206. * @returns the dot product
  30207. */
  30208. static Dot(left: Quaternion, right: Quaternion): number;
  30209. /**
  30210. * Checks if the two quaternions are close to each other
  30211. * @param quat0 defines the first quaternion to check
  30212. * @param quat1 defines the second quaternion to check
  30213. * @returns true if the two quaternions are close to each other
  30214. */
  30215. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  30216. /**
  30217. * Creates an empty quaternion
  30218. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  30219. */
  30220. static Zero(): Quaternion;
  30221. /**
  30222. * Inverse a given quaternion
  30223. * @param q defines the source quaternion
  30224. * @returns a new quaternion as the inverted current quaternion
  30225. */
  30226. static Inverse(q: Quaternion): Quaternion;
  30227. /**
  30228. * Creates an identity quaternion
  30229. * @returns the identity quaternion
  30230. */
  30231. static Identity(): Quaternion;
  30232. /**
  30233. * Gets a boolean indicating if the given quaternion is identity
  30234. * @param quaternion defines the quaternion to check
  30235. * @returns true if the quaternion is identity
  30236. */
  30237. static IsIdentity(quaternion: Quaternion): boolean;
  30238. /**
  30239. * Creates a quaternion from a rotation around an axis
  30240. * @param axis defines the axis to use
  30241. * @param angle defines the angle to use
  30242. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  30243. */
  30244. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  30245. /**
  30246. * Creates a rotation around an axis and stores it into the given quaternion
  30247. * @param axis defines the axis to use
  30248. * @param angle defines the angle to use
  30249. * @param result defines the target quaternion
  30250. * @returns the target quaternion
  30251. */
  30252. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  30253. /**
  30254. * Creates a new quaternion from data stored into an array
  30255. * @param array defines the data source
  30256. * @param offset defines the offset in the source array where the data starts
  30257. * @returns a new quaternion
  30258. */
  30259. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  30260. /**
  30261. * Creates a new quaternion from the given Euler float angles (y, x, z)
  30262. * @param yaw defines the rotation around Y axis
  30263. * @param pitch defines the rotation around X axis
  30264. * @param roll defines the rotation around Z axis
  30265. * @returns the new quaternion
  30266. */
  30267. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  30268. /**
  30269. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  30270. * @param yaw defines the rotation around Y axis
  30271. * @param pitch defines the rotation around X axis
  30272. * @param roll defines the rotation around Z axis
  30273. * @param result defines the target quaternion
  30274. */
  30275. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  30276. /**
  30277. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  30278. * @param alpha defines the rotation around first axis
  30279. * @param beta defines the rotation around second axis
  30280. * @param gamma defines the rotation around third axis
  30281. * @returns the new quaternion
  30282. */
  30283. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  30284. /**
  30285. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  30286. * @param alpha defines the rotation around first axis
  30287. * @param beta defines the rotation around second axis
  30288. * @param gamma defines the rotation around third axis
  30289. * @param result defines the target quaternion
  30290. */
  30291. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  30292. /**
  30293. * 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)
  30294. * @param axis1 defines the first axis
  30295. * @param axis2 defines the second axis
  30296. * @param axis3 defines the third axis
  30297. * @returns the new quaternion
  30298. */
  30299. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  30300. /**
  30301. * 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
  30302. * @param axis1 defines the first axis
  30303. * @param axis2 defines the second axis
  30304. * @param axis3 defines the third axis
  30305. * @param ref defines the target quaternion
  30306. */
  30307. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  30308. /**
  30309. * Interpolates between two quaternions
  30310. * @param left defines first quaternion
  30311. * @param right defines second quaternion
  30312. * @param amount defines the gradient to use
  30313. * @returns the new interpolated quaternion
  30314. */
  30315. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  30316. /**
  30317. * Interpolates between two quaternions and stores it into a target quaternion
  30318. * @param left defines first quaternion
  30319. * @param right defines second quaternion
  30320. * @param amount defines the gradient to use
  30321. * @param result defines the target quaternion
  30322. */
  30323. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  30324. /**
  30325. * Interpolate between two quaternions using Hermite interpolation
  30326. * @param value1 defines first quaternion
  30327. * @param tangent1 defines the incoming tangent
  30328. * @param value2 defines second quaternion
  30329. * @param tangent2 defines the outgoing tangent
  30330. * @param amount defines the target quaternion
  30331. * @returns the new interpolated quaternion
  30332. */
  30333. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  30334. }
  30335. /**
  30336. * Class used to store matrix data (4x4)
  30337. */
  30338. class Matrix {
  30339. private static _tempQuaternion;
  30340. private static _xAxis;
  30341. private static _yAxis;
  30342. private static _zAxis;
  30343. private static _updateFlagSeed;
  30344. private static _identityReadOnly;
  30345. private _isIdentity;
  30346. private _isIdentityDirty;
  30347. /**
  30348. * Gets the update flag of the matrix which is an unique number for the matrix.
  30349. * It will be incremented every time the matrix data change.
  30350. * You can use it to speed the comparison between two versions of the same matrix.
  30351. */
  30352. updateFlag: number;
  30353. /**
  30354. * Gets or sets the internal data of the matrix
  30355. */
  30356. m: Float32Array;
  30357. /** @hidden */
  30358. _markAsUpdated(): void;
  30359. /**
  30360. * Creates an empty matrix (filled with zeros)
  30361. */
  30362. constructor();
  30363. /**
  30364. * Check if the current matrix is indentity
  30365. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  30366. * @returns true is the matrix is the identity matrix
  30367. */
  30368. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  30369. /**
  30370. * Gets the determinant of the matrix
  30371. * @returns the matrix determinant
  30372. */
  30373. determinant(): number;
  30374. /**
  30375. * Returns the matrix as a Float32Array
  30376. * @returns the matrix underlying array
  30377. */
  30378. toArray(): Float32Array;
  30379. /**
  30380. * Returns the matrix as a Float32Array
  30381. * @returns the matrix underlying array.
  30382. */
  30383. asArray(): Float32Array;
  30384. /**
  30385. * Inverts the current matrix in place
  30386. * @returns the current inverted matrix
  30387. */
  30388. invert(): Matrix;
  30389. /**
  30390. * Sets all the matrix elements to zero
  30391. * @returns the current matrix
  30392. */
  30393. reset(): Matrix;
  30394. /**
  30395. * Adds the current matrix with a second one
  30396. * @param other defines the matrix to add
  30397. * @returns a new matrix as the addition of the current matrix and the given one
  30398. */
  30399. add(other: Matrix): Matrix;
  30400. /**
  30401. * Sets the given matrix "result" to the addition of the current matrix and the given one
  30402. * @param other defines the matrix to add
  30403. * @param result defines the target matrix
  30404. * @returns the current matrix
  30405. */
  30406. addToRef(other: Matrix, result: Matrix): Matrix;
  30407. /**
  30408. * Adds in place the given matrix to the current matrix
  30409. * @param other defines the second operand
  30410. * @returns the current updated matrix
  30411. */
  30412. addToSelf(other: Matrix): Matrix;
  30413. /**
  30414. * Sets the given matrix to the current inverted Matrix
  30415. * @param other defines the target matrix
  30416. * @returns the unmodified current matrix
  30417. */
  30418. invertToRef(other: Matrix): Matrix;
  30419. /**
  30420. * Inserts the translation vector (using 3 floats) in the current matrix
  30421. * @param x defines the 1st component of the translation
  30422. * @param y defines the 2nd component of the translation
  30423. * @param z defines the 3rd component of the translation
  30424. * @returns the current updated matrix
  30425. */
  30426. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  30427. /**
  30428. * Inserts the translation vector in the current matrix
  30429. * @param vector3 defines the translation to insert
  30430. * @returns the current updated matrix
  30431. */
  30432. setTranslation(vector3: Vector3): Matrix;
  30433. /**
  30434. * Gets the translation value of the current matrix
  30435. * @returns a new Vector3 as the extracted translation from the matrix
  30436. */
  30437. getTranslation(): Vector3;
  30438. /**
  30439. * Fill a Vector3 with the extracted translation from the matrix
  30440. * @param result defines the Vector3 where to store the translation
  30441. * @returns the current matrix
  30442. */
  30443. getTranslationToRef(result: Vector3): Matrix;
  30444. /**
  30445. * Remove rotation and scaling part from the matrix
  30446. * @returns the updated matrix
  30447. */
  30448. removeRotationAndScaling(): Matrix;
  30449. /**
  30450. * Multiply two matrices
  30451. * @param other defines the second operand
  30452. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  30453. */
  30454. multiply(other: Matrix): Matrix;
  30455. /**
  30456. * Copy the current matrix from the given one
  30457. * @param other defines the source matrix
  30458. * @returns the current updated matrix
  30459. */
  30460. copyFrom(other: Matrix): Matrix;
  30461. /**
  30462. * Populates the given array from the starting index with the current matrix values
  30463. * @param array defines the target array
  30464. * @param offset defines the offset in the target array where to start storing values
  30465. * @returns the current matrix
  30466. */
  30467. copyToArray(array: Float32Array, offset?: number): Matrix;
  30468. /**
  30469. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  30470. * @param other defines the second operand
  30471. * @param result defines the matrix where to store the multiplication
  30472. * @returns the current matrix
  30473. */
  30474. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  30475. /**
  30476. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  30477. * @param other defines the second operand
  30478. * @param result defines the array where to store the multiplication
  30479. * @param offset defines the offset in the target array where to start storing values
  30480. * @returns the current matrix
  30481. */
  30482. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  30483. /**
  30484. * Check equality between this matrix and a second one
  30485. * @param value defines the second matrix to compare
  30486. * @returns true is the current matrix and the given one values are strictly equal
  30487. */
  30488. equals(value: Matrix): boolean;
  30489. /**
  30490. * Clone the current matrix
  30491. * @returns a new matrix from the current matrix
  30492. */
  30493. clone(): Matrix;
  30494. /**
  30495. * Returns the name of the current matrix class
  30496. * @returns the string "Matrix"
  30497. */
  30498. getClassName(): string;
  30499. /**
  30500. * Gets the hash code of the current matrix
  30501. * @returns the hash code
  30502. */
  30503. getHashCode(): number;
  30504. /**
  30505. * Decomposes the current Matrix into a translation, rotation and scaling components
  30506. * @param scale defines the scale vector3 given as a reference to update
  30507. * @param rotation defines the rotation quaternion given as a reference to update
  30508. * @param translation defines the translation vector3 given as a reference to update
  30509. * @returns true if operation was successful
  30510. */
  30511. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  30512. /**
  30513. * Gets specific row of the matrix
  30514. * @param index defines the number of the row to get
  30515. * @returns the index-th row of the current matrix as a new Vector4
  30516. */
  30517. getRow(index: number): Nullable<Vector4>;
  30518. /**
  30519. * Sets the index-th row of the current matrix to the vector4 values
  30520. * @param index defines the number of the row to set
  30521. * @param row defines the target vector4
  30522. * @returns the updated current matrix
  30523. */
  30524. setRow(index: number, row: Vector4): Matrix;
  30525. /**
  30526. * Compute the transpose of the matrix
  30527. * @returns the new transposed matrix
  30528. */
  30529. transpose(): Matrix;
  30530. /**
  30531. * Compute the transpose of the matrix and store it in a given matrix
  30532. * @param result defines the target matrix
  30533. * @returns the current matrix
  30534. */
  30535. transposeToRef(result: Matrix): Matrix;
  30536. /**
  30537. * Sets the index-th row of the current matrix with the given 4 x float values
  30538. * @param index defines the row index
  30539. * @param x defines the x component to set
  30540. * @param y defines the y component to set
  30541. * @param z defines the z component to set
  30542. * @param w defines the w component to set
  30543. * @returns the updated current matrix
  30544. */
  30545. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  30546. /**
  30547. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  30548. * @param scale defines the scale factor
  30549. * @returns a new matrix
  30550. */
  30551. scale(scale: number): Matrix;
  30552. /**
  30553. * Scale the current matrix values by a factor to a given result matrix
  30554. * @param scale defines the scale factor
  30555. * @param result defines the matrix to store the result
  30556. * @returns the current matrix
  30557. */
  30558. scaleToRef(scale: number, result: Matrix): Matrix;
  30559. /**
  30560. * Scale the current matrix values by a factor and add the result to a given matrix
  30561. * @param scale defines the scale factor
  30562. * @param result defines the Matrix to store the result
  30563. * @returns the current matrix
  30564. */
  30565. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  30566. /**
  30567. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  30568. * @param ref matrix to store the result
  30569. */
  30570. toNormalMatrix(ref: Matrix): void;
  30571. /**
  30572. * Gets only rotation part of the current matrix
  30573. * @returns a new matrix sets to the extracted rotation matrix from the current one
  30574. */
  30575. getRotationMatrix(): Matrix;
  30576. /**
  30577. * Extracts the rotation matrix from the current one and sets it as the given "result"
  30578. * @param result defines the target matrix to store data to
  30579. * @returns the current matrix
  30580. */
  30581. getRotationMatrixToRef(result: Matrix): Matrix;
  30582. /**
  30583. * Creates a matrix from an array
  30584. * @param array defines the source array
  30585. * @param offset defines an offset in the source array
  30586. * @returns a new Matrix set from the starting index of the given array
  30587. */
  30588. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  30589. /**
  30590. * Copy the content of an array into a given matrix
  30591. * @param array defines the source array
  30592. * @param offset defines an offset in the source array
  30593. * @param result defines the target matrix
  30594. */
  30595. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  30596. /**
  30597. * Stores an array into a matrix after having multiplied each component by a given factor
  30598. * @param array defines the source array
  30599. * @param offset defines the offset in the source array
  30600. * @param scale defines the scaling factor
  30601. * @param result defines the target matrix
  30602. */
  30603. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  30604. /**
  30605. * Stores a list of values (16) inside a given matrix
  30606. * @param initialM11 defines 1st value of 1st row
  30607. * @param initialM12 defines 2nd value of 1st row
  30608. * @param initialM13 defines 3rd value of 1st row
  30609. * @param initialM14 defines 4th value of 1st row
  30610. * @param initialM21 defines 1st value of 2nd row
  30611. * @param initialM22 defines 2nd value of 2nd row
  30612. * @param initialM23 defines 3rd value of 2nd row
  30613. * @param initialM24 defines 4th value of 2nd row
  30614. * @param initialM31 defines 1st value of 3rd row
  30615. * @param initialM32 defines 2nd value of 3rd row
  30616. * @param initialM33 defines 3rd value of 3rd row
  30617. * @param initialM34 defines 4th value of 3rd row
  30618. * @param initialM41 defines 1st value of 4th row
  30619. * @param initialM42 defines 2nd value of 4th row
  30620. * @param initialM43 defines 3rd value of 4th row
  30621. * @param initialM44 defines 4th value of 4th row
  30622. * @param result defines the target matrix
  30623. */
  30624. 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;
  30625. /**
  30626. * Gets an identity matrix that must not be updated
  30627. */
  30628. static readonly IdentityReadOnly: Matrix;
  30629. /**
  30630. * Creates new matrix from a list of values (16)
  30631. * @param initialM11 defines 1st value of 1st row
  30632. * @param initialM12 defines 2nd value of 1st row
  30633. * @param initialM13 defines 3rd value of 1st row
  30634. * @param initialM14 defines 4th value of 1st row
  30635. * @param initialM21 defines 1st value of 2nd row
  30636. * @param initialM22 defines 2nd value of 2nd row
  30637. * @param initialM23 defines 3rd value of 2nd row
  30638. * @param initialM24 defines 4th value of 2nd row
  30639. * @param initialM31 defines 1st value of 3rd row
  30640. * @param initialM32 defines 2nd value of 3rd row
  30641. * @param initialM33 defines 3rd value of 3rd row
  30642. * @param initialM34 defines 4th value of 3rd row
  30643. * @param initialM41 defines 1st value of 4th row
  30644. * @param initialM42 defines 2nd value of 4th row
  30645. * @param initialM43 defines 3rd value of 4th row
  30646. * @param initialM44 defines 4th value of 4th row
  30647. * @returns the new matrix
  30648. */
  30649. 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;
  30650. /**
  30651. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  30652. * @param scale defines the scale vector3
  30653. * @param rotation defines the rotation quaternion
  30654. * @param translation defines the translation vector3
  30655. * @returns a new matrix
  30656. */
  30657. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  30658. /**
  30659. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  30660. * @param scale defines the scale vector3
  30661. * @param rotation defines the rotation quaternion
  30662. * @param translation defines the translation vector3
  30663. * @param result defines the target matrix
  30664. */
  30665. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  30666. /**
  30667. * Creates a new identity matrix
  30668. * @returns a new identity matrix
  30669. */
  30670. static Identity(): Matrix;
  30671. /**
  30672. * Creates a new identity matrix and stores the result in a given matrix
  30673. * @param result defines the target matrix
  30674. */
  30675. static IdentityToRef(result: Matrix): void;
  30676. /**
  30677. * Creates a new zero matrix
  30678. * @returns a new zero matrix
  30679. */
  30680. static Zero(): Matrix;
  30681. /**
  30682. * Creates a new rotation matrix for "angle" radians around the X axis
  30683. * @param angle defines the angle (in radians) to use
  30684. * @return the new matrix
  30685. */
  30686. static RotationX(angle: number): Matrix;
  30687. /**
  30688. * Creates a new matrix as the invert of a given matrix
  30689. * @param source defines the source matrix
  30690. * @returns the new matrix
  30691. */
  30692. static Invert(source: Matrix): Matrix;
  30693. /**
  30694. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  30695. * @param angle defines the angle (in radians) to use
  30696. * @param result defines the target matrix
  30697. */
  30698. static RotationXToRef(angle: number, result: Matrix): void;
  30699. /**
  30700. * Creates a new rotation matrix for "angle" radians around the Y axis
  30701. * @param angle defines the angle (in radians) to use
  30702. * @return the new matrix
  30703. */
  30704. static RotationY(angle: number): Matrix;
  30705. /**
  30706. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  30707. * @param angle defines the angle (in radians) to use
  30708. * @param result defines the target matrix
  30709. */
  30710. static RotationYToRef(angle: number, result: Matrix): void;
  30711. /**
  30712. * Creates a new rotation matrix for "angle" radians around the Z axis
  30713. * @param angle defines the angle (in radians) to use
  30714. * @return the new matrix
  30715. */
  30716. static RotationZ(angle: number): Matrix;
  30717. /**
  30718. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  30719. * @param angle defines the angle (in radians) to use
  30720. * @param result defines the target matrix
  30721. */
  30722. static RotationZToRef(angle: number, result: Matrix): void;
  30723. /**
  30724. * Creates a new rotation matrix for "angle" radians around the given axis
  30725. * @param axis defines the axis to use
  30726. * @param angle defines the angle (in radians) to use
  30727. * @return the new matrix
  30728. */
  30729. static RotationAxis(axis: Vector3, angle: number): Matrix;
  30730. /**
  30731. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  30732. * @param axis defines the axis to use
  30733. * @param angle defines the angle (in radians) to use
  30734. * @param result defines the target matrix
  30735. */
  30736. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  30737. /**
  30738. * Creates a rotation matrix
  30739. * @param yaw defines the yaw angle in radians (Y axis)
  30740. * @param pitch defines the pitch angle in radians (X axis)
  30741. * @param roll defines the roll angle in radians (X axis)
  30742. * @returns the new rotation matrix
  30743. */
  30744. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  30745. /**
  30746. * Creates a rotation matrix and stores it in a given matrix
  30747. * @param yaw defines the yaw angle in radians (Y axis)
  30748. * @param pitch defines the pitch angle in radians (X axis)
  30749. * @param roll defines the roll angle in radians (X axis)
  30750. * @param result defines the target matrix
  30751. */
  30752. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  30753. /**
  30754. * Creates a scaling matrix
  30755. * @param x defines the scale factor on X axis
  30756. * @param y defines the scale factor on Y axis
  30757. * @param z defines the scale factor on Z axis
  30758. * @returns the new matrix
  30759. */
  30760. static Scaling(x: number, y: number, z: number): Matrix;
  30761. /**
  30762. * Creates a scaling matrix and stores it in a given matrix
  30763. * @param x defines the scale factor on X axis
  30764. * @param y defines the scale factor on Y axis
  30765. * @param z defines the scale factor on Z axis
  30766. * @param result defines the target matrix
  30767. */
  30768. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  30769. /**
  30770. * Creates a translation matrix
  30771. * @param x defines the translation on X axis
  30772. * @param y defines the translation on Y axis
  30773. * @param z defines the translationon Z axis
  30774. * @returns the new matrix
  30775. */
  30776. static Translation(x: number, y: number, z: number): Matrix;
  30777. /**
  30778. * Creates a translation matrix and stores it in a given matrix
  30779. * @param x defines the translation on X axis
  30780. * @param y defines the translation on Y axis
  30781. * @param z defines the translationon Z axis
  30782. * @param result defines the target matrix
  30783. */
  30784. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  30785. /**
  30786. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  30787. * @param startValue defines the start value
  30788. * @param endValue defines the end value
  30789. * @param gradient defines the gradient factor
  30790. * @returns the new matrix
  30791. */
  30792. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  30793. /**
  30794. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  30795. * @param startValue defines the start value
  30796. * @param endValue defines the end value
  30797. * @param gradient defines the gradient factor
  30798. * @param result defines the Matrix object where to store data
  30799. */
  30800. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  30801. /**
  30802. * Builds a new matrix whose values are computed by:
  30803. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  30804. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  30805. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  30806. * @param startValue defines the first matrix
  30807. * @param endValue defines the second matrix
  30808. * @param gradient defines the gradient between the two matrices
  30809. * @returns the new matrix
  30810. */
  30811. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  30812. /**
  30813. * Update a matrix to values which are computed by:
  30814. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  30815. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  30816. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  30817. * @param startValue defines the first matrix
  30818. * @param endValue defines the second matrix
  30819. * @param gradient defines the gradient between the two matrices
  30820. * @param result defines the target matrix
  30821. */
  30822. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  30823. /**
  30824. * 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"
  30825. * This function works in left handed mode
  30826. * @param eye defines the final position of the entity
  30827. * @param target defines where the entity should look at
  30828. * @param up defines the up vector for the entity
  30829. * @returns the new matrix
  30830. */
  30831. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  30832. /**
  30833. * 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".
  30834. * This function works in left handed mode
  30835. * @param eye defines the final position of the entity
  30836. * @param target defines where the entity should look at
  30837. * @param up defines the up vector for the entity
  30838. * @param result defines the target matrix
  30839. */
  30840. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  30841. /**
  30842. * 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"
  30843. * This function works in right handed mode
  30844. * @param eye defines the final position of the entity
  30845. * @param target defines where the entity should look at
  30846. * @param up defines the up vector for the entity
  30847. * @returns the new matrix
  30848. */
  30849. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  30850. /**
  30851. * 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".
  30852. * This function works in right handed mode
  30853. * @param eye defines the final position of the entity
  30854. * @param target defines where the entity should look at
  30855. * @param up defines the up vector for the entity
  30856. * @param result defines the target matrix
  30857. */
  30858. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  30859. /**
  30860. * Create a left-handed orthographic projection matrix
  30861. * @param width defines the viewport width
  30862. * @param height defines the viewport height
  30863. * @param znear defines the near clip plane
  30864. * @param zfar defines the far clip plane
  30865. * @returns a new matrix as a left-handed orthographic projection matrix
  30866. */
  30867. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  30868. /**
  30869. * Store a left-handed orthographic projection to a given matrix
  30870. * @param width defines the viewport width
  30871. * @param height defines the viewport height
  30872. * @param znear defines the near clip plane
  30873. * @param zfar defines the far clip plane
  30874. * @param result defines the target matrix
  30875. */
  30876. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  30877. /**
  30878. * Create a left-handed orthographic projection matrix
  30879. * @param left defines the viewport left coordinate
  30880. * @param right defines the viewport right coordinate
  30881. * @param bottom defines the viewport bottom coordinate
  30882. * @param top defines the viewport top coordinate
  30883. * @param znear defines the near clip plane
  30884. * @param zfar defines the far clip plane
  30885. * @returns a new matrix as a left-handed orthographic projection matrix
  30886. */
  30887. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  30888. /**
  30889. * Stores a left-handed orthographic projection into a given matrix
  30890. * @param left defines the viewport left coordinate
  30891. * @param right defines the viewport right coordinate
  30892. * @param bottom defines the viewport bottom coordinate
  30893. * @param top defines the viewport top coordinate
  30894. * @param znear defines the near clip plane
  30895. * @param zfar defines the far clip plane
  30896. * @param result defines the target matrix
  30897. */
  30898. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  30899. /**
  30900. * Creates a right-handed orthographic projection matrix
  30901. * @param left defines the viewport left coordinate
  30902. * @param right defines the viewport right coordinate
  30903. * @param bottom defines the viewport bottom coordinate
  30904. * @param top defines the viewport top coordinate
  30905. * @param znear defines the near clip plane
  30906. * @param zfar defines the far clip plane
  30907. * @returns a new matrix as a right-handed orthographic projection matrix
  30908. */
  30909. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  30910. /**
  30911. * Stores a right-handed orthographic projection into a given matrix
  30912. * @param left defines the viewport left coordinate
  30913. * @param right defines the viewport right coordinate
  30914. * @param bottom defines the viewport bottom coordinate
  30915. * @param top defines the viewport top coordinate
  30916. * @param znear defines the near clip plane
  30917. * @param zfar defines the far clip plane
  30918. * @param result defines the target matrix
  30919. */
  30920. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  30921. /**
  30922. * Creates a left-handed perspective projection matrix
  30923. * @param width defines the viewport width
  30924. * @param height defines the viewport height
  30925. * @param znear defines the near clip plane
  30926. * @param zfar defines the far clip plane
  30927. * @returns a new matrix as a left-handed perspective projection matrix
  30928. */
  30929. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  30930. /**
  30931. * Creates a left-handed perspective projection matrix
  30932. * @param fov defines the horizontal field of view
  30933. * @param aspect defines the aspect ratio
  30934. * @param znear defines the near clip plane
  30935. * @param zfar defines the far clip plane
  30936. * @returns a new matrix as a left-handed perspective projection matrix
  30937. */
  30938. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  30939. /**
  30940. * Stores a left-handed perspective projection into a given matrix
  30941. * @param fov defines the horizontal field of view
  30942. * @param aspect defines the aspect ratio
  30943. * @param znear defines the near clip plane
  30944. * @param zfar defines the far clip plane
  30945. * @param result defines the target matrix
  30946. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  30947. */
  30948. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  30949. /**
  30950. * Creates a right-handed perspective projection matrix
  30951. * @param fov defines the horizontal field of view
  30952. * @param aspect defines the aspect ratio
  30953. * @param znear defines the near clip plane
  30954. * @param zfar defines the far clip plane
  30955. * @returns a new matrix as a right-handed perspective projection matrix
  30956. */
  30957. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  30958. /**
  30959. * Stores a right-handed perspective projection into a given matrix
  30960. * @param fov defines the horizontal field of view
  30961. * @param aspect defines the aspect ratio
  30962. * @param znear defines the near clip plane
  30963. * @param zfar defines the far clip plane
  30964. * @param result defines the target matrix
  30965. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  30966. */
  30967. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  30968. /**
  30969. * Stores a perspective projection for WebVR info a given matrix
  30970. * @param fov defines the field of view
  30971. * @param znear defines the near clip plane
  30972. * @param zfar defines the far clip plane
  30973. * @param result defines the target matrix
  30974. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  30975. */
  30976. static PerspectiveFovWebVRToRef(fov: {
  30977. upDegrees: number;
  30978. downDegrees: number;
  30979. leftDegrees: number;
  30980. rightDegrees: number;
  30981. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  30982. /**
  30983. * Computes a complete transformation matrix
  30984. * @param viewport defines the viewport to use
  30985. * @param world defines the world matrix
  30986. * @param view defines the view matrix
  30987. * @param projection defines the projection matrix
  30988. * @param zmin defines the near clip plane
  30989. * @param zmax defines the far clip plane
  30990. * @returns the transformation matrix
  30991. */
  30992. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  30993. /**
  30994. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  30995. * @param matrix defines the matrix to use
  30996. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  30997. */
  30998. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  30999. /**
  31000. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  31001. * @param matrix defines the matrix to use
  31002. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  31003. */
  31004. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  31005. /**
  31006. * Compute the transpose of a given matrix
  31007. * @param matrix defines the matrix to transpose
  31008. * @returns the new matrix
  31009. */
  31010. static Transpose(matrix: Matrix): Matrix;
  31011. /**
  31012. * Compute the transpose of a matrix and store it in a target matrix
  31013. * @param matrix defines the matrix to transpose
  31014. * @param result defines the target matrix
  31015. */
  31016. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  31017. /**
  31018. * Computes a reflection matrix from a plane
  31019. * @param plane defines the reflection plane
  31020. * @returns a new matrix
  31021. */
  31022. static Reflection(plane: Plane): Matrix;
  31023. /**
  31024. * Computes a reflection matrix from a plane
  31025. * @param plane defines the reflection plane
  31026. * @param result defines the target matrix
  31027. */
  31028. static ReflectionToRef(plane: Plane, result: Matrix): void;
  31029. /**
  31030. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  31031. * @param xaxis defines the value of the 1st axis
  31032. * @param yaxis defines the value of the 2nd axis
  31033. * @param zaxis defines the value of the 3rd axis
  31034. * @param result defines the target matrix
  31035. */
  31036. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  31037. /**
  31038. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  31039. * @param quat defines the quaternion to use
  31040. * @param result defines the target matrix
  31041. */
  31042. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  31043. }
  31044. class Plane {
  31045. normal: Vector3;
  31046. d: number;
  31047. /**
  31048. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  31049. */
  31050. constructor(a: number, b: number, c: number, d: number);
  31051. /**
  31052. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  31053. */
  31054. asArray(): number[];
  31055. /**
  31056. * Returns a new plane copied from the current Plane.
  31057. */
  31058. clone(): Plane;
  31059. /**
  31060. * Returns the string "Plane".
  31061. */
  31062. getClassName(): string;
  31063. /**
  31064. * Returns the Plane hash code.
  31065. */
  31066. getHashCode(): number;
  31067. /**
  31068. * Normalize the current Plane in place.
  31069. * Returns the updated Plane.
  31070. */
  31071. normalize(): Plane;
  31072. /**
  31073. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  31074. */
  31075. transform(transformation: Matrix): Plane;
  31076. /**
  31077. * Returns the dot product (float) of the point coordinates and the plane normal.
  31078. */
  31079. dotCoordinate(point: Vector3): number;
  31080. /**
  31081. * Updates the current Plane from the plane defined by the three given points.
  31082. * Returns the updated Plane.
  31083. */
  31084. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  31085. /**
  31086. * Boolean : True is the vector "direction" is the same side than the plane normal.
  31087. */
  31088. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  31089. /**
  31090. * Returns the signed distance (float) from the given point to the Plane.
  31091. */
  31092. signedDistanceTo(point: Vector3): number;
  31093. /**
  31094. * Returns a new Plane from the given array.
  31095. */
  31096. static FromArray(array: ArrayLike<number>): Plane;
  31097. /**
  31098. * Returns a new Plane defined by the three given points.
  31099. */
  31100. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  31101. /**
  31102. * Returns a new Plane the normal vector to this plane at the given origin point.
  31103. * Note : the vector "normal" is updated because normalized.
  31104. */
  31105. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  31106. /**
  31107. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  31108. */
  31109. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  31110. }
  31111. class Viewport {
  31112. x: number;
  31113. y: number;
  31114. width: number;
  31115. height: number;
  31116. /**
  31117. * Creates a Viewport object located at (x, y) and sized (width, height).
  31118. */
  31119. constructor(x: number, y: number, width: number, height: number);
  31120. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  31121. /**
  31122. * Returns a new Viewport copied from the current one.
  31123. */
  31124. clone(): Viewport;
  31125. }
  31126. class Frustum {
  31127. /**
  31128. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  31129. */
  31130. static GetPlanes(transform: Matrix): Plane[];
  31131. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  31132. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  31133. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  31134. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  31135. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  31136. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  31137. /**
  31138. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  31139. */
  31140. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  31141. }
  31142. /** Defines supported spaces */
  31143. enum Space {
  31144. /** Local (object) space */
  31145. LOCAL = 0,
  31146. /** World space */
  31147. WORLD = 1,
  31148. /** Bone space */
  31149. BONE = 2
  31150. }
  31151. /** Defines the 3 main axes */
  31152. class Axis {
  31153. /** X axis */
  31154. static X: Vector3;
  31155. /** Y axis */
  31156. static Y: Vector3;
  31157. /** Z axis */
  31158. static Z: Vector3;
  31159. }
  31160. class BezierCurve {
  31161. /**
  31162. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  31163. */
  31164. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  31165. }
  31166. /**
  31167. * Defines potential orientation for back face culling
  31168. */
  31169. enum Orientation {
  31170. /**
  31171. * Clockwise
  31172. */
  31173. CW = 0,
  31174. /** Counter clockwise */
  31175. CCW = 1
  31176. }
  31177. /**
  31178. * Defines angle representation
  31179. */
  31180. class Angle {
  31181. private _radians;
  31182. /**
  31183. * Creates an Angle object of "radians" radians (float).
  31184. */
  31185. constructor(radians: number);
  31186. /**
  31187. * Get value in degrees
  31188. * @returns the Angle value in degrees (float)
  31189. */
  31190. degrees(): number;
  31191. /**
  31192. * Get value in radians
  31193. * @returns the Angle value in radians (float)
  31194. */
  31195. radians(): number;
  31196. /**
  31197. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  31198. * @param a defines first vector
  31199. * @param b defines second vector
  31200. * @returns a new Angle
  31201. */
  31202. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  31203. /**
  31204. * Gets a new Angle object from the given float in radians
  31205. * @param radians defines the angle value in radians
  31206. * @returns a new Angle
  31207. */
  31208. static FromRadians(radians: number): Angle;
  31209. /**
  31210. * Gets a new Angle object from the given float in degrees
  31211. * @param degrees defines the angle value in degrees
  31212. * @returns a new Angle
  31213. */
  31214. static FromDegrees(degrees: number): Angle;
  31215. }
  31216. class Arc2 {
  31217. startPoint: Vector2;
  31218. midPoint: Vector2;
  31219. endPoint: Vector2;
  31220. centerPoint: Vector2;
  31221. radius: number;
  31222. angle: Angle;
  31223. startAngle: Angle;
  31224. orientation: Orientation;
  31225. /**
  31226. * Creates an Arc object from the three given points : start, middle and end.
  31227. */
  31228. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  31229. }
  31230. class Path2 {
  31231. private _points;
  31232. private _length;
  31233. closed: boolean;
  31234. /**
  31235. * Creates a Path2 object from the starting 2D coordinates x and y.
  31236. */
  31237. constructor(x: number, y: number);
  31238. /**
  31239. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  31240. * Returns the updated Path2.
  31241. */
  31242. addLineTo(x: number, y: number): Path2;
  31243. /**
  31244. * 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.
  31245. * Returns the updated Path2.
  31246. */
  31247. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  31248. /**
  31249. * Closes the Path2.
  31250. * Returns the Path2.
  31251. */
  31252. close(): Path2;
  31253. /**
  31254. * Returns the Path2 total length (float).
  31255. */
  31256. length(): number;
  31257. /**
  31258. * Returns the Path2 internal array of points.
  31259. */
  31260. getPoints(): Vector2[];
  31261. /**
  31262. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  31263. */
  31264. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  31265. /**
  31266. * Returns a new Path2 starting at the coordinates (x, y).
  31267. */
  31268. static StartingAt(x: number, y: number): Path2;
  31269. }
  31270. class Path3D {
  31271. path: Vector3[];
  31272. private _curve;
  31273. private _distances;
  31274. private _tangents;
  31275. private _normals;
  31276. private _binormals;
  31277. private _raw;
  31278. /**
  31279. * new Path3D(path, normal, raw)
  31280. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  31281. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  31282. * path : an array of Vector3, the curve axis of the Path3D
  31283. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  31284. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  31285. */
  31286. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  31287. /**
  31288. * Returns the Path3D array of successive Vector3 designing its curve.
  31289. */
  31290. getCurve(): Vector3[];
  31291. /**
  31292. * Returns an array populated with tangent vectors on each Path3D curve point.
  31293. */
  31294. getTangents(): Vector3[];
  31295. /**
  31296. * Returns an array populated with normal vectors on each Path3D curve point.
  31297. */
  31298. getNormals(): Vector3[];
  31299. /**
  31300. * Returns an array populated with binormal vectors on each Path3D curve point.
  31301. */
  31302. getBinormals(): Vector3[];
  31303. /**
  31304. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  31305. */
  31306. getDistances(): number[];
  31307. /**
  31308. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  31309. * Returns the same object updated.
  31310. */
  31311. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  31312. private _compute;
  31313. private _getFirstNonNullVector;
  31314. private _getLastNonNullVector;
  31315. private _normalVector;
  31316. }
  31317. class Curve3 {
  31318. private _points;
  31319. private _length;
  31320. /**
  31321. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  31322. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  31323. * @param v1 (Vector3) the control point
  31324. * @param v2 (Vector3) the end point of the Quadratic Bezier
  31325. * @param nbPoints (integer) the wanted number of points in the curve
  31326. */
  31327. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  31328. /**
  31329. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  31330. * @param v0 (Vector3) the origin point of the Cubic Bezier
  31331. * @param v1 (Vector3) the first control point
  31332. * @param v2 (Vector3) the second control point
  31333. * @param v3 (Vector3) the end point of the Cubic Bezier
  31334. * @param nbPoints (integer) the wanted number of points in the curve
  31335. */
  31336. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  31337. /**
  31338. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  31339. * @param p1 (Vector3) the origin point of the Hermite Spline
  31340. * @param t1 (Vector3) the tangent vector at the origin point
  31341. * @param p2 (Vector3) the end point of the Hermite Spline
  31342. * @param t2 (Vector3) the tangent vector at the end point
  31343. * @param nbPoints (integer) the wanted number of points in the curve
  31344. */
  31345. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  31346. /**
  31347. * Returns a Curve3 object along a CatmullRom Spline curve :
  31348. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  31349. * @param nbPoints (integer) the wanted number of points between each curve control points
  31350. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  31351. */
  31352. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  31353. /**
  31354. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  31355. * A Curve3 is designed from a series of successive Vector3.
  31356. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  31357. */
  31358. constructor(points: Vector3[]);
  31359. /**
  31360. * Returns the Curve3 stored array of successive Vector3
  31361. */
  31362. getPoints(): Vector3[];
  31363. /**
  31364. * Returns the computed length (float) of the curve.
  31365. */
  31366. length(): number;
  31367. /**
  31368. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  31369. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  31370. * curveA and curveB keep unchanged.
  31371. */
  31372. continue(curve: Curve3): Curve3;
  31373. private _computeLength;
  31374. }
  31375. class PositionNormalVertex {
  31376. position: Vector3;
  31377. normal: Vector3;
  31378. constructor(position?: Vector3, normal?: Vector3);
  31379. clone(): PositionNormalVertex;
  31380. }
  31381. class PositionNormalTextureVertex {
  31382. position: Vector3;
  31383. normal: Vector3;
  31384. uv: Vector2;
  31385. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  31386. clone(): PositionNormalTextureVertex;
  31387. }
  31388. class Tmp {
  31389. static Color3: Color3[];
  31390. static Color4: Color4[];
  31391. static Vector2: Vector2[];
  31392. static Vector3: Vector3[];
  31393. static Vector4: Vector4[];
  31394. static Quaternion: Quaternion[];
  31395. static Matrix: Matrix[];
  31396. }
  31397. }
  31398. declare module BABYLON {
  31399. /**
  31400. * Class representing spherical polynomial coefficients to the 3rd degree
  31401. */
  31402. class SphericalPolynomial {
  31403. /**
  31404. * The x coefficients of the spherical polynomial
  31405. */
  31406. x: Vector3;
  31407. /**
  31408. * The y coefficients of the spherical polynomial
  31409. */
  31410. y: Vector3;
  31411. /**
  31412. * The z coefficients of the spherical polynomial
  31413. */
  31414. z: Vector3;
  31415. /**
  31416. * The xx coefficients of the spherical polynomial
  31417. */
  31418. xx: Vector3;
  31419. /**
  31420. * The yy coefficients of the spherical polynomial
  31421. */
  31422. yy: Vector3;
  31423. /**
  31424. * The zz coefficients of the spherical polynomial
  31425. */
  31426. zz: Vector3;
  31427. /**
  31428. * The xy coefficients of the spherical polynomial
  31429. */
  31430. xy: Vector3;
  31431. /**
  31432. * The yz coefficients of the spherical polynomial
  31433. */
  31434. yz: Vector3;
  31435. /**
  31436. * The zx coefficients of the spherical polynomial
  31437. */
  31438. zx: Vector3;
  31439. /**
  31440. * Adds an ambient color to the spherical polynomial
  31441. * @param color the color to add
  31442. */
  31443. addAmbient(color: Color3): void;
  31444. /**
  31445. * Scales the spherical polynomial by the given amount
  31446. * @param scale the amount to scale
  31447. */
  31448. scale(scale: number): void;
  31449. /**
  31450. * Gets the spherical polynomial from harmonics
  31451. * @param harmonics the spherical harmonics
  31452. * @returns the spherical polynomial
  31453. */
  31454. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31455. /**
  31456. * Constructs a spherical polynomial from an array.
  31457. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31458. * @returns the spherical polynomial
  31459. */
  31460. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31461. }
  31462. /**
  31463. * Class representing spherical harmonics coefficients to the 3rd degree
  31464. */
  31465. class SphericalHarmonics {
  31466. /**
  31467. * The l0,0 coefficients of the spherical harmonics
  31468. */
  31469. l00: Vector3;
  31470. /**
  31471. * The l1,-1 coefficients of the spherical harmonics
  31472. */
  31473. l1_1: Vector3;
  31474. /**
  31475. * The l1,0 coefficients of the spherical harmonics
  31476. */
  31477. l10: Vector3;
  31478. /**
  31479. * The l1,1 coefficients of the spherical harmonics
  31480. */
  31481. l11: Vector3;
  31482. /**
  31483. * The l2,-2 coefficients of the spherical harmonics
  31484. */
  31485. l2_2: Vector3;
  31486. /**
  31487. * The l2,-1 coefficients of the spherical harmonics
  31488. */
  31489. l2_1: Vector3;
  31490. /**
  31491. * The l2,0 coefficients of the spherical harmonics
  31492. */
  31493. l20: Vector3;
  31494. /**
  31495. * The l2,1 coefficients of the spherical harmonics
  31496. */
  31497. l21: Vector3;
  31498. /**
  31499. * The l2,2 coefficients of the spherical harmonics
  31500. */
  31501. lL22: Vector3;
  31502. /**
  31503. * Adds a light to the spherical harmonics
  31504. * @param direction the direction of the light
  31505. * @param color the color of the light
  31506. * @param deltaSolidAngle the delta solid angle of the light
  31507. */
  31508. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31509. /**
  31510. * Scales the spherical harmonics by the given amount
  31511. * @param scale the amount to scale
  31512. */
  31513. scale(scale: number): void;
  31514. /**
  31515. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31516. *
  31517. * ```
  31518. * E_lm = A_l * L_lm
  31519. * ```
  31520. *
  31521. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31522. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31523. * the scaling factors are given in equation 9.
  31524. */
  31525. convertIncidentRadianceToIrradiance(): void;
  31526. /**
  31527. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31528. *
  31529. * ```
  31530. * L = (1/pi) * E * rho
  31531. * ```
  31532. *
  31533. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31534. */
  31535. convertIrradianceToLambertianRadiance(): void;
  31536. /**
  31537. * Gets the spherical harmonics from polynomial
  31538. * @param polynomial the spherical polynomial
  31539. * @returns the spherical harmonics
  31540. */
  31541. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31542. /**
  31543. * Constructs a spherical harmonics from an array.
  31544. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31545. * @returns the spherical harmonics
  31546. */
  31547. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31548. }
  31549. }
  31550. declare module BABYLON {
  31551. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  31552. readonly name: string;
  31553. private _zoomStopsAnimation;
  31554. private _idleRotationSpeed;
  31555. private _idleRotationWaitTime;
  31556. private _idleRotationSpinupTime;
  31557. /**
  31558. * Sets the flag that indicates if user zooming should stop animation.
  31559. */
  31560. /**
  31561. * Gets the flag that indicates if user zooming should stop animation.
  31562. */
  31563. zoomStopsAnimation: boolean;
  31564. /**
  31565. * Sets the default speed at which the camera rotates around the model.
  31566. */
  31567. /**
  31568. * Gets the default speed at which the camera rotates around the model.
  31569. */
  31570. idleRotationSpeed: number;
  31571. /**
  31572. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  31573. */
  31574. /**
  31575. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  31576. */
  31577. idleRotationWaitTime: number;
  31578. /**
  31579. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  31580. */
  31581. /**
  31582. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  31583. */
  31584. idleRotationSpinupTime: number;
  31585. /**
  31586. * Gets a value indicating if the camera is currently rotating because of this behavior
  31587. */
  31588. readonly rotationInProgress: boolean;
  31589. private _onPrePointerObservableObserver;
  31590. private _onAfterCheckInputsObserver;
  31591. private _attachedCamera;
  31592. private _isPointerDown;
  31593. private _lastFrameTime;
  31594. private _lastInteractionTime;
  31595. private _cameraRotationSpeed;
  31596. init(): void;
  31597. attach(camera: ArcRotateCamera): void;
  31598. detach(): void;
  31599. /**
  31600. * Returns true if user is scrolling.
  31601. * @return true if user is scrolling.
  31602. */
  31603. private _userIsZooming;
  31604. private _lastFrameRadius;
  31605. private _shouldAnimationStopForInteraction;
  31606. /**
  31607. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  31608. */
  31609. private _applyUserInteraction;
  31610. private _userIsMoving;
  31611. }
  31612. }
  31613. declare module BABYLON {
  31614. /**
  31615. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  31616. */
  31617. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  31618. readonly name: string;
  31619. /**
  31620. * The easing function used by animations
  31621. */
  31622. static EasingFunction: BackEase;
  31623. /**
  31624. * The easing mode used by animations
  31625. */
  31626. static EasingMode: number;
  31627. /**
  31628. * The duration of the animation, in milliseconds
  31629. */
  31630. transitionDuration: number;
  31631. /**
  31632. * Length of the distance animated by the transition when lower radius is reached
  31633. */
  31634. lowerRadiusTransitionRange: number;
  31635. /**
  31636. * Length of the distance animated by the transition when upper radius is reached
  31637. */
  31638. upperRadiusTransitionRange: number;
  31639. private _autoTransitionRange;
  31640. /**
  31641. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  31642. */
  31643. /**
  31644. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  31645. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  31646. */
  31647. autoTransitionRange: boolean;
  31648. private _attachedCamera;
  31649. private _onAfterCheckInputsObserver;
  31650. private _onMeshTargetChangedObserver;
  31651. init(): void;
  31652. attach(camera: ArcRotateCamera): void;
  31653. detach(): void;
  31654. private _radiusIsAnimating;
  31655. private _radiusBounceTransition;
  31656. private _animatables;
  31657. private _cachedWheelPrecision;
  31658. /**
  31659. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  31660. * @param radiusLimit The limit to check against.
  31661. * @return Bool to indicate if at limit.
  31662. */
  31663. private _isRadiusAtLimit;
  31664. /**
  31665. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  31666. * @param radiusDelta The delta by which to animate to. Can be negative.
  31667. */
  31668. private _applyBoundRadiusAnimation;
  31669. /**
  31670. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  31671. */
  31672. protected _clearAnimationLocks(): void;
  31673. /**
  31674. * Stops and removes all animations that have been applied to the camera
  31675. */
  31676. stopAllAnimations(): void;
  31677. }
  31678. }
  31679. declare module BABYLON {
  31680. class FramingBehavior implements Behavior<ArcRotateCamera> {
  31681. readonly name: string;
  31682. private _mode;
  31683. private _radiusScale;
  31684. private _positionScale;
  31685. private _defaultElevation;
  31686. private _elevationReturnTime;
  31687. private _elevationReturnWaitTime;
  31688. private _zoomStopsAnimation;
  31689. private _framingTime;
  31690. /**
  31691. * The easing function used by animations
  31692. */
  31693. static EasingFunction: ExponentialEase;
  31694. /**
  31695. * The easing mode used by animations
  31696. */
  31697. static EasingMode: number;
  31698. /**
  31699. * Sets the current mode used by the behavior
  31700. */
  31701. /**
  31702. * Gets current mode used by the behavior.
  31703. */
  31704. mode: number;
  31705. /**
  31706. * Sets the scale applied to the radius (1 by default)
  31707. */
  31708. /**
  31709. * Gets the scale applied to the radius
  31710. */
  31711. radiusScale: number;
  31712. /**
  31713. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  31714. */
  31715. /**
  31716. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  31717. */
  31718. positionScale: number;
  31719. /**
  31720. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  31721. * behaviour is triggered, in radians.
  31722. */
  31723. /**
  31724. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  31725. * behaviour is triggered, in radians.
  31726. */
  31727. defaultElevation: number;
  31728. /**
  31729. * Sets the time (in milliseconds) taken to return to the default beta position.
  31730. * Negative value indicates camera should not return to default.
  31731. */
  31732. /**
  31733. * Gets the time (in milliseconds) taken to return to the default beta position.
  31734. * Negative value indicates camera should not return to default.
  31735. */
  31736. elevationReturnTime: number;
  31737. /**
  31738. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  31739. */
  31740. /**
  31741. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  31742. */
  31743. elevationReturnWaitTime: number;
  31744. /**
  31745. * Sets the flag that indicates if user zooming should stop animation.
  31746. */
  31747. /**
  31748. * Gets the flag that indicates if user zooming should stop animation.
  31749. */
  31750. zoomStopsAnimation: boolean;
  31751. /**
  31752. * Sets the transition time when framing the mesh, in milliseconds
  31753. */
  31754. /**
  31755. * Gets the transition time when framing the mesh, in milliseconds
  31756. */
  31757. framingTime: number;
  31758. private _onPrePointerObservableObserver;
  31759. private _onAfterCheckInputsObserver;
  31760. private _onMeshTargetChangedObserver;
  31761. private _attachedCamera;
  31762. private _isPointerDown;
  31763. private _lastInteractionTime;
  31764. init(): void;
  31765. attach(camera: ArcRotateCamera): void;
  31766. detach(): void;
  31767. private _animatables;
  31768. private _betaIsAnimating;
  31769. private _betaTransition;
  31770. private _radiusTransition;
  31771. private _vectorTransition;
  31772. /**
  31773. * Targets the given mesh and updates zoom level accordingly.
  31774. * @param mesh The mesh to target.
  31775. * @param radius Optional. If a cached radius position already exists, overrides default.
  31776. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31777. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31778. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31779. */
  31780. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31781. /**
  31782. * Targets the given mesh with its children and updates zoom level accordingly.
  31783. * @param mesh The mesh to target.
  31784. * @param radius Optional. If a cached radius position already exists, overrides default.
  31785. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31786. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31787. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31788. */
  31789. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31790. /**
  31791. * Targets the given meshes with their children and updates zoom level accordingly.
  31792. * @param meshes The mesh to target.
  31793. * @param radius Optional. If a cached radius position already exists, overrides default.
  31794. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31795. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31796. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31797. */
  31798. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31799. /**
  31800. * Targets the given mesh and updates zoom level accordingly.
  31801. * @param mesh The mesh to target.
  31802. * @param radius Optional. If a cached radius position already exists, overrides default.
  31803. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31804. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31805. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31806. */
  31807. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31808. /**
  31809. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  31810. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  31811. * frustum width.
  31812. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  31813. * to fully enclose the mesh in the viewing frustum.
  31814. */
  31815. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  31816. /**
  31817. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  31818. * is automatically returned to its default position (expected to be above ground plane).
  31819. */
  31820. private _maintainCameraAboveGround;
  31821. /**
  31822. * Returns the frustum slope based on the canvas ratio and camera FOV
  31823. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  31824. */
  31825. private _getFrustumSlope;
  31826. /**
  31827. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  31828. */
  31829. private _clearAnimationLocks;
  31830. /**
  31831. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  31832. */
  31833. private _applyUserInteraction;
  31834. /**
  31835. * Stops and removes all animations that have been applied to the camera
  31836. */
  31837. stopAllAnimations(): void;
  31838. /**
  31839. * Gets a value indicating if the user is moving the camera
  31840. */
  31841. readonly isUserIsMoving: boolean;
  31842. /**
  31843. * The camera can move all the way towards the mesh.
  31844. */
  31845. static IgnoreBoundsSizeMode: number;
  31846. /**
  31847. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  31848. */
  31849. static FitFrustumSidesMode: number;
  31850. }
  31851. }
  31852. declare module BABYLON {
  31853. /**
  31854. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  31855. */
  31856. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  31857. private ui;
  31858. /**
  31859. * The name of the behavior
  31860. */
  31861. name: string;
  31862. /**
  31863. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  31864. */
  31865. distanceAwayFromFace: number;
  31866. /**
  31867. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  31868. */
  31869. distanceAwayFromBottomOfFace: number;
  31870. private _faceVectors;
  31871. private _target;
  31872. private _scene;
  31873. private _onRenderObserver;
  31874. private _tmpMatrix;
  31875. private _tmpVector;
  31876. /**
  31877. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  31878. * @param ui The transform node that should be attched to the mesh
  31879. */
  31880. constructor(ui: BABYLON.TransformNode);
  31881. /**
  31882. * Initializes the behavior
  31883. */
  31884. init(): void;
  31885. private _closestFace;
  31886. private _zeroVector;
  31887. private _lookAtTmpMatrix;
  31888. private _lookAtToRef;
  31889. /**
  31890. * Attaches the AttachToBoxBehavior to the passed in mesh
  31891. * @param target The mesh that the specified node will be attached to
  31892. */
  31893. attach(target: BABYLON.Mesh): void;
  31894. /**
  31895. * Detaches the behavior from the mesh
  31896. */
  31897. detach(): void;
  31898. }
  31899. }
  31900. declare module BABYLON {
  31901. /**
  31902. * A behavior that when attached to a mesh will allow the mesh to be scaled
  31903. */
  31904. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  31905. private _dragBehaviorA;
  31906. private _dragBehaviorB;
  31907. private _startDistance;
  31908. private _initialScale;
  31909. private _targetScale;
  31910. private _ownerNode;
  31911. private _sceneRenderObserver;
  31912. constructor();
  31913. /**
  31914. * The name of the behavior
  31915. */
  31916. readonly name: string;
  31917. /**
  31918. * Initializes the behavior
  31919. */
  31920. init(): void;
  31921. private _getCurrentDistance;
  31922. /**
  31923. * Attaches the scale behavior the passed in mesh
  31924. * @param ownerNode The mesh that will be scaled around once attached
  31925. */
  31926. attach(ownerNode: Mesh): void;
  31927. /**
  31928. * Detaches the behavior from the mesh
  31929. */
  31930. detach(): void;
  31931. }
  31932. }
  31933. declare module BABYLON {
  31934. /**
  31935. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  31936. */
  31937. class PointerDragBehavior implements Behavior<Mesh> {
  31938. private _attachedNode;
  31939. private _dragPlane;
  31940. private _scene;
  31941. private _pointerObserver;
  31942. private _beforeRenderObserver;
  31943. private static _planeScene;
  31944. /**
  31945. * 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)
  31946. */
  31947. maxDragAngle: number;
  31948. /**
  31949. * @hidden
  31950. */
  31951. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  31952. /**
  31953. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  31954. */
  31955. currentDraggingPointerID: number;
  31956. /**
  31957. * The last position where the pointer hit the drag plane in world space
  31958. */
  31959. lastDragPosition: Vector3;
  31960. /**
  31961. * If the behavior is currently in a dragging state
  31962. */
  31963. dragging: boolean;
  31964. /**
  31965. * 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)
  31966. */
  31967. dragDeltaRatio: number;
  31968. /**
  31969. * If the drag plane orientation should be updated during the dragging (Default: true)
  31970. */
  31971. updateDragPlane: boolean;
  31972. private _debugMode;
  31973. private _moving;
  31974. /**
  31975. * Fires each time the attached mesh is dragged with the pointer
  31976. * * delta between last drag position and current drag position in world space
  31977. * * dragDistance along the drag axis
  31978. * * dragPlaneNormal normal of the current drag plane used during the drag
  31979. * * dragPlanePoint in world space where the drag intersects the drag plane
  31980. */
  31981. onDragObservable: Observable<{
  31982. delta: Vector3;
  31983. dragPlanePoint: Vector3;
  31984. dragPlaneNormal: Vector3;
  31985. dragDistance: number;
  31986. pointerId: number;
  31987. }>;
  31988. /**
  31989. * Fires each time a drag begins (eg. mouse down on mesh)
  31990. */
  31991. onDragStartObservable: Observable<{
  31992. dragPlanePoint: Vector3;
  31993. pointerId: number;
  31994. }>;
  31995. /**
  31996. * Fires each time a drag ends (eg. mouse release after drag)
  31997. */
  31998. onDragEndObservable: Observable<{
  31999. dragPlanePoint: Vector3;
  32000. pointerId: number;
  32001. }>;
  32002. /**
  32003. * If the attached mesh should be moved when dragged
  32004. */
  32005. moveAttached: boolean;
  32006. /**
  32007. * If the drag behavior will react to drag events (Default: true)
  32008. */
  32009. enabled: boolean;
  32010. /**
  32011. * If camera controls should be detached during the drag
  32012. */
  32013. detachCameraControls: boolean;
  32014. /**
  32015. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  32016. */
  32017. useObjectOrienationForDragging: boolean;
  32018. private _options;
  32019. /**
  32020. * Creates a pointer drag behavior that can be attached to a mesh
  32021. * @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)
  32022. */
  32023. constructor(options?: {
  32024. dragAxis?: Vector3;
  32025. dragPlaneNormal?: Vector3;
  32026. });
  32027. /**
  32028. * The name of the behavior
  32029. */
  32030. readonly name: string;
  32031. /**
  32032. * Initializes the behavior
  32033. */
  32034. init(): void;
  32035. private _tmpVector;
  32036. private _alternatePickedPoint;
  32037. private _worldDragAxis;
  32038. /**
  32039. * Attaches the drag behavior the passed in mesh
  32040. * @param ownerNode The mesh that will be dragged around once attached
  32041. */
  32042. attach(ownerNode: Mesh): void;
  32043. releaseDrag(): void;
  32044. private _pickWithRayOnDragPlane;
  32045. private _pointA;
  32046. private _pointB;
  32047. private _pointC;
  32048. private _lineA;
  32049. private _lineB;
  32050. private _localAxis;
  32051. private _lookAt;
  32052. private _updateDragPlanePosition;
  32053. /**
  32054. * Detaches the behavior from the mesh
  32055. */
  32056. detach(): void;
  32057. }
  32058. }
  32059. declare module BABYLON {
  32060. /**
  32061. * 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
  32062. */
  32063. class SixDofDragBehavior implements Behavior<Mesh> {
  32064. private static _virtualScene;
  32065. private _ownerNode;
  32066. private _sceneRenderObserver;
  32067. private _scene;
  32068. private _targetPosition;
  32069. private _virtualOriginMesh;
  32070. private _virtualDragMesh;
  32071. private _pointerObserver;
  32072. private _moving;
  32073. private _startingOrientation;
  32074. /**
  32075. * 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)
  32076. */
  32077. private zDragFactor;
  32078. /**
  32079. * If the behavior is currently in a dragging state
  32080. */
  32081. dragging: boolean;
  32082. /**
  32083. * 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)
  32084. */
  32085. dragDeltaRatio: number;
  32086. /**
  32087. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  32088. */
  32089. currentDraggingPointerID: number;
  32090. /**
  32091. * If camera controls should be detached during the drag
  32092. */
  32093. detachCameraControls: boolean;
  32094. constructor();
  32095. /**
  32096. * The name of the behavior
  32097. */
  32098. readonly name: string;
  32099. /**
  32100. * Initializes the behavior
  32101. */
  32102. init(): void;
  32103. /**
  32104. * Attaches the scale behavior the passed in mesh
  32105. * @param ownerNode The mesh that will be scaled around once attached
  32106. */
  32107. attach(ownerNode: Mesh): void;
  32108. /**
  32109. * Detaches the behavior from the mesh
  32110. */
  32111. detach(): void;
  32112. }
  32113. }
  32114. declare module BABYLON {
  32115. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  32116. camera: ArcRotateCamera;
  32117. gamepad: Nullable<Gamepad>;
  32118. private _onGamepadConnectedObserver;
  32119. private _onGamepadDisconnectedObserver;
  32120. gamepadRotationSensibility: number;
  32121. gamepadMoveSensibility: number;
  32122. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32123. detachControl(element: Nullable<HTMLElement>): void;
  32124. checkInputs(): void;
  32125. getClassName(): string;
  32126. getSimpleName(): string;
  32127. }
  32128. }
  32129. declare module BABYLON {
  32130. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  32131. camera: ArcRotateCamera;
  32132. private _keys;
  32133. keysUp: number[];
  32134. keysDown: number[];
  32135. keysLeft: number[];
  32136. keysRight: number[];
  32137. keysReset: number[];
  32138. panningSensibility: number;
  32139. zoomingSensibility: number;
  32140. useAltToZoom: boolean;
  32141. private _ctrlPressed;
  32142. private _altPressed;
  32143. private _onCanvasBlurObserver;
  32144. private _onKeyboardObserver;
  32145. private _engine;
  32146. private _scene;
  32147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32148. detachControl(element: Nullable<HTMLElement>): void;
  32149. checkInputs(): void;
  32150. getClassName(): string;
  32151. getSimpleName(): string;
  32152. }
  32153. }
  32154. declare module BABYLON {
  32155. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  32156. camera: ArcRotateCamera;
  32157. private _wheel;
  32158. private _observer;
  32159. wheelPrecision: number;
  32160. /**
  32161. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  32162. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  32163. */
  32164. wheelDeltaPercentage: number;
  32165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32166. detachControl(element: Nullable<HTMLElement>): void;
  32167. getClassName(): string;
  32168. getSimpleName(): string;
  32169. }
  32170. }
  32171. declare module BABYLON {
  32172. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  32173. camera: ArcRotateCamera;
  32174. buttons: number[];
  32175. angularSensibilityX: number;
  32176. angularSensibilityY: number;
  32177. pinchPrecision: number;
  32178. /**
  32179. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  32180. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  32181. */
  32182. pinchDeltaPercentage: number;
  32183. panningSensibility: number;
  32184. multiTouchPanning: boolean;
  32185. multiTouchPanAndZoom: boolean;
  32186. private _isPanClick;
  32187. pinchInwards: boolean;
  32188. private _pointerInput;
  32189. private _observer;
  32190. private _onMouseMove;
  32191. private _onGestureStart;
  32192. private _onGesture;
  32193. private _MSGestureHandler;
  32194. private _onLostFocus;
  32195. private _onContextMenu;
  32196. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32197. detachControl(element: Nullable<HTMLElement>): void;
  32198. getClassName(): string;
  32199. getSimpleName(): string;
  32200. }
  32201. }
  32202. declare module BABYLON {
  32203. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  32204. camera: ArcRotateCamera;
  32205. alphaCorrection: number;
  32206. betaCorrection: number;
  32207. gammaCorrection: number;
  32208. private _alpha;
  32209. private _gamma;
  32210. private _dirty;
  32211. private _deviceOrientationHandler;
  32212. constructor();
  32213. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32214. /** @hidden */
  32215. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  32216. checkInputs(): void;
  32217. detachControl(element: Nullable<HTMLElement>): void;
  32218. getClassName(): string;
  32219. getSimpleName(): string;
  32220. }
  32221. }
  32222. declare module BABYLON {
  32223. /**
  32224. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  32225. * Screen rotation is taken into account.
  32226. */
  32227. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  32228. private _camera;
  32229. private _screenOrientationAngle;
  32230. private _constantTranform;
  32231. private _screenQuaternion;
  32232. private _alpha;
  32233. private _beta;
  32234. private _gamma;
  32235. constructor();
  32236. camera: FreeCamera;
  32237. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32238. private _orientationChanged;
  32239. private _deviceOrientation;
  32240. detachControl(element: Nullable<HTMLElement>): void;
  32241. checkInputs(): void;
  32242. getClassName(): string;
  32243. getSimpleName(): string;
  32244. }
  32245. }
  32246. declare module BABYLON {
  32247. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  32248. camera: FreeCamera;
  32249. gamepad: Nullable<Gamepad>;
  32250. private _onGamepadConnectedObserver;
  32251. private _onGamepadDisconnectedObserver;
  32252. gamepadAngularSensibility: number;
  32253. gamepadMoveSensibility: number;
  32254. private _cameraTransform;
  32255. private _deltaTransform;
  32256. private _vector3;
  32257. private _vector2;
  32258. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32259. detachControl(element: Nullable<HTMLElement>): void;
  32260. checkInputs(): void;
  32261. getClassName(): string;
  32262. getSimpleName(): string;
  32263. }
  32264. }
  32265. declare module BABYLON {
  32266. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  32267. camera: FreeCamera;
  32268. private _keys;
  32269. private _onCanvasBlurObserver;
  32270. private _onKeyboardObserver;
  32271. private _engine;
  32272. private _scene;
  32273. keysUp: number[];
  32274. keysDown: number[];
  32275. keysLeft: number[];
  32276. keysRight: number[];
  32277. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32278. detachControl(element: Nullable<HTMLElement>): void;
  32279. checkInputs(): void;
  32280. getClassName(): string;
  32281. /** @hidden */
  32282. _onLostFocus(e: FocusEvent): void;
  32283. getSimpleName(): string;
  32284. }
  32285. }
  32286. declare module BABYLON {
  32287. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  32288. touchEnabled: boolean;
  32289. camera: FreeCamera;
  32290. buttons: number[];
  32291. angularSensibility: number;
  32292. private _pointerInput;
  32293. private _onMouseMove;
  32294. private _observer;
  32295. private previousPosition;
  32296. constructor(touchEnabled?: boolean);
  32297. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32298. detachControl(element: Nullable<HTMLElement>): void;
  32299. getClassName(): string;
  32300. getSimpleName(): string;
  32301. }
  32302. }
  32303. declare module BABYLON {
  32304. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  32305. camera: FreeCamera;
  32306. private _offsetX;
  32307. private _offsetY;
  32308. private _pointerPressed;
  32309. private _pointerInput;
  32310. private _observer;
  32311. private _onLostFocus;
  32312. touchAngularSensibility: number;
  32313. touchMoveSensibility: number;
  32314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32315. detachControl(element: Nullable<HTMLElement>): void;
  32316. checkInputs(): void;
  32317. getClassName(): string;
  32318. getSimpleName(): string;
  32319. }
  32320. }
  32321. declare module BABYLON {
  32322. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  32323. camera: FreeCamera;
  32324. private _leftjoystick;
  32325. private _rightjoystick;
  32326. getLeftJoystick(): VirtualJoystick;
  32327. getRightJoystick(): VirtualJoystick;
  32328. checkInputs(): void;
  32329. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32330. detachControl(element: Nullable<HTMLElement>): void;
  32331. getClassName(): string;
  32332. getSimpleName(): string;
  32333. }
  32334. }
  32335. declare module BABYLON {
  32336. /**
  32337. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  32338. */
  32339. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  32340. /**
  32341. * Creates a new AnaglyphArcRotateCamera
  32342. * @param name defines camera name
  32343. * @param alpha defines alpha angle (in radians)
  32344. * @param beta defines beta angle (in radians)
  32345. * @param radius defines radius
  32346. * @param target defines camera target
  32347. * @param interaxialDistance defines distance between each color axis
  32348. * @param scene defines the hosting scene
  32349. */
  32350. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  32351. /**
  32352. * Gets camera class name
  32353. * @returns AnaglyphArcRotateCamera
  32354. */
  32355. getClassName(): string;
  32356. }
  32357. }
  32358. declare module BABYLON {
  32359. /**
  32360. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  32361. */
  32362. class AnaglyphFreeCamera extends FreeCamera {
  32363. /**
  32364. * Creates a new AnaglyphFreeCamera
  32365. * @param name defines camera name
  32366. * @param position defines initial position
  32367. * @param interaxialDistance defines distance between each color axis
  32368. * @param scene defines the hosting scene
  32369. */
  32370. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  32371. /**
  32372. * Gets camera class name
  32373. * @returns AnaglyphFreeCamera
  32374. */
  32375. getClassName(): string;
  32376. }
  32377. }
  32378. declare module BABYLON {
  32379. /**
  32380. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  32381. */
  32382. class AnaglyphGamepadCamera extends GamepadCamera {
  32383. /**
  32384. * Creates a new AnaglyphGamepadCamera
  32385. * @param name defines camera name
  32386. * @param position defines initial position
  32387. * @param interaxialDistance defines distance between each color axis
  32388. * @param scene defines the hosting scene
  32389. */
  32390. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  32391. /**
  32392. * Gets camera class name
  32393. * @returns AnaglyphGamepadCamera
  32394. */
  32395. getClassName(): string;
  32396. }
  32397. }
  32398. declare module BABYLON {
  32399. /**
  32400. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  32401. */
  32402. class AnaglyphUniversalCamera extends UniversalCamera {
  32403. /**
  32404. * Creates a new AnaglyphUniversalCamera
  32405. * @param name defines camera name
  32406. * @param position defines initial position
  32407. * @param interaxialDistance defines distance between each color axis
  32408. * @param scene defines the hosting scene
  32409. */
  32410. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  32411. /**
  32412. * Gets camera class name
  32413. * @returns AnaglyphUniversalCamera
  32414. */
  32415. getClassName(): string;
  32416. }
  32417. }
  32418. declare module BABYLON {
  32419. /**
  32420. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  32421. */
  32422. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  32423. /**
  32424. * Creates a new StereoscopicArcRotateCamera
  32425. * @param name defines camera name
  32426. * @param alpha defines alpha angle (in radians)
  32427. * @param beta defines beta angle (in radians)
  32428. * @param radius defines radius
  32429. * @param target defines camera target
  32430. * @param interaxialDistance defines distance between each color axis
  32431. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  32432. * @param scene defines the hosting scene
  32433. */
  32434. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  32435. /**
  32436. * Gets camera class name
  32437. * @returns StereoscopicArcRotateCamera
  32438. */
  32439. getClassName(): string;
  32440. }
  32441. }
  32442. declare module BABYLON {
  32443. /**
  32444. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  32445. */
  32446. class StereoscopicFreeCamera extends FreeCamera {
  32447. /**
  32448. * Creates a new StereoscopicFreeCamera
  32449. * @param name defines camera name
  32450. * @param position defines initial position
  32451. * @param interaxialDistance defines distance between each color axis
  32452. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  32453. * @param scene defines the hosting scene
  32454. */
  32455. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  32456. /**
  32457. * Gets camera class name
  32458. * @returns StereoscopicFreeCamera
  32459. */
  32460. getClassName(): string;
  32461. }
  32462. }
  32463. declare module BABYLON {
  32464. /**
  32465. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  32466. */
  32467. class StereoscopicGamepadCamera extends GamepadCamera {
  32468. /**
  32469. * Creates a new StereoscopicGamepadCamera
  32470. * @param name defines camera name
  32471. * @param position defines initial position
  32472. * @param interaxialDistance defines distance between each color axis
  32473. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  32474. * @param scene defines the hosting scene
  32475. */
  32476. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  32477. /**
  32478. * Gets camera class name
  32479. * @returns StereoscopicGamepadCamera
  32480. */
  32481. getClassName(): string;
  32482. }
  32483. }
  32484. declare module BABYLON {
  32485. /**
  32486. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  32487. */
  32488. class StereoscopicUniversalCamera extends UniversalCamera {
  32489. /**
  32490. * Creates a new StereoscopicUniversalCamera
  32491. * @param name defines camera name
  32492. * @param position defines initial position
  32493. * @param interaxialDistance defines distance between each color axis
  32494. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  32495. * @param scene defines the hosting scene
  32496. */
  32497. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  32498. /**
  32499. * Gets camera class name
  32500. * @returns StereoscopicUniversalCamera
  32501. */
  32502. getClassName(): string;
  32503. }
  32504. }
  32505. declare module BABYLON {
  32506. class VRCameraMetrics {
  32507. hResolution: number;
  32508. vResolution: number;
  32509. hScreenSize: number;
  32510. vScreenSize: number;
  32511. vScreenCenter: number;
  32512. eyeToScreenDistance: number;
  32513. lensSeparationDistance: number;
  32514. interpupillaryDistance: number;
  32515. distortionK: number[];
  32516. chromaAbCorrection: number[];
  32517. postProcessScaleFactor: number;
  32518. lensCenterOffset: number;
  32519. compensateDistortion: boolean;
  32520. readonly aspectRatio: number;
  32521. readonly aspectRatioFov: number;
  32522. readonly leftHMatrix: Matrix;
  32523. readonly rightHMatrix: Matrix;
  32524. readonly leftPreViewMatrix: Matrix;
  32525. readonly rightPreViewMatrix: Matrix;
  32526. static GetDefault(): VRCameraMetrics;
  32527. }
  32528. }
  32529. declare module BABYLON {
  32530. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  32531. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  32532. getClassName(): string;
  32533. }
  32534. }
  32535. declare module BABYLON {
  32536. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  32537. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  32538. getClassName(): string;
  32539. }
  32540. }
  32541. declare module BABYLON {
  32542. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  32543. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  32544. getClassName(): string;
  32545. }
  32546. }
  32547. declare module BABYLON {
  32548. /**
  32549. * Options to modify the vr teleportation behavior.
  32550. */
  32551. interface VRTeleportationOptions {
  32552. /**
  32553. * The name of the mesh which should be used as the teleportation floor. (default: null)
  32554. */
  32555. floorMeshName?: string;
  32556. /**
  32557. * A list of meshes to be used as the teleportation floor. (default: empty)
  32558. */
  32559. floorMeshes?: Mesh[];
  32560. }
  32561. /**
  32562. * Options to modify the vr experience helper's behavior.
  32563. */
  32564. interface VRExperienceHelperOptions extends WebVROptions {
  32565. /**
  32566. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  32567. */
  32568. createDeviceOrientationCamera?: boolean;
  32569. /**
  32570. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  32571. */
  32572. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  32573. /**
  32574. * Uses the main button on the controller to toggle the laser casted. (default: true)
  32575. */
  32576. laserToggle?: boolean;
  32577. /**
  32578. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  32579. */
  32580. floorMeshes?: Mesh[];
  32581. }
  32582. /**
  32583. * Helps to quickly add VR support to an existing scene.
  32584. * See http://doc.babylonjs.com/how_to/webvr_helper
  32585. */
  32586. class VRExperienceHelper {
  32587. /** Options to modify the vr experience helper's behavior. */
  32588. webVROptions: VRExperienceHelperOptions;
  32589. private _scene;
  32590. private _position;
  32591. private _btnVR;
  32592. private _btnVRDisplayed;
  32593. private _webVRsupported;
  32594. private _webVRready;
  32595. private _webVRrequesting;
  32596. private _webVRpresenting;
  32597. private _fullscreenVRpresenting;
  32598. private _canvas;
  32599. private _webVRCamera;
  32600. private _vrDeviceOrientationCamera;
  32601. private _deviceOrientationCamera;
  32602. private _existingCamera;
  32603. private _onKeyDown;
  32604. private _onVrDisplayPresentChange;
  32605. private _onVRDisplayChanged;
  32606. private _onVRRequestPresentStart;
  32607. private _onVRRequestPresentComplete;
  32608. /**
  32609. * Observable raised when entering VR.
  32610. */
  32611. onEnteringVRObservable: Observable<VRExperienceHelper>;
  32612. /**
  32613. * Observable raised when exiting VR.
  32614. */
  32615. onExitingVRObservable: Observable<VRExperienceHelper>;
  32616. /**
  32617. * Observable raised when controller mesh is loaded.
  32618. */
  32619. onControllerMeshLoadedObservable: Observable<WebVRController>;
  32620. /** Return this.onEnteringVRObservable
  32621. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  32622. */
  32623. readonly onEnteringVR: Observable<VRExperienceHelper>;
  32624. /** Return this.onExitingVRObservable
  32625. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  32626. */
  32627. readonly onExitingVR: Observable<VRExperienceHelper>;
  32628. /** Return this.onControllerMeshLoadedObservable
  32629. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  32630. */
  32631. readonly onControllerMeshLoaded: Observable<WebVRController>;
  32632. private _rayLength;
  32633. private _useCustomVRButton;
  32634. private _teleportationRequested;
  32635. private _teleportActive;
  32636. private _floorMeshName;
  32637. private _floorMeshesCollection;
  32638. private _rotationAllowed;
  32639. private _teleportBackwardsVector;
  32640. private _teleportationTarget;
  32641. private _isDefaultTeleportationTarget;
  32642. private _postProcessMove;
  32643. private _teleportationFillColor;
  32644. private _teleportationBorderColor;
  32645. private _rotationAngle;
  32646. private _haloCenter;
  32647. private _cameraGazer;
  32648. private _padSensibilityUp;
  32649. private _padSensibilityDown;
  32650. private leftController;
  32651. private rightController;
  32652. /**
  32653. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  32654. */
  32655. onNewMeshSelected: Observable<AbstractMesh>;
  32656. /**
  32657. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  32658. */
  32659. onNewMeshPicked: Observable<PickingInfo>;
  32660. private _circleEase;
  32661. /**
  32662. * Observable raised before camera teleportation
  32663. */
  32664. onBeforeCameraTeleport: Observable<Vector3>;
  32665. /**
  32666. * Observable raised after camera teleportation
  32667. */
  32668. onAfterCameraTeleport: Observable<Vector3>;
  32669. /**
  32670. * Observable raised when current selected mesh gets unselected
  32671. */
  32672. onSelectedMeshUnselected: Observable<AbstractMesh>;
  32673. private _raySelectionPredicate;
  32674. /**
  32675. * To be optionaly changed by user to define custom ray selection
  32676. */
  32677. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  32678. /**
  32679. * To be optionaly changed by user to define custom selection logic (after ray selection)
  32680. */
  32681. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  32682. /**
  32683. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  32684. */
  32685. teleportationEnabled: boolean;
  32686. private _defaultHeight;
  32687. private _teleportationInitialized;
  32688. private _interactionsEnabled;
  32689. private _interactionsRequested;
  32690. private _displayGaze;
  32691. private _displayLaserPointer;
  32692. /**
  32693. * The mesh used to display where the user is going to teleport.
  32694. */
  32695. /**
  32696. * Sets the mesh to be used to display where the user is going to teleport.
  32697. */
  32698. teleportationTarget: Mesh;
  32699. /**
  32700. * The mesh used to display where the user is selecting,
  32701. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  32702. * See http://doc.babylonjs.com/resources/baking_transformations
  32703. */
  32704. gazeTrackerMesh: Mesh;
  32705. /**
  32706. * If the ray of the gaze should be displayed.
  32707. */
  32708. /**
  32709. * Sets if the ray of the gaze should be displayed.
  32710. */
  32711. displayGaze: boolean;
  32712. /**
  32713. * If the ray of the LaserPointer should be displayed.
  32714. */
  32715. /**
  32716. * Sets if the ray of the LaserPointer should be displayed.
  32717. */
  32718. displayLaserPointer: boolean;
  32719. /**
  32720. * The deviceOrientationCamera used as the camera when not in VR.
  32721. */
  32722. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  32723. /**
  32724. * Based on the current WebVR support, returns the current VR camera used.
  32725. */
  32726. readonly currentVRCamera: Nullable<Camera>;
  32727. /**
  32728. * The webVRCamera which is used when in VR.
  32729. */
  32730. readonly webVRCamera: WebVRFreeCamera;
  32731. /**
  32732. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  32733. */
  32734. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  32735. private readonly _teleportationRequestInitiated;
  32736. /**
  32737. * Instantiates a VRExperienceHelper.
  32738. * Helps to quickly add VR support to an existing scene.
  32739. * @param scene The scene the VRExperienceHelper belongs to.
  32740. * @param webVROptions Options to modify the vr experience helper's behavior.
  32741. */
  32742. constructor(scene: Scene,
  32743. /** Options to modify the vr experience helper's behavior. */
  32744. webVROptions?: VRExperienceHelperOptions);
  32745. private _onDefaultMeshLoaded;
  32746. private _onResize;
  32747. private _onFullscreenChange;
  32748. /**
  32749. * Gets a value indicating if we are currently in VR mode.
  32750. */
  32751. readonly isInVRMode: boolean;
  32752. private onVrDisplayPresentChange;
  32753. private onVRDisplayChanged;
  32754. private moveButtonToBottomRight;
  32755. private displayVRButton;
  32756. private updateButtonVisibility;
  32757. /**
  32758. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  32759. * Otherwise, will use the fullscreen API.
  32760. */
  32761. enterVR(): void;
  32762. /**
  32763. * Attempt to exit VR, or fullscreen.
  32764. */
  32765. exitVR(): void;
  32766. /**
  32767. * The position of the vr experience helper.
  32768. */
  32769. /**
  32770. * Sets the position of the vr experience helper.
  32771. */
  32772. position: Vector3;
  32773. /**
  32774. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  32775. */
  32776. enableInteractions(): void;
  32777. private readonly _noControllerIsActive;
  32778. private beforeRender;
  32779. private _isTeleportationFloor;
  32780. /**
  32781. * Adds a floor mesh to be used for teleportation.
  32782. * @param floorMesh the mesh to be used for teleportation.
  32783. */
  32784. addFloorMesh(floorMesh: Mesh): void;
  32785. /**
  32786. * Removes a floor mesh from being used for teleportation.
  32787. * @param floorMesh the mesh to be removed.
  32788. */
  32789. removeFloorMesh(floorMesh: Mesh): void;
  32790. /**
  32791. * Enables interactions and teleportation using the VR controllers and gaze.
  32792. * @param vrTeleportationOptions options to modify teleportation behavior.
  32793. */
  32794. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  32795. private _onNewGamepadConnected;
  32796. private _tryEnableInteractionOnController;
  32797. private _onNewGamepadDisconnected;
  32798. private _enableInteractionOnController;
  32799. private _checkTeleportWithRay;
  32800. private _checkRotate;
  32801. private _checkTeleportBackwards;
  32802. private _enableTeleportationOnController;
  32803. private _createTeleportationCircles;
  32804. private _displayTeleportationTarget;
  32805. private _hideTeleportationTarget;
  32806. private _rotateCamera;
  32807. private _moveTeleportationSelectorTo;
  32808. private _workingVector;
  32809. private _workingQuaternion;
  32810. private _workingMatrix;
  32811. private _teleportCamera;
  32812. private _convertNormalToDirectionOfRay;
  32813. private _castRayAndSelectObject;
  32814. private _notifySelectedMeshUnselected;
  32815. /**
  32816. * Sets the color of the laser ray from the vr controllers.
  32817. * @param color new color for the ray.
  32818. */
  32819. changeLaserColor(color: Color3): void;
  32820. /**
  32821. * Sets the color of the ray from the vr headsets gaze.
  32822. * @param color new color for the ray.
  32823. */
  32824. changeGazeColor(color: Color3): void;
  32825. /**
  32826. * Exits VR and disposes of the vr experience helper
  32827. */
  32828. dispose(): void;
  32829. /**
  32830. * Gets the name of the VRExperienceHelper class
  32831. * @returns "VRExperienceHelper"
  32832. */
  32833. getClassName(): string;
  32834. }
  32835. }
  32836. declare module BABYLON {
  32837. /**
  32838. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  32839. * IMPORTANT!! The data is right-hand data.
  32840. * @export
  32841. * @interface DevicePose
  32842. */
  32843. interface DevicePose {
  32844. /**
  32845. * The position of the device, values in array are [x,y,z].
  32846. */
  32847. readonly position: Nullable<Float32Array>;
  32848. /**
  32849. * The linearVelocity of the device, values in array are [x,y,z].
  32850. */
  32851. readonly linearVelocity: Nullable<Float32Array>;
  32852. /**
  32853. * The linearAcceleration of the device, values in array are [x,y,z].
  32854. */
  32855. readonly linearAcceleration: Nullable<Float32Array>;
  32856. /**
  32857. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  32858. */
  32859. readonly orientation: Nullable<Float32Array>;
  32860. /**
  32861. * The angularVelocity of the device, values in array are [x,y,z].
  32862. */
  32863. readonly angularVelocity: Nullable<Float32Array>;
  32864. /**
  32865. * The angularAcceleration of the device, values in array are [x,y,z].
  32866. */
  32867. readonly angularAcceleration: Nullable<Float32Array>;
  32868. }
  32869. /**
  32870. * Interface representing a pose controlled object in Babylon.
  32871. * A pose controlled object has both regular pose values as well as pose values
  32872. * from an external device such as a VR head mounted display
  32873. */
  32874. interface PoseControlled {
  32875. /**
  32876. * The position of the object in babylon space.
  32877. */
  32878. position: Vector3;
  32879. /**
  32880. * The rotation quaternion of the object in babylon space.
  32881. */
  32882. rotationQuaternion: Quaternion;
  32883. /**
  32884. * The position of the device in babylon space.
  32885. */
  32886. devicePosition?: Vector3;
  32887. /**
  32888. * The rotation quaternion of the device in babylon space.
  32889. */
  32890. deviceRotationQuaternion: Quaternion;
  32891. /**
  32892. * The raw pose coming from the device.
  32893. */
  32894. rawPose: Nullable<DevicePose>;
  32895. /**
  32896. * The scale of the device to be used when translating from device space to babylon space.
  32897. */
  32898. deviceScaleFactor: number;
  32899. /**
  32900. * Updates the poseControlled values based on the input device pose.
  32901. * @param poseData the pose data to update the object with
  32902. */
  32903. updateFromDevice(poseData: DevicePose): void;
  32904. }
  32905. /**
  32906. * Set of options to customize the webVRCamera
  32907. */
  32908. interface WebVROptions {
  32909. /**
  32910. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  32911. */
  32912. trackPosition?: boolean;
  32913. /**
  32914. * Sets the scale of the vrDevice in babylon space. (default: 1)
  32915. */
  32916. positionScale?: number;
  32917. /**
  32918. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  32919. */
  32920. displayName?: string;
  32921. /**
  32922. * Should the native controller meshes be initialized. (default: true)
  32923. */
  32924. controllerMeshes?: boolean;
  32925. /**
  32926. * Creating a default HemiLight only on controllers. (default: true)
  32927. */
  32928. defaultLightingOnControllers?: boolean;
  32929. /**
  32930. * If you don't want to use the default VR button of the helper. (default: false)
  32931. */
  32932. useCustomVRButton?: boolean;
  32933. /**
  32934. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  32935. */
  32936. customVRButton?: HTMLButtonElement;
  32937. /**
  32938. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  32939. */
  32940. rayLength?: number;
  32941. /**
  32942. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  32943. */
  32944. defaultHeight?: number;
  32945. }
  32946. /**
  32947. * This represents a WebVR camera.
  32948. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  32949. * @example http://doc.babylonjs.com/how_to/webvr_camera
  32950. */
  32951. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  32952. private webVROptions;
  32953. /**
  32954. * @hidden
  32955. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  32956. */
  32957. _vrDevice: any;
  32958. /**
  32959. * The rawPose of the vrDevice.
  32960. */
  32961. rawPose: Nullable<DevicePose>;
  32962. private _onVREnabled;
  32963. private _specsVersion;
  32964. private _attached;
  32965. private _frameData;
  32966. protected _descendants: Array<Node>;
  32967. private _deviceRoomPosition;
  32968. /** @hidden */
  32969. _deviceRoomRotationQuaternion: Quaternion;
  32970. private _standingMatrix;
  32971. /**
  32972. * Represents device position in babylon space.
  32973. */
  32974. devicePosition: Vector3;
  32975. /**
  32976. * Represents device rotation in babylon space.
  32977. */
  32978. deviceRotationQuaternion: Quaternion;
  32979. /**
  32980. * The scale of the device to be used when translating from device space to babylon space.
  32981. */
  32982. deviceScaleFactor: number;
  32983. private _deviceToWorld;
  32984. private _worldToDevice;
  32985. /**
  32986. * References to the webVR controllers for the vrDevice.
  32987. */
  32988. controllers: Array<WebVRController>;
  32989. /**
  32990. * Emits an event when a controller is attached.
  32991. */
  32992. onControllersAttachedObservable: Observable<WebVRController[]>;
  32993. /**
  32994. * Emits an event when a controller's mesh has been loaded;
  32995. */
  32996. onControllerMeshLoadedObservable: Observable<WebVRController>;
  32997. /**
  32998. * Emits an event when the HMD's pose has been updated.
  32999. */
  33000. onPoseUpdatedFromDeviceObservable: Observable<any>;
  33001. private _poseSet;
  33002. /**
  33003. * If the rig cameras be used as parent instead of this camera.
  33004. */
  33005. rigParenting: boolean;
  33006. private _lightOnControllers;
  33007. private _defaultHeight?;
  33008. /**
  33009. * Instantiates a WebVRFreeCamera.
  33010. * @param name The name of the WebVRFreeCamera
  33011. * @param position The starting anchor position for the camera
  33012. * @param scene The scene the camera belongs to
  33013. * @param webVROptions a set of customizable options for the webVRCamera
  33014. */
  33015. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  33016. /**
  33017. * Gets the device distance from the ground in meters.
  33018. * @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.
  33019. */
  33020. deviceDistanceToRoomGround(): number;
  33021. /**
  33022. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  33023. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  33024. */
  33025. useStandingMatrix(callback?: (bool: boolean) => void): void;
  33026. /**
  33027. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  33028. * @returns A promise with a boolean set to if the standing matrix is supported.
  33029. */
  33030. useStandingMatrixAsync(): Promise<boolean>;
  33031. /**
  33032. * Disposes the camera
  33033. */
  33034. dispose(): void;
  33035. /**
  33036. * Gets a vrController by name.
  33037. * @param name The name of the controller to retreive
  33038. * @returns the controller matching the name specified or null if not found
  33039. */
  33040. getControllerByName(name: string): Nullable<WebVRController>;
  33041. private _leftController;
  33042. /**
  33043. * The controller corrisponding to the users left hand.
  33044. */
  33045. readonly leftController: Nullable<WebVRController>;
  33046. private _rightController;
  33047. /**
  33048. * The controller corrisponding to the users right hand.
  33049. */
  33050. readonly rightController: Nullable<WebVRController>;
  33051. /**
  33052. * Casts a ray forward from the vrCamera's gaze.
  33053. * @param length Length of the ray (default: 100)
  33054. * @returns the ray corrisponding to the gaze
  33055. */
  33056. getForwardRay(length?: number): Ray;
  33057. /**
  33058. * @hidden
  33059. * Updates the camera based on device's frame data
  33060. */
  33061. _checkInputs(): void;
  33062. /**
  33063. * Updates the poseControlled values based on the input device pose.
  33064. * @param poseData Pose coming from the device
  33065. */
  33066. updateFromDevice(poseData: DevicePose): void;
  33067. /**
  33068. * WebVR's attach control will start broadcasting frames to the device.
  33069. * Note that in certain browsers (chrome for example) this function must be called
  33070. * within a user-interaction callback. Example:
  33071. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  33072. *
  33073. * @param element html element to attach the vrDevice to
  33074. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  33075. */
  33076. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33077. /**
  33078. * Detaches the camera from the html element and disables VR
  33079. *
  33080. * @param element html element to detach from
  33081. */
  33082. detachControl(element: HTMLElement): void;
  33083. /**
  33084. * @returns the name of this class
  33085. */
  33086. getClassName(): string;
  33087. /**
  33088. * Calls resetPose on the vrDisplay
  33089. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  33090. */
  33091. resetToCurrentRotation(): void;
  33092. /**
  33093. * @hidden
  33094. * Updates the rig cameras (left and right eye)
  33095. */
  33096. _updateRigCameras(): void;
  33097. private _workingVector;
  33098. private _oneVector;
  33099. private _workingMatrix;
  33100. private updateCacheCalled;
  33101. /**
  33102. * @hidden
  33103. * Updates the cached values of the camera
  33104. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  33105. */
  33106. _updateCache(ignoreParentClass?: boolean): void;
  33107. /**
  33108. * Updates the current device position and rotation in the babylon world
  33109. */
  33110. update(): void;
  33111. /**
  33112. * @hidden
  33113. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  33114. * @returns an identity matrix
  33115. */
  33116. _getViewMatrix(): Matrix;
  33117. /**
  33118. * This function is called by the two RIG cameras.
  33119. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  33120. */
  33121. protected _getWebVRViewMatrix(): Matrix;
  33122. protected _getWebVRProjectionMatrix(): Matrix;
  33123. private _onGamepadConnectedObserver;
  33124. private _onGamepadDisconnectedObserver;
  33125. /**
  33126. * Initializes the controllers and their meshes
  33127. */
  33128. initControllers(): void;
  33129. }
  33130. }
  33131. declare module BABYLON {
  33132. interface IOctreeContainer<T> {
  33133. blocks: Array<OctreeBlock<T>>;
  33134. }
  33135. class Octree<T> {
  33136. maxDepth: number;
  33137. blocks: Array<OctreeBlock<T>>;
  33138. dynamicContent: T[];
  33139. private _maxBlockCapacity;
  33140. private _selectionContent;
  33141. private _creationFunc;
  33142. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  33143. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  33144. addMesh(entry: T): void;
  33145. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  33146. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  33147. intersectsRay(ray: Ray): SmartArray<T>;
  33148. 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;
  33149. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  33150. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  33151. }
  33152. }
  33153. declare module BABYLON {
  33154. class OctreeBlock<T> {
  33155. entries: T[];
  33156. blocks: Array<OctreeBlock<T>>;
  33157. private _depth;
  33158. private _maxDepth;
  33159. private _capacity;
  33160. private _minPoint;
  33161. private _maxPoint;
  33162. private _boundingVectors;
  33163. private _creationFunc;
  33164. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  33165. readonly capacity: number;
  33166. readonly minPoint: Vector3;
  33167. readonly maxPoint: Vector3;
  33168. addEntry(entry: T): void;
  33169. addEntries(entries: T[]): void;
  33170. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  33171. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  33172. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  33173. createInnerBlocks(): void;
  33174. }
  33175. }
  33176. declare module BABYLON {
  33177. interface Engine {
  33178. /**
  33179. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  33180. * @return the new query
  33181. */
  33182. createQuery(): WebGLQuery;
  33183. /**
  33184. * Delete and release a webGL query
  33185. * @param query defines the query to delete
  33186. * @return the current engine
  33187. */
  33188. deleteQuery(query: WebGLQuery): Engine;
  33189. /**
  33190. * Check if a given query has resolved and got its value
  33191. * @param query defines the query to check
  33192. * @returns true if the query got its value
  33193. */
  33194. isQueryResultAvailable(query: WebGLQuery): boolean;
  33195. /**
  33196. * Gets the value of a given query
  33197. * @param query defines the query to check
  33198. * @returns the value of the query
  33199. */
  33200. getQueryResult(query: WebGLQuery): number;
  33201. /**
  33202. * Initiates an occlusion query
  33203. * @param algorithmType defines the algorithm to use
  33204. * @param query defines the query to use
  33205. * @returns the current engine
  33206. * @see http://doc.babylonjs.com/features/occlusionquery
  33207. */
  33208. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  33209. /**
  33210. * Ends an occlusion query
  33211. * @see http://doc.babylonjs.com/features/occlusionquery
  33212. * @param algorithmType defines the algorithm to use
  33213. * @returns the current engine
  33214. */
  33215. endOcclusionQuery(algorithmType: number): Engine;
  33216. /**
  33217. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  33218. * Please note that only one query can be issued at a time
  33219. * @returns a time token used to track the time span
  33220. */
  33221. startTimeQuery(): Nullable<_TimeToken>;
  33222. /**
  33223. * Ends a time query
  33224. * @param token defines the token used to measure the time span
  33225. * @returns the time spent (in ns)
  33226. */
  33227. endTimeQuery(token: _TimeToken): int;
  33228. /** @hidden */
  33229. _currentNonTimestampToken: Nullable<_TimeToken>;
  33230. /** @hidden */
  33231. _createTimeQuery(): WebGLQuery;
  33232. /** @hidden */
  33233. _deleteTimeQuery(query: WebGLQuery): void;
  33234. /** @hidden */
  33235. _getGlAlgorithmType(algorithmType: number): number;
  33236. /** @hidden */
  33237. _getTimeQueryResult(query: WebGLQuery): any;
  33238. /** @hidden */
  33239. _getTimeQueryAvailability(query: WebGLQuery): any;
  33240. }
  33241. }
  33242. declare module BABYLON {
  33243. interface Engine {
  33244. /**
  33245. * Creates a webGL transform feedback object
  33246. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  33247. * @returns the webGL transform feedback object
  33248. */
  33249. createTransformFeedback(): WebGLTransformFeedback;
  33250. /**
  33251. * Delete a webGL transform feedback object
  33252. * @param value defines the webGL transform feedback object to delete
  33253. */
  33254. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  33255. /**
  33256. * Bind a webGL transform feedback object to the webgl context
  33257. * @param value defines the webGL transform feedback object to bind
  33258. */
  33259. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  33260. /**
  33261. * Begins a transform feedback operation
  33262. * @param usePoints defines if points or triangles must be used
  33263. */
  33264. beginTransformFeedback(usePoints: boolean): void;
  33265. /**
  33266. * Ends a transform feedback operation
  33267. */
  33268. endTransformFeedback(): void;
  33269. /**
  33270. * Specify the varyings to use with transform feedback
  33271. * @param program defines the associated webGL program
  33272. * @param value defines the list of strings representing the varying names
  33273. */
  33274. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  33275. /**
  33276. * Bind a webGL buffer for a transform feedback operation
  33277. * @param value defines the webGL buffer to bind
  33278. */
  33279. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  33280. }
  33281. }
  33282. declare module BABYLON {
  33283. /**
  33284. * Google Daydream controller
  33285. */
  33286. class DaydreamController extends WebVRController {
  33287. /**
  33288. * Base Url for the controller model.
  33289. */
  33290. static MODEL_BASE_URL: string;
  33291. /**
  33292. * File name for the controller model.
  33293. */
  33294. static MODEL_FILENAME: string;
  33295. /**
  33296. * Gamepad Id prefix used to identify Daydream Controller.
  33297. */
  33298. static readonly GAMEPAD_ID_PREFIX: string;
  33299. /**
  33300. * Creates a new DaydreamController from a gamepad
  33301. * @param vrGamepad the gamepad that the controller should be created from
  33302. */
  33303. constructor(vrGamepad: any);
  33304. /**
  33305. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33306. * @param scene scene in which to add meshes
  33307. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33308. */
  33309. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33310. /**
  33311. * Called once for each button that changed state since the last frame
  33312. * @param buttonIdx Which button index changed
  33313. * @param state New state of the button
  33314. * @param changes Which properties on the state changed since last frame
  33315. */
  33316. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33317. }
  33318. }
  33319. declare module BABYLON {
  33320. /**
  33321. * Gear VR Controller
  33322. */
  33323. class GearVRController extends WebVRController {
  33324. /**
  33325. * Base Url for the controller model.
  33326. */
  33327. static MODEL_BASE_URL: string;
  33328. /**
  33329. * File name for the controller model.
  33330. */
  33331. static MODEL_FILENAME: string;
  33332. private _maxRotationDistFromHeadset;
  33333. private _draggedRoomRotation;
  33334. private _tmpVector;
  33335. /**
  33336. * Gamepad Id prefix used to identify this controller.
  33337. */
  33338. static readonly GAMEPAD_ID_PREFIX: string;
  33339. private readonly _buttonIndexToObservableNameMap;
  33340. /**
  33341. * Creates a new GearVRController from a gamepad
  33342. * @param vrGamepad the gamepad that the controller should be created from
  33343. */
  33344. constructor(vrGamepad: any);
  33345. /**
  33346. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  33347. * @param poseData raw pose fromthe device
  33348. */
  33349. updateFromDevice(poseData: DevicePose): void;
  33350. /**
  33351. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33352. * @param scene scene in which to add meshes
  33353. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33354. */
  33355. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33356. /**
  33357. * Called once for each button that changed state since the last frame
  33358. * @param buttonIdx Which button index changed
  33359. * @param state New state of the button
  33360. * @param changes Which properties on the state changed since last frame
  33361. */
  33362. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33363. }
  33364. }
  33365. declare module BABYLON {
  33366. /**
  33367. * Generic Controller
  33368. */
  33369. class GenericController extends WebVRController {
  33370. /**
  33371. * Base Url for the controller model.
  33372. */
  33373. static readonly MODEL_BASE_URL: string;
  33374. /**
  33375. * File name for the controller model.
  33376. */
  33377. static readonly MODEL_FILENAME: string;
  33378. /**
  33379. * Creates a new GenericController from a gamepad
  33380. * @param vrGamepad the gamepad that the controller should be created from
  33381. */
  33382. constructor(vrGamepad: any);
  33383. /**
  33384. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33385. * @param scene scene in which to add meshes
  33386. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33387. */
  33388. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33389. /**
  33390. * Called once for each button that changed state since the last frame
  33391. * @param buttonIdx Which button index changed
  33392. * @param state New state of the button
  33393. * @param changes Which properties on the state changed since last frame
  33394. */
  33395. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33396. }
  33397. }
  33398. declare module BABYLON {
  33399. /**
  33400. * Oculus Touch Controller
  33401. */
  33402. class OculusTouchController extends WebVRController {
  33403. /**
  33404. * Base Url for the controller model.
  33405. */
  33406. static MODEL_BASE_URL: string;
  33407. /**
  33408. * File name for the left controller model.
  33409. */
  33410. static MODEL_LEFT_FILENAME: string;
  33411. /**
  33412. * File name for the right controller model.
  33413. */
  33414. static MODEL_RIGHT_FILENAME: string;
  33415. /**
  33416. * Fired when the secondary trigger on this controller is modified
  33417. */
  33418. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  33419. /**
  33420. * Fired when the thumb rest on this controller is modified
  33421. */
  33422. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  33423. /**
  33424. * Creates a new OculusTouchController from a gamepad
  33425. * @param vrGamepad the gamepad that the controller should be created from
  33426. */
  33427. constructor(vrGamepad: any);
  33428. /**
  33429. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33430. * @param scene scene in which to add meshes
  33431. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33432. */
  33433. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33434. /**
  33435. * Fired when the A button on this controller is modified
  33436. */
  33437. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33438. /**
  33439. * Fired when the B button on this controller is modified
  33440. */
  33441. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33442. /**
  33443. * Fired when the X button on this controller is modified
  33444. */
  33445. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33446. /**
  33447. * Fired when the Y button on this controller is modified
  33448. */
  33449. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33450. /**
  33451. * Called once for each button that changed state since the last frame
  33452. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  33453. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  33454. * 2) secondary trigger (same)
  33455. * 3) A (right) X (left), touch, pressed = value
  33456. * 4) B / Y
  33457. * 5) thumb rest
  33458. * @param buttonIdx Which button index changed
  33459. * @param state New state of the button
  33460. * @param changes Which properties on the state changed since last frame
  33461. */
  33462. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33463. }
  33464. }
  33465. declare module BABYLON {
  33466. /**
  33467. * Defines the types of pose enabled controllers that are supported
  33468. */
  33469. enum PoseEnabledControllerType {
  33470. /**
  33471. * HTC Vive
  33472. */
  33473. VIVE = 0,
  33474. /**
  33475. * Oculus Rift
  33476. */
  33477. OCULUS = 1,
  33478. /**
  33479. * Windows mixed reality
  33480. */
  33481. WINDOWS = 2,
  33482. /**
  33483. * Samsung gear VR
  33484. */
  33485. GEAR_VR = 3,
  33486. /**
  33487. * Google Daydream
  33488. */
  33489. DAYDREAM = 4,
  33490. /**
  33491. * Generic
  33492. */
  33493. GENERIC = 5
  33494. }
  33495. /**
  33496. * Defines the MutableGamepadButton interface for the state of a gamepad button
  33497. */
  33498. interface MutableGamepadButton {
  33499. /**
  33500. * Value of the button/trigger
  33501. */
  33502. value: number;
  33503. /**
  33504. * If the button/trigger is currently touched
  33505. */
  33506. touched: boolean;
  33507. /**
  33508. * If the button/trigger is currently pressed
  33509. */
  33510. pressed: boolean;
  33511. }
  33512. /**
  33513. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  33514. * @hidden
  33515. */
  33516. interface ExtendedGamepadButton extends GamepadButton {
  33517. /**
  33518. * If the button/trigger is currently pressed
  33519. */
  33520. readonly pressed: boolean;
  33521. /**
  33522. * If the button/trigger is currently touched
  33523. */
  33524. readonly touched: boolean;
  33525. /**
  33526. * Value of the button/trigger
  33527. */
  33528. readonly value: number;
  33529. }
  33530. /**
  33531. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  33532. */
  33533. class PoseEnabledControllerHelper {
  33534. /**
  33535. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  33536. * @param vrGamepad the gamepad to initialized
  33537. * @returns a vr controller of the type the gamepad identified as
  33538. */
  33539. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  33540. }
  33541. /**
  33542. * Defines the PoseEnabledController object that contains state of a vr capable controller
  33543. */
  33544. class PoseEnabledController extends Gamepad implements PoseControlled {
  33545. private _deviceRoomPosition;
  33546. private _deviceRoomRotationQuaternion;
  33547. /**
  33548. * The device position in babylon space
  33549. */
  33550. devicePosition: Vector3;
  33551. /**
  33552. * The device rotation in babylon space
  33553. */
  33554. deviceRotationQuaternion: Quaternion;
  33555. /**
  33556. * The scale factor of the device in babylon space
  33557. */
  33558. deviceScaleFactor: number;
  33559. /**
  33560. * (Likely devicePosition should be used instead) The device position in its room space
  33561. */
  33562. position: Vector3;
  33563. /**
  33564. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  33565. */
  33566. rotationQuaternion: Quaternion;
  33567. /**
  33568. * The type of controller (Eg. Windows mixed reality)
  33569. */
  33570. controllerType: PoseEnabledControllerType;
  33571. protected _calculatedPosition: Vector3;
  33572. private _calculatedRotation;
  33573. /**
  33574. * The raw pose from the device
  33575. */
  33576. rawPose: DevicePose;
  33577. /**
  33578. * Internal, the mesh attached to the controller
  33579. * @hidden
  33580. */
  33581. _mesh: Nullable<AbstractMesh>;
  33582. private _poseControlledCamera;
  33583. private _leftHandSystemQuaternion;
  33584. /**
  33585. * Internal, matrix used to convert room space to babylon space
  33586. * @hidden
  33587. */
  33588. _deviceToWorld: Matrix;
  33589. /**
  33590. * Node to be used when casting a ray from the controller
  33591. * @hidden
  33592. */
  33593. _pointingPoseNode: Nullable<AbstractMesh>;
  33594. /**
  33595. * Name of the child mesh that can be used to cast a ray from the controller
  33596. */
  33597. static readonly POINTING_POSE: string;
  33598. /**
  33599. * Creates a new PoseEnabledController from a gamepad
  33600. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  33601. */
  33602. constructor(browserGamepad: any);
  33603. private _workingMatrix;
  33604. /**
  33605. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  33606. */
  33607. update(): void;
  33608. /**
  33609. * Updates only the pose device and mesh without doing any button event checking
  33610. */
  33611. protected _updatePoseAndMesh(): void;
  33612. /**
  33613. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  33614. * @param poseData raw pose fromthe device
  33615. */
  33616. updateFromDevice(poseData: DevicePose): void;
  33617. /**
  33618. * @hidden
  33619. */
  33620. _meshAttachedObservable: Observable<AbstractMesh>;
  33621. /**
  33622. * Attaches a mesh to the controller
  33623. * @param mesh the mesh to be attached
  33624. */
  33625. attachToMesh(mesh: AbstractMesh): void;
  33626. /**
  33627. * Attaches the controllers mesh to a camera
  33628. * @param camera the camera the mesh should be attached to
  33629. */
  33630. attachToPoseControlledCamera(camera: TargetCamera): void;
  33631. /**
  33632. * Disposes of the controller
  33633. */
  33634. dispose(): void;
  33635. /**
  33636. * The mesh that is attached to the controller
  33637. */
  33638. readonly mesh: Nullable<AbstractMesh>;
  33639. /**
  33640. * Gets the ray of the controller in the direction the controller is pointing
  33641. * @param length the length the resulting ray should be
  33642. * @returns a ray in the direction the controller is pointing
  33643. */
  33644. getForwardRay(length?: number): Ray;
  33645. }
  33646. }
  33647. declare module BABYLON {
  33648. /**
  33649. * Vive Controller
  33650. */
  33651. class ViveController extends WebVRController {
  33652. /**
  33653. * Base Url for the controller model.
  33654. */
  33655. static MODEL_BASE_URL: string;
  33656. /**
  33657. * File name for the controller model.
  33658. */
  33659. static MODEL_FILENAME: string;
  33660. /**
  33661. * Creates a new ViveController from a gamepad
  33662. * @param vrGamepad the gamepad that the controller should be created from
  33663. */
  33664. constructor(vrGamepad: any);
  33665. /**
  33666. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33667. * @param scene scene in which to add meshes
  33668. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33669. */
  33670. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33671. /**
  33672. * Fired when the left button on this controller is modified
  33673. */
  33674. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33675. /**
  33676. * Fired when the right button on this controller is modified
  33677. */
  33678. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33679. /**
  33680. * Fired when the menu button on this controller is modified
  33681. */
  33682. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33683. /**
  33684. * Called once for each button that changed state since the last frame
  33685. * Vive mapping:
  33686. * 0: touchpad
  33687. * 1: trigger
  33688. * 2: left AND right buttons
  33689. * 3: menu button
  33690. * @param buttonIdx Which button index changed
  33691. * @param state New state of the button
  33692. * @param changes Which properties on the state changed since last frame
  33693. */
  33694. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33695. }
  33696. }
  33697. declare module BABYLON {
  33698. /**
  33699. * Defines the WebVRController object that represents controllers tracked in 3D space
  33700. */
  33701. abstract class WebVRController extends PoseEnabledController {
  33702. /**
  33703. * Internal, the default controller model for the controller
  33704. */
  33705. protected _defaultModel: AbstractMesh;
  33706. /**
  33707. * Fired when the trigger state has changed
  33708. */
  33709. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  33710. /**
  33711. * Fired when the main button state has changed
  33712. */
  33713. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33714. /**
  33715. * Fired when the secondary button state has changed
  33716. */
  33717. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33718. /**
  33719. * Fired when the pad state has changed
  33720. */
  33721. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  33722. /**
  33723. * Fired when controllers stick values have changed
  33724. */
  33725. onPadValuesChangedObservable: Observable<StickValues>;
  33726. /**
  33727. * Array of button availible on the controller
  33728. */
  33729. protected _buttons: Array<MutableGamepadButton>;
  33730. private _onButtonStateChange;
  33731. /**
  33732. * Fired when a controller button's state has changed
  33733. * @param callback the callback containing the button that was modified
  33734. */
  33735. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  33736. /**
  33737. * X and Y axis corrisponding to the controllers joystick
  33738. */
  33739. pad: StickValues;
  33740. /**
  33741. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  33742. */
  33743. hand: string;
  33744. /**
  33745. * The default controller model for the controller
  33746. */
  33747. readonly defaultModel: AbstractMesh;
  33748. /**
  33749. * Creates a new WebVRController from a gamepad
  33750. * @param vrGamepad the gamepad that the WebVRController should be created from
  33751. */
  33752. constructor(vrGamepad: any);
  33753. /**
  33754. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  33755. */
  33756. update(): void;
  33757. /**
  33758. * Function to be called when a button is modified
  33759. */
  33760. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33761. /**
  33762. * Loads a mesh and attaches it to the controller
  33763. * @param scene the scene the mesh should be added to
  33764. * @param meshLoaded callback for when the mesh has been loaded
  33765. */
  33766. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33767. private _setButtonValue;
  33768. private _changes;
  33769. private _checkChanges;
  33770. /**
  33771. * Disposes of th webVRCOntroller
  33772. */
  33773. dispose(): void;
  33774. }
  33775. }
  33776. declare module BABYLON {
  33777. /**
  33778. * Defines the WindowsMotionController object that the state of the windows motion controller
  33779. */
  33780. class WindowsMotionController extends WebVRController {
  33781. /**
  33782. * The base url used to load the left and right controller models
  33783. */
  33784. static MODEL_BASE_URL: string;
  33785. /**
  33786. * The name of the left controller model file
  33787. */
  33788. static MODEL_LEFT_FILENAME: string;
  33789. /**
  33790. * The name of the right controller model file
  33791. */
  33792. static MODEL_RIGHT_FILENAME: string;
  33793. /**
  33794. * The controller name prefix for this controller type
  33795. */
  33796. static readonly GAMEPAD_ID_PREFIX: string;
  33797. /**
  33798. * The controller id pattern for this controller type
  33799. */
  33800. private static readonly GAMEPAD_ID_PATTERN;
  33801. private _loadedMeshInfo;
  33802. private readonly _mapping;
  33803. /**
  33804. * Fired when the trackpad on this controller is clicked
  33805. */
  33806. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  33807. /**
  33808. * Fired when the trackpad on this controller is modified
  33809. */
  33810. onTrackpadValuesChangedObservable: Observable<StickValues>;
  33811. /**
  33812. * The current x and y values of this controller's trackpad
  33813. */
  33814. trackpad: StickValues;
  33815. /**
  33816. * Creates a new WindowsMotionController from a gamepad
  33817. * @param vrGamepad the gamepad that the controller should be created from
  33818. */
  33819. constructor(vrGamepad: any);
  33820. /**
  33821. * Fired when the trigger on this controller is modified
  33822. */
  33823. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33824. /**
  33825. * Fired when the menu button on this controller is modified
  33826. */
  33827. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33828. /**
  33829. * Fired when the grip button on this controller is modified
  33830. */
  33831. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33832. /**
  33833. * Fired when the thumbstick button on this controller is modified
  33834. */
  33835. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33836. /**
  33837. * Fired when the touchpad button on this controller is modified
  33838. */
  33839. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33840. /**
  33841. * Fired when the touchpad values on this controller are modified
  33842. */
  33843. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  33844. private _updateTrackpad;
  33845. /**
  33846. * Called once per frame by the engine.
  33847. */
  33848. update(): void;
  33849. /**
  33850. * Called once for each button that changed state since the last frame
  33851. * @param buttonIdx Which button index changed
  33852. * @param state New state of the button
  33853. * @param changes Which properties on the state changed since last frame
  33854. */
  33855. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33856. /**
  33857. * Moves the buttons on the controller mesh based on their current state
  33858. * @param buttonName the name of the button to move
  33859. * @param buttonValue the value of the button which determines the buttons new position
  33860. */
  33861. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  33862. /**
  33863. * Moves the axis on the controller mesh based on its current state
  33864. * @param axis the index of the axis
  33865. * @param axisValue the value of the axis which determines the meshes new position
  33866. * @hidden
  33867. */
  33868. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  33869. /**
  33870. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33871. * @param scene scene in which to add meshes
  33872. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33873. */
  33874. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  33875. /**
  33876. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  33877. * can be transformed by button presses and axes values, based on this._mapping.
  33878. *
  33879. * @param scene scene in which the meshes exist
  33880. * @param meshes list of meshes that make up the controller model to process
  33881. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  33882. */
  33883. private processModel;
  33884. private createMeshInfo;
  33885. /**
  33886. * Gets the ray of the controller in the direction the controller is pointing
  33887. * @param length the length the resulting ray should be
  33888. * @returns a ray in the direction the controller is pointing
  33889. */
  33890. getForwardRay(length?: number): Ray;
  33891. /**
  33892. * Disposes of the controller
  33893. */
  33894. dispose(): void;
  33895. }
  33896. }
  33897. declare module BABYLON {
  33898. /**
  33899. * Interface to implement to create a shadow generator compatible with BJS.
  33900. */
  33901. interface IShadowGenerator {
  33902. /**
  33903. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  33904. * @returns The render target texture if present otherwise, null
  33905. */
  33906. getShadowMap(): Nullable<RenderTargetTexture>;
  33907. /**
  33908. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  33909. * @returns The render target texture if the shadow map is present otherwise, null
  33910. */
  33911. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  33912. /**
  33913. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  33914. * @param subMesh The submesh we want to render in the shadow map
  33915. * @param useInstances Defines wether will draw in the map using instances
  33916. * @returns true if ready otherwise, false
  33917. */
  33918. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  33919. /**
  33920. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  33921. * @param defines Defines of the material we want to update
  33922. * @param lightIndex Index of the light in the enabled light list of the material
  33923. */
  33924. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  33925. /**
  33926. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  33927. * defined in the generator but impacting the effect).
  33928. * It implies the unifroms available on the materials are the standard BJS ones.
  33929. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  33930. * @param effect The effect we are binfing the information for
  33931. */
  33932. bindShadowLight(lightIndex: string, effect: Effect): void;
  33933. /**
  33934. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  33935. * (eq to shadow prjection matrix * light transform matrix)
  33936. * @returns The transform matrix used to create the shadow map
  33937. */
  33938. getTransformMatrix(): Matrix;
  33939. /**
  33940. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  33941. * Cube and 2D textures for instance.
  33942. */
  33943. recreateShadowMap(): void;
  33944. /**
  33945. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  33946. * @param onCompiled Callback triggered at the and of the effects compilation
  33947. * @param options Sets of optional options forcing the compilation with different modes
  33948. */
  33949. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  33950. useInstances: boolean;
  33951. }>): void;
  33952. /**
  33953. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  33954. * @param options Sets of optional options forcing the compilation with different modes
  33955. * @returns A promise that resolves when the compilation completes
  33956. */
  33957. forceCompilationAsync(options?: Partial<{
  33958. useInstances: boolean;
  33959. }>): Promise<void>;
  33960. /**
  33961. * Serializes the shadow generator setup to a json object.
  33962. * @returns The serialized JSON object
  33963. */
  33964. serialize(): any;
  33965. /**
  33966. * Disposes the Shadow map and related Textures and effects.
  33967. */
  33968. dispose(): void;
  33969. }
  33970. /**
  33971. * Default implementation IShadowGenerator.
  33972. * This is the main object responsible of generating shadows in the framework.
  33973. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  33974. */
  33975. class ShadowGenerator implements IShadowGenerator {
  33976. /**
  33977. * Shadow generator mode None: no filtering applied.
  33978. */
  33979. static readonly FILTER_NONE: number;
  33980. /**
  33981. * Shadow generator mode ESM: Exponential Shadow Mapping.
  33982. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  33983. */
  33984. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  33985. /**
  33986. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  33987. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  33988. */
  33989. static readonly FILTER_POISSONSAMPLING: number;
  33990. /**
  33991. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  33992. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  33993. */
  33994. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  33995. /**
  33996. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  33997. * edge artifacts on steep falloff.
  33998. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  33999. */
  34000. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  34001. /**
  34002. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  34003. * edge artifacts on steep falloff.
  34004. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  34005. */
  34006. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  34007. /**
  34008. * Shadow generator mode PCF: Percentage Closer Filtering
  34009. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  34010. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  34011. */
  34012. static readonly FILTER_PCF: number;
  34013. /**
  34014. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  34015. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  34016. * Contact Hardening
  34017. */
  34018. static readonly FILTER_PCSS: number;
  34019. /**
  34020. * Reserved for PCF and PCSS
  34021. * Highest Quality.
  34022. *
  34023. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  34024. *
  34025. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  34026. */
  34027. static readonly QUALITY_HIGH: number;
  34028. /**
  34029. * Reserved for PCF and PCSS
  34030. * Good tradeoff for quality/perf cross devices
  34031. *
  34032. * Execute PCF on a 3*3 kernel.
  34033. *
  34034. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  34035. */
  34036. static readonly QUALITY_MEDIUM: number;
  34037. /**
  34038. * Reserved for PCF and PCSS
  34039. * The lowest quality but the fastest.
  34040. *
  34041. * Execute PCF on a 1*1 kernel.
  34042. *
  34043. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  34044. */
  34045. static readonly QUALITY_LOW: number;
  34046. private _bias;
  34047. /**
  34048. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  34049. */
  34050. /**
  34051. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  34052. */
  34053. bias: number;
  34054. private _normalBias;
  34055. /**
  34056. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  34057. */
  34058. /**
  34059. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  34060. */
  34061. normalBias: number;
  34062. private _blurBoxOffset;
  34063. /**
  34064. * Gets the blur box offset: offset applied during the blur pass.
  34065. * Only usefull if useKernelBlur = false
  34066. */
  34067. /**
  34068. * Sets the blur box offset: offset applied during the blur pass.
  34069. * Only usefull if useKernelBlur = false
  34070. */
  34071. blurBoxOffset: number;
  34072. private _blurScale;
  34073. /**
  34074. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  34075. * 2 means half of the size.
  34076. */
  34077. /**
  34078. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  34079. * 2 means half of the size.
  34080. */
  34081. blurScale: number;
  34082. private _blurKernel;
  34083. /**
  34084. * Gets the blur kernel: kernel size of the blur pass.
  34085. * Only usefull if useKernelBlur = true
  34086. */
  34087. /**
  34088. * Sets the blur kernel: kernel size of the blur pass.
  34089. * Only usefull if useKernelBlur = true
  34090. */
  34091. blurKernel: number;
  34092. private _useKernelBlur;
  34093. /**
  34094. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  34095. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  34096. */
  34097. /**
  34098. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  34099. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  34100. */
  34101. useKernelBlur: boolean;
  34102. private _depthScale;
  34103. /**
  34104. * Gets the depth scale used in ESM mode.
  34105. */
  34106. /**
  34107. * Sets the depth scale used in ESM mode.
  34108. * This can override the scale stored on the light.
  34109. */
  34110. depthScale: number;
  34111. private _filter;
  34112. /**
  34113. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  34114. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  34115. */
  34116. /**
  34117. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  34118. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  34119. */
  34120. filter: number;
  34121. /**
  34122. * Gets if the current filter is set to Poisson Sampling.
  34123. */
  34124. /**
  34125. * Sets the current filter to Poisson Sampling.
  34126. */
  34127. usePoissonSampling: boolean;
  34128. /**
  34129. * Gets if the current filter is set to VSM.
  34130. * DEPRECATED. Should use useExponentialShadowMap instead.
  34131. */
  34132. /**
  34133. * Sets the current filter is to VSM.
  34134. * DEPRECATED. Should use useExponentialShadowMap instead.
  34135. */
  34136. useVarianceShadowMap: boolean;
  34137. /**
  34138. * Gets if the current filter is set to blurred VSM.
  34139. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  34140. */
  34141. /**
  34142. * Sets the current filter is to blurred VSM.
  34143. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  34144. */
  34145. useBlurVarianceShadowMap: boolean;
  34146. /**
  34147. * Gets if the current filter is set to ESM.
  34148. */
  34149. /**
  34150. * Sets the current filter is to ESM.
  34151. */
  34152. useExponentialShadowMap: boolean;
  34153. /**
  34154. * Gets if the current filter is set to filtered ESM.
  34155. */
  34156. /**
  34157. * Gets if the current filter is set to filtered ESM.
  34158. */
  34159. useBlurExponentialShadowMap: boolean;
  34160. /**
  34161. * Gets if the current filter is set to "close ESM" (using the inverse of the
  34162. * exponential to prevent steep falloff artifacts).
  34163. */
  34164. /**
  34165. * Sets the current filter to "close ESM" (using the inverse of the
  34166. * exponential to prevent steep falloff artifacts).
  34167. */
  34168. useCloseExponentialShadowMap: boolean;
  34169. /**
  34170. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  34171. * exponential to prevent steep falloff artifacts).
  34172. */
  34173. /**
  34174. * Sets the current filter to filtered "close ESM" (using the inverse of the
  34175. * exponential to prevent steep falloff artifacts).
  34176. */
  34177. useBlurCloseExponentialShadowMap: boolean;
  34178. /**
  34179. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  34180. */
  34181. /**
  34182. * Sets the current filter to "PCF" (percentage closer filtering).
  34183. */
  34184. usePercentageCloserFiltering: boolean;
  34185. private _filteringQuality;
  34186. /**
  34187. * Gets the PCF or PCSS Quality.
  34188. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  34189. */
  34190. /**
  34191. * Sets the PCF or PCSS Quality.
  34192. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  34193. */
  34194. filteringQuality: number;
  34195. /**
  34196. * Gets if the current filter is set to "PCSS" (contact hardening).
  34197. */
  34198. /**
  34199. * Sets the current filter to "PCSS" (contact hardening).
  34200. */
  34201. useContactHardeningShadow: boolean;
  34202. private _contactHardeningLightSizeUVRatio;
  34203. /**
  34204. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  34205. * Using a ratio helps keeping shape stability independently of the map size.
  34206. *
  34207. * It does not account for the light projection as it was having too much
  34208. * instability during the light setup or during light position changes.
  34209. *
  34210. * Only valid if useContactHardeningShadow is true.
  34211. */
  34212. /**
  34213. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  34214. * Using a ratio helps keeping shape stability independently of the map size.
  34215. *
  34216. * It does not account for the light projection as it was having too much
  34217. * instability during the light setup or during light position changes.
  34218. *
  34219. * Only valid if useContactHardeningShadow is true.
  34220. */
  34221. contactHardeningLightSizeUVRatio: number;
  34222. private _darkness;
  34223. /**
  34224. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  34225. * 0 means strongest and 1 would means no shadow.
  34226. * @returns the darkness.
  34227. */
  34228. getDarkness(): number;
  34229. /**
  34230. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  34231. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  34232. * @returns the shadow generator allowing fluent coding.
  34233. */
  34234. setDarkness(darkness: number): ShadowGenerator;
  34235. private _transparencyShadow;
  34236. /**
  34237. * Sets the ability to have transparent shadow (boolean).
  34238. * @param transparent True if transparent else False
  34239. * @returns the shadow generator allowing fluent coding
  34240. */
  34241. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  34242. private _shadowMap;
  34243. private _shadowMap2;
  34244. /**
  34245. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  34246. * @returns The render target texture if present otherwise, null
  34247. */
  34248. getShadowMap(): Nullable<RenderTargetTexture>;
  34249. /**
  34250. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  34251. * @returns The render target texture if the shadow map is present otherwise, null
  34252. */
  34253. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  34254. /**
  34255. * Helper function to add a mesh and its descendants to the list of shadow casters.
  34256. * @param mesh Mesh to add
  34257. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  34258. * @returns the Shadow Generator itself
  34259. */
  34260. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  34261. /**
  34262. * Helper function to remove a mesh and its descendants from the list of shadow casters
  34263. * @param mesh Mesh to remove
  34264. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  34265. * @returns the Shadow Generator itself
  34266. */
  34267. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  34268. /**
  34269. * Controls the extent to which the shadows fade out at the edge of the frustum
  34270. * Used only by directionals and spots
  34271. */
  34272. frustumEdgeFalloff: number;
  34273. private _light;
  34274. /**
  34275. * Returns the associated light object.
  34276. * @returns the light generating the shadow
  34277. */
  34278. getLight(): IShadowLight;
  34279. /**
  34280. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  34281. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  34282. * It might on the other hand introduce peter panning.
  34283. */
  34284. forceBackFacesOnly: boolean;
  34285. private _scene;
  34286. private _lightDirection;
  34287. private _effect;
  34288. private _viewMatrix;
  34289. private _projectionMatrix;
  34290. private _transformMatrix;
  34291. private _cachedPosition;
  34292. private _cachedDirection;
  34293. private _cachedDefines;
  34294. private _currentRenderID;
  34295. private _boxBlurPostprocess;
  34296. private _kernelBlurXPostprocess;
  34297. private _kernelBlurYPostprocess;
  34298. private _blurPostProcesses;
  34299. private _mapSize;
  34300. private _currentFaceIndex;
  34301. private _currentFaceIndexCache;
  34302. private _textureType;
  34303. private _defaultTextureMatrix;
  34304. /**
  34305. * Creates a ShadowGenerator object.
  34306. * A ShadowGenerator is the required tool to use the shadows.
  34307. * Each light casting shadows needs to use its own ShadowGenerator.
  34308. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  34309. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  34310. * @param light The light object generating the shadows.
  34311. * @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.
  34312. */
  34313. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  34314. private _initializeGenerator;
  34315. private _initializeShadowMap;
  34316. private _initializeBlurRTTAndPostProcesses;
  34317. private _renderForShadowMap;
  34318. private _renderSubMeshForShadowMap;
  34319. private _applyFilterValues;
  34320. /**
  34321. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34322. * @param onCompiled Callback triggered at the and of the effects compilation
  34323. * @param options Sets of optional options forcing the compilation with different modes
  34324. */
  34325. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  34326. useInstances: boolean;
  34327. }>): void;
  34328. /**
  34329. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  34330. * @param options Sets of optional options forcing the compilation with different modes
  34331. * @returns A promise that resolves when the compilation completes
  34332. */
  34333. forceCompilationAsync(options?: Partial<{
  34334. useInstances: boolean;
  34335. }>): Promise<void>;
  34336. /**
  34337. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  34338. * @param subMesh The submesh we want to render in the shadow map
  34339. * @param useInstances Defines wether will draw in the map using instances
  34340. * @returns true if ready otherwise, false
  34341. */
  34342. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34343. /**
  34344. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  34345. * @param defines Defines of the material we want to update
  34346. * @param lightIndex Index of the light in the enabled light list of the material
  34347. */
  34348. prepareDefines(defines: any, lightIndex: number): void;
  34349. /**
  34350. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  34351. * defined in the generator but impacting the effect).
  34352. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  34353. * @param effect The effect we are binfing the information for
  34354. */
  34355. bindShadowLight(lightIndex: string, effect: Effect): void;
  34356. /**
  34357. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  34358. * (eq to shadow prjection matrix * light transform matrix)
  34359. * @returns The transform matrix used to create the shadow map
  34360. */
  34361. getTransformMatrix(): Matrix;
  34362. /**
  34363. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  34364. * Cube and 2D textures for instance.
  34365. */
  34366. recreateShadowMap(): void;
  34367. private _disposeBlurPostProcesses;
  34368. private _disposeRTTandPostProcesses;
  34369. /**
  34370. * Disposes the ShadowGenerator.
  34371. * Returns nothing.
  34372. */
  34373. dispose(): void;
  34374. /**
  34375. * Serializes the shadow generator setup to a json object.
  34376. * @returns The serialized JSON object
  34377. */
  34378. serialize(): any;
  34379. /**
  34380. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  34381. * @param parsedShadowGenerator The JSON object to parse
  34382. * @param scene The scene to create the shadow map for
  34383. * @returns The parsed shadow generator
  34384. */
  34385. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  34386. }
  34387. }
  34388. declare module BABYLON {
  34389. }
  34390. declare module BABYLON {
  34391. /**
  34392. * Background material used to create an efficient environement around your scene.
  34393. */
  34394. class BackgroundMaterial extends PushMaterial {
  34395. /**
  34396. * Standard reflectance value at parallel view angle.
  34397. */
  34398. static StandardReflectance0: number;
  34399. /**
  34400. * Standard reflectance value at grazing angle.
  34401. */
  34402. static StandardReflectance90: number;
  34403. protected _primaryColor: Color3;
  34404. /**
  34405. * Key light Color (multiply against the environement texture)
  34406. */
  34407. primaryColor: Color3;
  34408. protected __perceptualColor: Nullable<Color3>;
  34409. /**
  34410. * Experimental Internal Use Only.
  34411. *
  34412. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  34413. * This acts as a helper to set the primary color to a more "human friendly" value.
  34414. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  34415. * output color as close as possible from the chosen value.
  34416. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  34417. * part of lighting setup.)
  34418. */
  34419. _perceptualColor: Nullable<Color3>;
  34420. protected _primaryColorShadowLevel: float;
  34421. /**
  34422. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  34423. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  34424. */
  34425. primaryColorShadowLevel: float;
  34426. protected _primaryColorHighlightLevel: float;
  34427. /**
  34428. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  34429. * The primary color is used at the level chosen to define what the white area would look.
  34430. */
  34431. primaryColorHighlightLevel: float;
  34432. protected _reflectionTexture: Nullable<BaseTexture>;
  34433. /**
  34434. * Reflection Texture used in the material.
  34435. * Should be author in a specific way for the best result (refer to the documentation).
  34436. */
  34437. reflectionTexture: Nullable<BaseTexture>;
  34438. protected _reflectionBlur: float;
  34439. /**
  34440. * Reflection Texture level of blur.
  34441. *
  34442. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  34443. * texture twice.
  34444. */
  34445. reflectionBlur: float;
  34446. protected _diffuseTexture: Nullable<BaseTexture>;
  34447. /**
  34448. * Diffuse Texture used in the material.
  34449. * Should be author in a specific way for the best result (refer to the documentation).
  34450. */
  34451. diffuseTexture: Nullable<BaseTexture>;
  34452. protected _shadowLights: Nullable<IShadowLight[]>;
  34453. /**
  34454. * Specify the list of lights casting shadow on the material.
  34455. * All scene shadow lights will be included if null.
  34456. */
  34457. shadowLights: Nullable<IShadowLight[]>;
  34458. protected _shadowLevel: float;
  34459. /**
  34460. * Helps adjusting the shadow to a softer level if required.
  34461. * 0 means black shadows and 1 means no shadows.
  34462. */
  34463. shadowLevel: float;
  34464. protected _sceneCenter: Vector3;
  34465. /**
  34466. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  34467. * It is usually zero but might be interesting to modify according to your setup.
  34468. */
  34469. sceneCenter: Vector3;
  34470. protected _opacityFresnel: boolean;
  34471. /**
  34472. * This helps specifying that the material is falling off to the sky box at grazing angle.
  34473. * This helps ensuring a nice transition when the camera goes under the ground.
  34474. */
  34475. opacityFresnel: boolean;
  34476. protected _reflectionFresnel: boolean;
  34477. /**
  34478. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  34479. * This helps adding a mirror texture on the ground.
  34480. */
  34481. reflectionFresnel: boolean;
  34482. protected _reflectionFalloffDistance: number;
  34483. /**
  34484. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  34485. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  34486. */
  34487. reflectionFalloffDistance: number;
  34488. protected _reflectionAmount: number;
  34489. /**
  34490. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  34491. */
  34492. reflectionAmount: number;
  34493. protected _reflectionReflectance0: number;
  34494. /**
  34495. * This specifies the weight of the reflection at grazing angle.
  34496. */
  34497. reflectionReflectance0: number;
  34498. protected _reflectionReflectance90: number;
  34499. /**
  34500. * This specifies the weight of the reflection at a perpendicular point of view.
  34501. */
  34502. reflectionReflectance90: number;
  34503. /**
  34504. * Sets the reflection reflectance fresnel values according to the default standard
  34505. * empirically know to work well :-)
  34506. */
  34507. reflectionStandardFresnelWeight: number;
  34508. protected _useRGBColor: boolean;
  34509. /**
  34510. * Helps to directly use the maps channels instead of their level.
  34511. */
  34512. useRGBColor: boolean;
  34513. protected _enableNoise: boolean;
  34514. /**
  34515. * This helps reducing the banding effect that could occur on the background.
  34516. */
  34517. enableNoise: boolean;
  34518. /**
  34519. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  34520. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  34521. * Recommended to be keep at 1.0 except for special cases.
  34522. */
  34523. fovMultiplier: number;
  34524. private _fovMultiplier;
  34525. /**
  34526. * Enable the FOV adjustment feature controlled by fovMultiplier.
  34527. */
  34528. useEquirectangularFOV: boolean;
  34529. private _maxSimultaneousLights;
  34530. /**
  34531. * Number of Simultaneous lights allowed on the material.
  34532. */
  34533. maxSimultaneousLights: int;
  34534. /**
  34535. * Default configuration related to image processing available in the Background Material.
  34536. */
  34537. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34538. /**
  34539. * Keep track of the image processing observer to allow dispose and replace.
  34540. */
  34541. private _imageProcessingObserver;
  34542. /**
  34543. * Attaches a new image processing configuration to the PBR Material.
  34544. * @param configuration (if null the scene configuration will be use)
  34545. */
  34546. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  34547. /**
  34548. * Gets the image processing configuration used either in this material.
  34549. */
  34550. /**
  34551. * Sets the Default image processing configuration used either in the this material.
  34552. *
  34553. * If sets to null, the scene one is in use.
  34554. */
  34555. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  34556. /**
  34557. * Gets wether the color curves effect is enabled.
  34558. */
  34559. /**
  34560. * Sets wether the color curves effect is enabled.
  34561. */
  34562. cameraColorCurvesEnabled: boolean;
  34563. /**
  34564. * Gets wether the color grading effect is enabled.
  34565. */
  34566. /**
  34567. * Gets wether the color grading effect is enabled.
  34568. */
  34569. cameraColorGradingEnabled: boolean;
  34570. /**
  34571. * Gets wether tonemapping is enabled or not.
  34572. */
  34573. /**
  34574. * Sets wether tonemapping is enabled or not
  34575. */
  34576. cameraToneMappingEnabled: boolean;
  34577. /**
  34578. * The camera exposure used on this material.
  34579. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  34580. * This corresponds to a photographic exposure.
  34581. */
  34582. /**
  34583. * The camera exposure used on this material.
  34584. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  34585. * This corresponds to a photographic exposure.
  34586. */
  34587. cameraExposure: float;
  34588. /**
  34589. * Gets The camera contrast used on this material.
  34590. */
  34591. /**
  34592. * Sets The camera contrast used on this material.
  34593. */
  34594. cameraContrast: float;
  34595. /**
  34596. * Gets the Color Grading 2D Lookup Texture.
  34597. */
  34598. /**
  34599. * Sets the Color Grading 2D Lookup Texture.
  34600. */
  34601. cameraColorGradingTexture: Nullable<BaseTexture>;
  34602. /**
  34603. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  34604. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  34605. * 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;
  34606. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  34607. */
  34608. /**
  34609. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  34610. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  34611. * 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;
  34612. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  34613. */
  34614. cameraColorCurves: Nullable<ColorCurves>;
  34615. /**
  34616. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  34617. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  34618. */
  34619. switchToBGR: boolean;
  34620. private _renderTargets;
  34621. private _reflectionControls;
  34622. private _white;
  34623. private _primaryShadowColor;
  34624. private _primaryHighlightColor;
  34625. /**
  34626. * Instantiates a Background Material in the given scene
  34627. * @param name The friendly name of the material
  34628. * @param scene The scene to add the material to
  34629. */
  34630. constructor(name: string, scene: Scene);
  34631. /**
  34632. * The entire material has been created in order to prevent overdraw.
  34633. * @returns false
  34634. */
  34635. needAlphaTesting(): boolean;
  34636. /**
  34637. * The entire material has been created in order to prevent overdraw.
  34638. * @returns true if blending is enable
  34639. */
  34640. needAlphaBlending(): boolean;
  34641. /**
  34642. * Checks wether the material is ready to be rendered for a given mesh.
  34643. * @param mesh The mesh to render
  34644. * @param subMesh The submesh to check against
  34645. * @param useInstances Specify wether or not the material is used with instances
  34646. * @returns true if all the dependencies are ready (Textures, Effects...)
  34647. */
  34648. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  34649. /**
  34650. * Compute the primary color according to the chosen perceptual color.
  34651. */
  34652. private _computePrimaryColorFromPerceptualColor;
  34653. /**
  34654. * Compute the highlights and shadow colors according to their chosen levels.
  34655. */
  34656. private _computePrimaryColors;
  34657. /**
  34658. * Build the uniform buffer used in the material.
  34659. */
  34660. buildUniformLayout(): void;
  34661. /**
  34662. * Unbind the material.
  34663. */
  34664. unbind(): void;
  34665. /**
  34666. * Bind only the world matrix to the material.
  34667. * @param world The world matrix to bind.
  34668. */
  34669. bindOnlyWorldMatrix(world: Matrix): void;
  34670. /**
  34671. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  34672. * @param world The world matrix to bind.
  34673. * @param subMesh The submesh to bind for.
  34674. */
  34675. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  34676. /**
  34677. * Dispose the material.
  34678. * @param forceDisposeEffect Force disposal of the associated effect.
  34679. * @param forceDisposeTextures Force disposal of the associated textures.
  34680. */
  34681. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  34682. /**
  34683. * Clones the material.
  34684. * @param name The cloned name.
  34685. * @returns The cloned material.
  34686. */
  34687. clone(name: string): BackgroundMaterial;
  34688. /**
  34689. * Serializes the current material to its JSON representation.
  34690. * @returns The JSON representation.
  34691. */
  34692. serialize(): any;
  34693. /**
  34694. * Gets the class name of the material
  34695. * @returns "BackgroundMaterial"
  34696. */
  34697. getClassName(): string;
  34698. /**
  34699. * Parse a JSON input to create back a background material.
  34700. * @param source The JSON data to parse
  34701. * @param scene The scene to create the parsed material in
  34702. * @param rootUrl The root url of the assets the material depends upon
  34703. * @returns the instantiated BackgroundMaterial.
  34704. */
  34705. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  34706. }
  34707. }
  34708. declare module BABYLON {
  34709. /**
  34710. * The Physically based material base class of BJS.
  34711. *
  34712. * This offers the main features of a standard PBR material.
  34713. * For more information, please refer to the documentation :
  34714. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  34715. */
  34716. abstract class PBRBaseMaterial extends PushMaterial {
  34717. /**
  34718. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  34719. */
  34720. static readonly LIGHTFALLOFF_PHYSICAL: number;
  34721. /**
  34722. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  34723. * to enhance interoperability with other engines.
  34724. */
  34725. static readonly LIGHTFALLOFF_GLTF: number;
  34726. /**
  34727. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  34728. * to enhance interoperability with other materials.
  34729. */
  34730. static readonly LIGHTFALLOFF_STANDARD: number;
  34731. /**
  34732. * Intensity of the direct lights e.g. the four lights available in your scene.
  34733. * This impacts both the direct diffuse and specular highlights.
  34734. */
  34735. protected _directIntensity: number;
  34736. /**
  34737. * Intensity of the emissive part of the material.
  34738. * This helps controlling the emissive effect without modifying the emissive color.
  34739. */
  34740. protected _emissiveIntensity: number;
  34741. /**
  34742. * Intensity of the environment e.g. how much the environment will light the object
  34743. * either through harmonics for rough material or through the refelction for shiny ones.
  34744. */
  34745. protected _environmentIntensity: number;
  34746. /**
  34747. * This is a special control allowing the reduction of the specular highlights coming from the
  34748. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  34749. */
  34750. protected _specularIntensity: number;
  34751. /**
  34752. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  34753. */
  34754. private _lightingInfos;
  34755. /**
  34756. * Debug Control allowing disabling the bump map on this material.
  34757. */
  34758. protected _disableBumpMap: boolean;
  34759. /**
  34760. * AKA Diffuse Texture in standard nomenclature.
  34761. */
  34762. protected _albedoTexture: BaseTexture;
  34763. /**
  34764. * AKA Occlusion Texture in other nomenclature.
  34765. */
  34766. protected _ambientTexture: BaseTexture;
  34767. /**
  34768. * AKA Occlusion Texture Intensity in other nomenclature.
  34769. */
  34770. protected _ambientTextureStrength: number;
  34771. /**
  34772. * Stores the alpha values in a texture.
  34773. */
  34774. protected _opacityTexture: BaseTexture;
  34775. /**
  34776. * Stores the reflection values in a texture.
  34777. */
  34778. protected _reflectionTexture: BaseTexture;
  34779. /**
  34780. * Stores the refraction values in a texture.
  34781. */
  34782. protected _refractionTexture: BaseTexture;
  34783. /**
  34784. * Stores the emissive values in a texture.
  34785. */
  34786. protected _emissiveTexture: BaseTexture;
  34787. /**
  34788. * AKA Specular texture in other nomenclature.
  34789. */
  34790. protected _reflectivityTexture: BaseTexture;
  34791. /**
  34792. * Used to switch from specular/glossiness to metallic/roughness workflow.
  34793. */
  34794. protected _metallicTexture: BaseTexture;
  34795. /**
  34796. * Specifies the metallic scalar of the metallic/roughness workflow.
  34797. * Can also be used to scale the metalness values of the metallic texture.
  34798. */
  34799. protected _metallic: Nullable<number>;
  34800. /**
  34801. * Specifies the roughness scalar of the metallic/roughness workflow.
  34802. * Can also be used to scale the roughness values of the metallic texture.
  34803. */
  34804. protected _roughness: Nullable<number>;
  34805. /**
  34806. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  34807. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  34808. */
  34809. protected _microSurfaceTexture: BaseTexture;
  34810. /**
  34811. * Stores surface normal data used to displace a mesh in a texture.
  34812. */
  34813. protected _bumpTexture: BaseTexture;
  34814. /**
  34815. * Stores the pre-calculated light information of a mesh in a texture.
  34816. */
  34817. protected _lightmapTexture: BaseTexture;
  34818. /**
  34819. * The color of a material in ambient lighting.
  34820. */
  34821. protected _ambientColor: Color3;
  34822. /**
  34823. * AKA Diffuse Color in other nomenclature.
  34824. */
  34825. protected _albedoColor: Color3;
  34826. /**
  34827. * AKA Specular Color in other nomenclature.
  34828. */
  34829. protected _reflectivityColor: Color3;
  34830. /**
  34831. * The color applied when light is reflected from a material.
  34832. */
  34833. protected _reflectionColor: Color3;
  34834. /**
  34835. * The color applied when light is emitted from a material.
  34836. */
  34837. protected _emissiveColor: Color3;
  34838. /**
  34839. * AKA Glossiness in other nomenclature.
  34840. */
  34841. protected _microSurface: number;
  34842. /**
  34843. * source material index of refraction (IOR)' / 'destination material IOR.
  34844. */
  34845. protected _indexOfRefraction: number;
  34846. /**
  34847. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  34848. */
  34849. protected _invertRefractionY: boolean;
  34850. /**
  34851. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  34852. * Materials half opaque for instance using refraction could benefit from this control.
  34853. */
  34854. protected _linkRefractionWithTransparency: boolean;
  34855. /**
  34856. * Specifies that the material will use the light map as a show map.
  34857. */
  34858. protected _useLightmapAsShadowmap: boolean;
  34859. /**
  34860. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  34861. * makes the reflect vector face the model (under horizon).
  34862. */
  34863. protected _useHorizonOcclusion: boolean;
  34864. /**
  34865. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  34866. * too much the area relying on ambient texture to define their ambient occlusion.
  34867. */
  34868. protected _useRadianceOcclusion: boolean;
  34869. /**
  34870. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  34871. */
  34872. protected _useAlphaFromAlbedoTexture: boolean;
  34873. /**
  34874. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  34875. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  34876. */
  34877. protected _useSpecularOverAlpha: boolean;
  34878. /**
  34879. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  34880. */
  34881. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  34882. /**
  34883. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  34884. */
  34885. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  34886. /**
  34887. * Specifies if the metallic texture contains the roughness information in its green channel.
  34888. */
  34889. protected _useRoughnessFromMetallicTextureGreen: boolean;
  34890. /**
  34891. * Specifies if the metallic texture contains the metallness information in its blue channel.
  34892. */
  34893. protected _useMetallnessFromMetallicTextureBlue: boolean;
  34894. /**
  34895. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  34896. */
  34897. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  34898. /**
  34899. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  34900. */
  34901. protected _useAmbientInGrayScale: boolean;
  34902. /**
  34903. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  34904. * The material will try to infer what glossiness each pixel should be.
  34905. */
  34906. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  34907. /**
  34908. * Defines the falloff type used in this material.
  34909. * It by default is Physical.
  34910. */
  34911. protected _lightFalloff: number;
  34912. /**
  34913. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  34914. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  34915. */
  34916. protected _useRadianceOverAlpha: boolean;
  34917. /**
  34918. * Allows using an object space normal map (instead of tangent space).
  34919. */
  34920. protected _useObjectSpaceNormalMap: boolean;
  34921. /**
  34922. * Allows using the bump map in parallax mode.
  34923. */
  34924. protected _useParallax: boolean;
  34925. /**
  34926. * Allows using the bump map in parallax occlusion mode.
  34927. */
  34928. protected _useParallaxOcclusion: boolean;
  34929. /**
  34930. * Controls the scale bias of the parallax mode.
  34931. */
  34932. protected _parallaxScaleBias: number;
  34933. /**
  34934. * If sets to true, disables all the lights affecting the material.
  34935. */
  34936. protected _disableLighting: boolean;
  34937. /**
  34938. * Number of Simultaneous lights allowed on the material.
  34939. */
  34940. protected _maxSimultaneousLights: number;
  34941. /**
  34942. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  34943. */
  34944. protected _invertNormalMapX: boolean;
  34945. /**
  34946. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  34947. */
  34948. protected _invertNormalMapY: boolean;
  34949. /**
  34950. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  34951. */
  34952. protected _twoSidedLighting: boolean;
  34953. /**
  34954. * Defines the alpha limits in alpha test mode.
  34955. */
  34956. protected _alphaCutOff: number;
  34957. /**
  34958. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  34959. */
  34960. protected _forceAlphaTest: boolean;
  34961. /**
  34962. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  34963. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  34964. */
  34965. protected _useAlphaFresnel: boolean;
  34966. /**
  34967. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  34968. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  34969. */
  34970. protected _useLinearAlphaFresnel: boolean;
  34971. /**
  34972. * The transparency mode of the material.
  34973. */
  34974. protected _transparencyMode: Nullable<number>;
  34975. /**
  34976. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  34977. * from cos thetav and roughness:
  34978. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  34979. */
  34980. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  34981. /**
  34982. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  34983. */
  34984. protected _forceIrradianceInFragment: boolean;
  34985. /**
  34986. * Force normal to face away from face.
  34987. */
  34988. protected _forceNormalForward: boolean;
  34989. /**
  34990. * Enables specular anti aliasing in the PBR shader.
  34991. * It will both interacts on the Geometry for analytical and IBL lighting.
  34992. * It also prefilter the roughness map based on the bump values.
  34993. */
  34994. protected _enableSpecularAntiAliasing: boolean;
  34995. /**
  34996. * Default configuration related to image processing available in the PBR Material.
  34997. */
  34998. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34999. /**
  35000. * Keep track of the image processing observer to allow dispose and replace.
  35001. */
  35002. private _imageProcessingObserver;
  35003. /**
  35004. * Attaches a new image processing configuration to the PBR Material.
  35005. * @param configuration
  35006. */
  35007. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  35008. /**
  35009. * Stores the available render targets.
  35010. */
  35011. private _renderTargets;
  35012. /**
  35013. * Sets the global ambient color for the material used in lighting calculations.
  35014. */
  35015. private _globalAmbientColor;
  35016. /**
  35017. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  35018. */
  35019. private _useLogarithmicDepth;
  35020. /**
  35021. * If set to true, no lighting calculations will be applied.
  35022. */
  35023. private _unlit;
  35024. /**
  35025. * Instantiates a new PBRMaterial instance.
  35026. *
  35027. * @param name The material name
  35028. * @param scene The scene the material will be use in.
  35029. */
  35030. constructor(name: string, scene: Scene);
  35031. /**
  35032. * Gets the name of the material class.
  35033. */
  35034. getClassName(): string;
  35035. /**
  35036. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  35037. */
  35038. /**
  35039. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  35040. */
  35041. useLogarithmicDepth: boolean;
  35042. /**
  35043. * Gets the current transparency mode.
  35044. */
  35045. /**
  35046. * Sets the transparency mode of the material.
  35047. *
  35048. * | Value | Type | Description |
  35049. * | ----- | ----------------------------------- | ----------- |
  35050. * | 0 | OPAQUE | |
  35051. * | 1 | ALPHATEST | |
  35052. * | 2 | ALPHABLEND | |
  35053. * | 3 | ALPHATESTANDBLEND | |
  35054. *
  35055. */
  35056. transparencyMode: Nullable<number>;
  35057. /**
  35058. * Returns true if alpha blending should be disabled.
  35059. */
  35060. private readonly _disableAlphaBlending;
  35061. /**
  35062. * Specifies whether or not this material should be rendered in alpha blend mode.
  35063. */
  35064. needAlphaBlending(): boolean;
  35065. /**
  35066. * Specifies if the mesh will require alpha blending.
  35067. * @param mesh - BJS mesh.
  35068. */
  35069. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  35070. /**
  35071. * Specifies whether or not this material should be rendered in alpha test mode.
  35072. */
  35073. needAlphaTesting(): boolean;
  35074. /**
  35075. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  35076. */
  35077. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  35078. /**
  35079. * Gets the texture used for the alpha test.
  35080. */
  35081. getAlphaTestTexture(): BaseTexture;
  35082. /**
  35083. * Stores the reflectivity values based on metallic roughness workflow.
  35084. */
  35085. private static _scaledReflectivity;
  35086. /**
  35087. * Specifies that the submesh is ready to be used.
  35088. * @param mesh - BJS mesh.
  35089. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  35090. * @param useInstances - Specifies that instances should be used.
  35091. * @returns - boolean indicating that the submesh is ready or not.
  35092. */
  35093. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  35094. /**
  35095. * Specifies if the material uses metallic roughness workflow.
  35096. * @returns boolean specifiying if the material uses metallic roughness workflow.
  35097. */
  35098. isMetallicWorkflow(): boolean;
  35099. private _prepareEffect;
  35100. private _prepareDefines;
  35101. /**
  35102. * Force shader compilation
  35103. */
  35104. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  35105. clipPlane: boolean;
  35106. }>): void;
  35107. /**
  35108. * Initializes the uniform buffer layout for the shader.
  35109. */
  35110. buildUniformLayout(): void;
  35111. /**
  35112. * Unbinds the textures.
  35113. */
  35114. unbind(): void;
  35115. /**
  35116. * Binds the submesh data.
  35117. * @param world - The world matrix.
  35118. * @param mesh - The BJS mesh.
  35119. * @param subMesh - A submesh of the BJS mesh.
  35120. */
  35121. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  35122. /**
  35123. * Returns the animatable textures.
  35124. * @returns - Array of animatable textures.
  35125. */
  35126. getAnimatables(): IAnimatable[];
  35127. /**
  35128. * Returns the texture used for reflections.
  35129. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  35130. */
  35131. private _getReflectionTexture;
  35132. /**
  35133. * Returns the texture used for refraction or null if none is used.
  35134. * @returns - Refection texture if present. If no refraction texture and refraction
  35135. * is linked with transparency, returns environment texture. Otherwise, returns null.
  35136. */
  35137. private _getRefractionTexture;
  35138. /**
  35139. * Disposes the resources of the material.
  35140. * @param forceDisposeEffect - Forces the disposal of effects.
  35141. * @param forceDisposeTextures - Forces the disposal of all textures.
  35142. */
  35143. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  35144. }
  35145. }
  35146. declare module BABYLON {
  35147. /**
  35148. * The Physically based simple base material of BJS.
  35149. *
  35150. * This enables better naming and convention enforcements on top of the pbrMaterial.
  35151. * It is used as the base class for both the specGloss and metalRough conventions.
  35152. */
  35153. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  35154. /**
  35155. * Number of Simultaneous lights allowed on the material.
  35156. */
  35157. maxSimultaneousLights: number;
  35158. /**
  35159. * If sets to true, disables all the lights affecting the material.
  35160. */
  35161. disableLighting: boolean;
  35162. /**
  35163. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  35164. */
  35165. environmentTexture: BaseTexture;
  35166. /**
  35167. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  35168. */
  35169. invertNormalMapX: boolean;
  35170. /**
  35171. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  35172. */
  35173. invertNormalMapY: boolean;
  35174. /**
  35175. * Normal map used in the model.
  35176. */
  35177. normalTexture: BaseTexture;
  35178. /**
  35179. * Emissivie color used to self-illuminate the model.
  35180. */
  35181. emissiveColor: Color3;
  35182. /**
  35183. * Emissivie texture used to self-illuminate the model.
  35184. */
  35185. emissiveTexture: BaseTexture;
  35186. /**
  35187. * Occlusion Channel Strenght.
  35188. */
  35189. occlusionStrength: number;
  35190. /**
  35191. * Occlusion Texture of the material (adding extra occlusion effects).
  35192. */
  35193. occlusionTexture: BaseTexture;
  35194. /**
  35195. * Defines the alpha limits in alpha test mode.
  35196. */
  35197. alphaCutOff: number;
  35198. /**
  35199. * Gets the current double sided mode.
  35200. */
  35201. /**
  35202. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  35203. */
  35204. doubleSided: boolean;
  35205. lightmapTexture: BaseTexture;
  35206. useLightmapAsShadowmap: boolean;
  35207. /**
  35208. * Return the active textures of the material.
  35209. */
  35210. getActiveTextures(): BaseTexture[];
  35211. hasTexture(texture: BaseTexture): boolean;
  35212. /**
  35213. * Instantiates a new PBRMaterial instance.
  35214. *
  35215. * @param name The material name
  35216. * @param scene The scene the material will be use in.
  35217. */
  35218. constructor(name: string, scene: Scene);
  35219. getClassName(): string;
  35220. }
  35221. }
  35222. declare module BABYLON {
  35223. /**
  35224. * The Physically based material of BJS.
  35225. *
  35226. * This offers the main features of a standard PBR material.
  35227. * For more information, please refer to the documentation :
  35228. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  35229. */
  35230. class PBRMaterial extends PBRBaseMaterial {
  35231. /**
  35232. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  35233. */
  35234. static readonly PBRMATERIAL_OPAQUE: number;
  35235. /**
  35236. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  35237. */
  35238. static readonly PBRMATERIAL_ALPHATEST: number;
  35239. /**
  35240. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  35241. */
  35242. static readonly PBRMATERIAL_ALPHABLEND: number;
  35243. /**
  35244. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  35245. * They are also discarded below the alpha cutoff threshold to improve performances.
  35246. */
  35247. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  35248. /**
  35249. * Intensity of the direct lights e.g. the four lights available in your scene.
  35250. * This impacts both the direct diffuse and specular highlights.
  35251. */
  35252. directIntensity: number;
  35253. /**
  35254. * Intensity of the emissive part of the material.
  35255. * This helps controlling the emissive effect without modifying the emissive color.
  35256. */
  35257. emissiveIntensity: number;
  35258. /**
  35259. * Intensity of the environment e.g. how much the environment will light the object
  35260. * either through harmonics for rough material or through the refelction for shiny ones.
  35261. */
  35262. environmentIntensity: number;
  35263. /**
  35264. * This is a special control allowing the reduction of the specular highlights coming from the
  35265. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  35266. */
  35267. specularIntensity: number;
  35268. /**
  35269. * Debug Control allowing disabling the bump map on this material.
  35270. */
  35271. disableBumpMap: boolean;
  35272. /**
  35273. * AKA Diffuse Texture in standard nomenclature.
  35274. */
  35275. albedoTexture: BaseTexture;
  35276. /**
  35277. * AKA Occlusion Texture in other nomenclature.
  35278. */
  35279. ambientTexture: BaseTexture;
  35280. /**
  35281. * AKA Occlusion Texture Intensity in other nomenclature.
  35282. */
  35283. ambientTextureStrength: number;
  35284. /**
  35285. * Stores the alpha values in a texture.
  35286. */
  35287. opacityTexture: BaseTexture;
  35288. /**
  35289. * Stores the reflection values in a texture.
  35290. */
  35291. reflectionTexture: Nullable<BaseTexture>;
  35292. /**
  35293. * Stores the emissive values in a texture.
  35294. */
  35295. emissiveTexture: BaseTexture;
  35296. /**
  35297. * AKA Specular texture in other nomenclature.
  35298. */
  35299. reflectivityTexture: BaseTexture;
  35300. /**
  35301. * Used to switch from specular/glossiness to metallic/roughness workflow.
  35302. */
  35303. metallicTexture: BaseTexture;
  35304. /**
  35305. * Specifies the metallic scalar of the metallic/roughness workflow.
  35306. * Can also be used to scale the metalness values of the metallic texture.
  35307. */
  35308. metallic: Nullable<number>;
  35309. /**
  35310. * Specifies the roughness scalar of the metallic/roughness workflow.
  35311. * Can also be used to scale the roughness values of the metallic texture.
  35312. */
  35313. roughness: Nullable<number>;
  35314. /**
  35315. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  35316. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  35317. */
  35318. microSurfaceTexture: BaseTexture;
  35319. /**
  35320. * Stores surface normal data used to displace a mesh in a texture.
  35321. */
  35322. bumpTexture: BaseTexture;
  35323. /**
  35324. * Stores the pre-calculated light information of a mesh in a texture.
  35325. */
  35326. lightmapTexture: BaseTexture;
  35327. /**
  35328. * Stores the refracted light information in a texture.
  35329. */
  35330. refractionTexture: BaseTexture;
  35331. /**
  35332. * The color of a material in ambient lighting.
  35333. */
  35334. ambientColor: Color3;
  35335. /**
  35336. * AKA Diffuse Color in other nomenclature.
  35337. */
  35338. albedoColor: Color3;
  35339. /**
  35340. * AKA Specular Color in other nomenclature.
  35341. */
  35342. reflectivityColor: Color3;
  35343. /**
  35344. * The color reflected from the material.
  35345. */
  35346. reflectionColor: Color3;
  35347. /**
  35348. * The color emitted from the material.
  35349. */
  35350. emissiveColor: Color3;
  35351. /**
  35352. * AKA Glossiness in other nomenclature.
  35353. */
  35354. microSurface: number;
  35355. /**
  35356. * source material index of refraction (IOR)' / 'destination material IOR.
  35357. */
  35358. indexOfRefraction: number;
  35359. /**
  35360. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  35361. */
  35362. invertRefractionY: boolean;
  35363. /**
  35364. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  35365. * Materials half opaque for instance using refraction could benefit from this control.
  35366. */
  35367. linkRefractionWithTransparency: boolean;
  35368. useLightmapAsShadowmap: boolean;
  35369. /**
  35370. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  35371. */
  35372. useAlphaFromAlbedoTexture: boolean;
  35373. /**
  35374. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  35375. */
  35376. forceAlphaTest: boolean;
  35377. /**
  35378. * Defines the alpha limits in alpha test mode.
  35379. */
  35380. alphaCutOff: number;
  35381. /**
  35382. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  35383. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  35384. */
  35385. useSpecularOverAlpha: boolean;
  35386. /**
  35387. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  35388. */
  35389. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  35390. /**
  35391. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  35392. */
  35393. useRoughnessFromMetallicTextureAlpha: boolean;
  35394. /**
  35395. * Specifies if the metallic texture contains the roughness information in its green channel.
  35396. */
  35397. useRoughnessFromMetallicTextureGreen: boolean;
  35398. /**
  35399. * Specifies if the metallic texture contains the metallness information in its blue channel.
  35400. */
  35401. useMetallnessFromMetallicTextureBlue: boolean;
  35402. /**
  35403. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  35404. */
  35405. useAmbientOcclusionFromMetallicTextureRed: boolean;
  35406. /**
  35407. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  35408. */
  35409. useAmbientInGrayScale: boolean;
  35410. /**
  35411. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  35412. * The material will try to infer what glossiness each pixel should be.
  35413. */
  35414. useAutoMicroSurfaceFromReflectivityMap: boolean;
  35415. /**
  35416. * BJS is using an harcoded light falloff based on a manually sets up range.
  35417. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  35418. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  35419. */
  35420. /**
  35421. * BJS is using an harcoded light falloff based on a manually sets up range.
  35422. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  35423. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  35424. */
  35425. usePhysicalLightFalloff: boolean;
  35426. /**
  35427. * In order to support the falloff compatibility with gltf, a special mode has been added
  35428. * to reproduce the gltf light falloff.
  35429. */
  35430. /**
  35431. * In order to support the falloff compatibility with gltf, a special mode has been added
  35432. * to reproduce the gltf light falloff.
  35433. */
  35434. useGLTFLightFalloff: boolean;
  35435. /**
  35436. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  35437. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  35438. */
  35439. useRadianceOverAlpha: boolean;
  35440. /**
  35441. * Allows using an object space normal map (instead of tangent space).
  35442. */
  35443. useObjectSpaceNormalMap: boolean;
  35444. /**
  35445. * Allows using the bump map in parallax mode.
  35446. */
  35447. useParallax: boolean;
  35448. /**
  35449. * Allows using the bump map in parallax occlusion mode.
  35450. */
  35451. useParallaxOcclusion: boolean;
  35452. /**
  35453. * Controls the scale bias of the parallax mode.
  35454. */
  35455. parallaxScaleBias: number;
  35456. /**
  35457. * If sets to true, disables all the lights affecting the material.
  35458. */
  35459. disableLighting: boolean;
  35460. /**
  35461. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  35462. */
  35463. forceIrradianceInFragment: boolean;
  35464. /**
  35465. * Number of Simultaneous lights allowed on the material.
  35466. */
  35467. maxSimultaneousLights: number;
  35468. /**
  35469. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  35470. */
  35471. invertNormalMapX: boolean;
  35472. /**
  35473. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  35474. */
  35475. invertNormalMapY: boolean;
  35476. /**
  35477. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  35478. */
  35479. twoSidedLighting: boolean;
  35480. /**
  35481. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35482. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  35483. */
  35484. useAlphaFresnel: boolean;
  35485. /**
  35486. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35487. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  35488. */
  35489. useLinearAlphaFresnel: boolean;
  35490. /**
  35491. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35492. * And/Or occlude the blended part.
  35493. */
  35494. environmentBRDFTexture: Nullable<BaseTexture>;
  35495. /**
  35496. * Force normal to face away from face.
  35497. */
  35498. forceNormalForward: boolean;
  35499. /**
  35500. * Enables specular anti aliasing in the PBR shader.
  35501. * It will both interacts on the Geometry for analytical and IBL lighting.
  35502. * It also prefilter the roughness map based on the bump values.
  35503. */
  35504. enableSpecularAntiAliasing: boolean;
  35505. /**
  35506. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  35507. * makes the reflect vector face the model (under horizon).
  35508. */
  35509. useHorizonOcclusion: boolean;
  35510. /**
  35511. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  35512. * too much the area relying on ambient texture to define their ambient occlusion.
  35513. */
  35514. useRadianceOcclusion: boolean;
  35515. /**
  35516. * If set to true, no lighting calculations will be applied.
  35517. */
  35518. unlit: boolean;
  35519. /**
  35520. * Gets the image processing configuration used either in this material.
  35521. */
  35522. /**
  35523. * Sets the Default image processing configuration used either in the this material.
  35524. *
  35525. * If sets to null, the scene one is in use.
  35526. */
  35527. imageProcessingConfiguration: ImageProcessingConfiguration;
  35528. /**
  35529. * Gets wether the color curves effect is enabled.
  35530. */
  35531. /**
  35532. * Sets wether the color curves effect is enabled.
  35533. */
  35534. cameraColorCurvesEnabled: boolean;
  35535. /**
  35536. * Gets wether the color grading effect is enabled.
  35537. */
  35538. /**
  35539. * Gets wether the color grading effect is enabled.
  35540. */
  35541. cameraColorGradingEnabled: boolean;
  35542. /**
  35543. * Gets wether tonemapping is enabled or not.
  35544. */
  35545. /**
  35546. * Sets wether tonemapping is enabled or not
  35547. */
  35548. cameraToneMappingEnabled: boolean;
  35549. /**
  35550. * The camera exposure used on this material.
  35551. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  35552. * This corresponds to a photographic exposure.
  35553. */
  35554. /**
  35555. * The camera exposure used on this material.
  35556. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  35557. * This corresponds to a photographic exposure.
  35558. */
  35559. cameraExposure: number;
  35560. /**
  35561. * Gets The camera contrast used on this material.
  35562. */
  35563. /**
  35564. * Sets The camera contrast used on this material.
  35565. */
  35566. cameraContrast: number;
  35567. /**
  35568. * Gets the Color Grading 2D Lookup Texture.
  35569. */
  35570. /**
  35571. * Sets the Color Grading 2D Lookup Texture.
  35572. */
  35573. cameraColorGradingTexture: Nullable<BaseTexture>;
  35574. /**
  35575. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  35576. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  35577. * 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;
  35578. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  35579. */
  35580. /**
  35581. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  35582. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  35583. * 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;
  35584. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  35585. */
  35586. cameraColorCurves: Nullable<ColorCurves>;
  35587. /**
  35588. * Instantiates a new PBRMaterial instance.
  35589. *
  35590. * @param name The material name
  35591. * @param scene The scene the material will be use in.
  35592. */
  35593. constructor(name: string, scene: Scene);
  35594. /**
  35595. * Returns the name of this material class.
  35596. */
  35597. getClassName(): string;
  35598. /**
  35599. * Returns an array of the actively used textures.
  35600. * @returns - Array of BaseTextures
  35601. */
  35602. getActiveTextures(): BaseTexture[];
  35603. /**
  35604. * Checks to see if a texture is used in the material.
  35605. * @param texture - Base texture to use.
  35606. * @returns - Boolean specifying if a texture is used in the material.
  35607. */
  35608. hasTexture(texture: BaseTexture): boolean;
  35609. /**
  35610. * Makes a duplicate of the current material.
  35611. * @param name - name to use for the new material.
  35612. */
  35613. clone(name: string): PBRMaterial;
  35614. /**
  35615. * Serializes this PBR Material.
  35616. * @returns - An object with the serialized material.
  35617. */
  35618. serialize(): any;
  35619. /**
  35620. * Parses a PBR Material from a serialized object.
  35621. * @param source - Serialized object.
  35622. * @param scene - BJS scene instance.
  35623. * @param rootUrl - url for the scene object
  35624. * @returns - PBRMaterial
  35625. */
  35626. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  35627. }
  35628. }
  35629. declare module BABYLON {
  35630. /**
  35631. * The PBR material of BJS following the metal roughness convention.
  35632. *
  35633. * This fits to the PBR convention in the GLTF definition:
  35634. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  35635. */
  35636. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  35637. /**
  35638. * The base color has two different interpretations depending on the value of metalness.
  35639. * When the material is a metal, the base color is the specific measured reflectance value
  35640. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  35641. * of the material.
  35642. */
  35643. baseColor: Color3;
  35644. /**
  35645. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  35646. * well as opacity information in the alpha channel.
  35647. */
  35648. baseTexture: BaseTexture;
  35649. /**
  35650. * Specifies the metallic scalar value of the material.
  35651. * Can also be used to scale the metalness values of the metallic texture.
  35652. */
  35653. metallic: number;
  35654. /**
  35655. * Specifies the roughness scalar value of the material.
  35656. * Can also be used to scale the roughness values of the metallic texture.
  35657. */
  35658. roughness: number;
  35659. /**
  35660. * Texture containing both the metallic value in the B channel and the
  35661. * roughness value in the G channel to keep better precision.
  35662. */
  35663. metallicRoughnessTexture: BaseTexture;
  35664. /**
  35665. * Instantiates a new PBRMetalRoughnessMaterial instance.
  35666. *
  35667. * @param name The material name
  35668. * @param scene The scene the material will be use in.
  35669. */
  35670. constructor(name: string, scene: Scene);
  35671. /**
  35672. * Return the currrent class name of the material.
  35673. */
  35674. getClassName(): string;
  35675. /**
  35676. * Return the active textures of the material.
  35677. */
  35678. getActiveTextures(): BaseTexture[];
  35679. /**
  35680. * Checks to see if a texture is used in the material.
  35681. * @param texture - Base texture to use.
  35682. * @returns - Boolean specifying if a texture is used in the material.
  35683. */
  35684. hasTexture(texture: BaseTexture): boolean;
  35685. /**
  35686. * Makes a duplicate of the current material.
  35687. * @param name - name to use for the new material.
  35688. */
  35689. clone(name: string): PBRMetallicRoughnessMaterial;
  35690. /**
  35691. * Serialize the material to a parsable JSON object.
  35692. */
  35693. serialize(): any;
  35694. /**
  35695. * Parses a JSON object correponding to the serialize function.
  35696. */
  35697. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  35698. }
  35699. }
  35700. declare module BABYLON {
  35701. /**
  35702. * The PBR material of BJS following the specular glossiness convention.
  35703. *
  35704. * This fits to the PBR convention in the GLTF definition:
  35705. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  35706. */
  35707. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  35708. /**
  35709. * Specifies the diffuse color of the material.
  35710. */
  35711. diffuseColor: Color3;
  35712. /**
  35713. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  35714. * channel.
  35715. */
  35716. diffuseTexture: BaseTexture;
  35717. /**
  35718. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  35719. */
  35720. specularColor: Color3;
  35721. /**
  35722. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  35723. */
  35724. glossiness: number;
  35725. /**
  35726. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  35727. */
  35728. specularGlossinessTexture: BaseTexture;
  35729. /**
  35730. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  35731. *
  35732. * @param name The material name
  35733. * @param scene The scene the material will be use in.
  35734. */
  35735. constructor(name: string, scene: Scene);
  35736. /**
  35737. * Return the currrent class name of the material.
  35738. */
  35739. getClassName(): string;
  35740. /**
  35741. * Return the active textures of the material.
  35742. */
  35743. getActiveTextures(): BaseTexture[];
  35744. /**
  35745. * Checks to see if a texture is used in the material.
  35746. * @param texture - Base texture to use.
  35747. * @returns - Boolean specifying if a texture is used in the material.
  35748. */
  35749. hasTexture(texture: BaseTexture): boolean;
  35750. /**
  35751. * Makes a duplicate of the current material.
  35752. * @param name - name to use for the new material.
  35753. */
  35754. clone(name: string): PBRSpecularGlossinessMaterial;
  35755. /**
  35756. * Serialize the material to a parsable JSON object.
  35757. */
  35758. serialize(): any;
  35759. /**
  35760. * Parses a JSON object correponding to the serialize function.
  35761. */
  35762. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  35763. }
  35764. }
  35765. declare module BABYLON {
  35766. class BaseTexture {
  35767. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  35768. name: string;
  35769. private _hasAlpha;
  35770. hasAlpha: boolean;
  35771. getAlphaFromRGB: boolean;
  35772. level: number;
  35773. coordinatesIndex: number;
  35774. private _coordinatesMode;
  35775. /**
  35776. * How a texture is mapped.
  35777. *
  35778. * | Value | Type | Description |
  35779. * | ----- | ----------------------------------- | ----------- |
  35780. * | 0 | EXPLICIT_MODE | |
  35781. * | 1 | SPHERICAL_MODE | |
  35782. * | 2 | PLANAR_MODE | |
  35783. * | 3 | CUBIC_MODE | |
  35784. * | 4 | PROJECTION_MODE | |
  35785. * | 5 | SKYBOX_MODE | |
  35786. * | 6 | INVCUBIC_MODE | |
  35787. * | 7 | EQUIRECTANGULAR_MODE | |
  35788. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  35789. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  35790. */
  35791. coordinatesMode: number;
  35792. /**
  35793. * | Value | Type | Description |
  35794. * | ----- | ------------------ | ----------- |
  35795. * | 0 | CLAMP_ADDRESSMODE | |
  35796. * | 1 | WRAP_ADDRESSMODE | |
  35797. * | 2 | MIRROR_ADDRESSMODE | |
  35798. */
  35799. wrapU: number;
  35800. /**
  35801. * | Value | Type | Description |
  35802. * | ----- | ------------------ | ----------- |
  35803. * | 0 | CLAMP_ADDRESSMODE | |
  35804. * | 1 | WRAP_ADDRESSMODE | |
  35805. * | 2 | MIRROR_ADDRESSMODE | |
  35806. */
  35807. wrapV: number;
  35808. /**
  35809. * | Value | Type | Description |
  35810. * | ----- | ------------------ | ----------- |
  35811. * | 0 | CLAMP_ADDRESSMODE | |
  35812. * | 1 | WRAP_ADDRESSMODE | |
  35813. * | 2 | MIRROR_ADDRESSMODE | |
  35814. */
  35815. wrapR: number;
  35816. anisotropicFilteringLevel: number;
  35817. isCube: boolean;
  35818. is3D: boolean;
  35819. gammaSpace: boolean;
  35820. /**
  35821. * Gets whether or not the texture contains RGBD data.
  35822. */
  35823. readonly isRGBD: boolean;
  35824. invertZ: boolean;
  35825. lodLevelInAlpha: boolean;
  35826. lodGenerationOffset: number;
  35827. lodGenerationScale: number;
  35828. isRenderTarget: boolean;
  35829. readonly uid: string;
  35830. toString(): string;
  35831. getClassName(): string;
  35832. animations: Animation[];
  35833. /**
  35834. * An event triggered when the texture is disposed.
  35835. */
  35836. onDisposeObservable: Observable<BaseTexture>;
  35837. private _onDisposeObserver;
  35838. onDispose: () => void;
  35839. delayLoadState: number;
  35840. private _scene;
  35841. /** @hidden */
  35842. _texture: Nullable<InternalTexture>;
  35843. private _uid;
  35844. readonly isBlocking: boolean;
  35845. constructor(scene: Nullable<Scene>);
  35846. getScene(): Nullable<Scene>;
  35847. getTextureMatrix(): Matrix;
  35848. getReflectionTextureMatrix(): Matrix;
  35849. getInternalTexture(): Nullable<InternalTexture>;
  35850. isReadyOrNotBlocking(): boolean;
  35851. isReady(): boolean;
  35852. private _cachedSize;
  35853. getSize(): ISize;
  35854. getBaseSize(): ISize;
  35855. scale(ratio: number): void;
  35856. readonly canRescale: boolean;
  35857. /** @hidden */
  35858. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  35859. /** @hidden */
  35860. _rebuild(): void;
  35861. delayLoad(): void;
  35862. clone(): Nullable<BaseTexture>;
  35863. readonly textureType: number;
  35864. readonly textureFormat: number;
  35865. /**
  35866. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35867. * This will returns an RGBA array buffer containing either in values (0-255) or
  35868. * float values (0-1) depending of the underlying buffer type.
  35869. * @param faceIndex The face of the texture to read (in case of cube texture)
  35870. * @param level The LOD level of the texture to read (in case of Mip Maps)
  35871. * @returns The Array buffer containing the pixels data.
  35872. */
  35873. readPixels(faceIndex?: number, level?: number): Nullable<ArrayBufferView>;
  35874. releaseInternalTexture(): void;
  35875. sphericalPolynomial: Nullable<SphericalPolynomial>;
  35876. readonly _lodTextureHigh: Nullable<BaseTexture>;
  35877. readonly _lodTextureMid: Nullable<BaseTexture>;
  35878. readonly _lodTextureLow: Nullable<BaseTexture>;
  35879. dispose(): void;
  35880. serialize(): any;
  35881. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35882. }
  35883. }
  35884. declare module BABYLON {
  35885. /**
  35886. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  35887. * It can help converting any input color in a desired output one. This can then be used to create effects
  35888. * from sepia, black and white to sixties or futuristic rendering...
  35889. *
  35890. * The only supported format is currently 3dl.
  35891. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  35892. */
  35893. class ColorGradingTexture extends BaseTexture {
  35894. /**
  35895. * The current texture matrix. (will always be identity in color grading texture)
  35896. */
  35897. private _textureMatrix;
  35898. /**
  35899. * The texture URL.
  35900. */
  35901. url: string;
  35902. /**
  35903. * Empty line regex stored for GC.
  35904. */
  35905. private static _noneEmptyLineRegex;
  35906. private _engine;
  35907. /**
  35908. * Instantiates a ColorGradingTexture from the following parameters.
  35909. *
  35910. * @param url The location of the color gradind data (currently only supporting 3dl)
  35911. * @param scene The scene the texture will be used in
  35912. */
  35913. constructor(url: string, scene: Scene);
  35914. /**
  35915. * Returns the texture matrix used in most of the material.
  35916. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  35917. */
  35918. getTextureMatrix(): Matrix;
  35919. /**
  35920. * Occurs when the file being loaded is a .3dl LUT file.
  35921. */
  35922. private load3dlTexture;
  35923. /**
  35924. * Starts the loading process of the texture.
  35925. */
  35926. private loadTexture;
  35927. /**
  35928. * Clones the color gradind texture.
  35929. */
  35930. clone(): ColorGradingTexture;
  35931. /**
  35932. * Called during delayed load for textures.
  35933. */
  35934. delayLoad(): void;
  35935. /**
  35936. * Parses a color grading texture serialized by Babylon.
  35937. * @param parsedTexture The texture information being parsedTexture
  35938. * @param scene The scene to load the texture in
  35939. * @param rootUrl The root url of the data assets to load
  35940. * @return A color gradind texture
  35941. */
  35942. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  35943. /**
  35944. * Serializes the LUT texture to json format.
  35945. */
  35946. serialize(): any;
  35947. }
  35948. }
  35949. declare module BABYLON {
  35950. class CubeTexture extends BaseTexture {
  35951. url: string;
  35952. /**
  35953. * Gets or sets the center of the bounding box associated with the cube texture
  35954. * It must define where the camera used to render the texture was set
  35955. */
  35956. boundingBoxPosition: Vector3;
  35957. private _boundingBoxSize;
  35958. /**
  35959. * Gets or sets the size of the bounding box associated with the cube texture
  35960. * When defined, the cubemap will switch to local mode
  35961. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  35962. * @example https://www.babylonjs-playground.com/#RNASML
  35963. */
  35964. boundingBoxSize: Vector3;
  35965. protected _rotationY: number;
  35966. /**
  35967. * Sets texture matrix rotation angle around Y axis in radians.
  35968. */
  35969. /**
  35970. * Gets texture matrix rotation angle around Y axis radians.
  35971. */
  35972. rotationY: number;
  35973. private _noMipmap;
  35974. private _files;
  35975. private _extensions;
  35976. private _textureMatrix;
  35977. private _format;
  35978. private _createPolynomials;
  35979. /** @hidden */
  35980. readonly _prefiltered: boolean;
  35981. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  35982. /**
  35983. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  35984. * @param url defines the url of the prefiltered texture
  35985. * @param scene defines the scene the texture is attached to
  35986. * @param forcedExtension defines the extension of the file if different from the url
  35987. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  35988. * @return the prefiltered texture
  35989. */
  35990. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  35991. /**
  35992. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  35993. * as prefiltered data.
  35994. * @param rootUrl defines the url of the texture or the root name of the six images
  35995. * @param scene defines the scene the texture is attached to
  35996. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  35997. * @param noMipmap defines if mipmaps should be created or not
  35998. * @param files defines the six files to load for the different faces
  35999. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  36000. * @param onError defines a callback triggered in case of error during load
  36001. * @param format defines the internal format to use for the texture once loaded
  36002. * @param prefiltered defines whether or not the texture is created from prefiltered data
  36003. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  36004. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  36005. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  36006. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  36007. * @return the cube texture
  36008. */
  36009. 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);
  36010. delayLoad(): void;
  36011. getReflectionTextureMatrix(): Matrix;
  36012. setReflectionTextureMatrix(value: Matrix): void;
  36013. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  36014. clone(): CubeTexture;
  36015. }
  36016. }
  36017. declare module BABYLON {
  36018. /**
  36019. * A class extending {BABYLON.Texture} allowing drawing on a texture
  36020. * @see http://doc.babylonjs.com/how_to/dynamictexture
  36021. */
  36022. class DynamicTexture extends Texture {
  36023. private _generateMipMaps;
  36024. private _canvas;
  36025. private _context;
  36026. private _engine;
  36027. /**
  36028. * Creates a {BABYLON.DynamicTexture}
  36029. * @param name defines the name of the texture
  36030. * @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
  36031. * @param scene defines the scene where you want the texture
  36032. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  36033. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  36034. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  36035. */
  36036. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  36037. /**
  36038. * Gets the current state of canRescale
  36039. */
  36040. readonly canRescale: boolean;
  36041. private _recreate;
  36042. /**
  36043. * Scales the texture
  36044. * @param ratio the scale factor to apply to both width and height
  36045. */
  36046. scale(ratio: number): void;
  36047. /**
  36048. * Resizes the texture
  36049. * @param width the new width
  36050. * @param height the new height
  36051. */
  36052. scaleTo(width: number, height: number): void;
  36053. /**
  36054. * Gets the context of the canvas used by the texture
  36055. * @returns the canvas context of the dynamic texture
  36056. */
  36057. getContext(): CanvasRenderingContext2D;
  36058. /**
  36059. * Clears the texture
  36060. */
  36061. clear(): void;
  36062. /**
  36063. * Updates the texture
  36064. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  36065. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  36066. */
  36067. update(invertY?: boolean, premulAlpha?: boolean): void;
  36068. /**
  36069. * Draws text onto the texture
  36070. * @param text defines the text to be drawn
  36071. * @param x defines the placement of the text from the left
  36072. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  36073. * @param font defines the font to be used with font-style, font-size, font-name
  36074. * @param color defines the color used for the text
  36075. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  36076. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  36077. * @param update defines whether texture is immediately update (default is true)
  36078. */
  36079. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  36080. /**
  36081. * Clones the texture
  36082. * @returns the clone of the texture.
  36083. */
  36084. clone(): DynamicTexture;
  36085. /**
  36086. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  36087. * @returns a serialized dynamic texture object
  36088. */
  36089. serialize(): any;
  36090. /** @hidden */
  36091. _rebuild(): void;
  36092. }
  36093. }
  36094. declare module BABYLON {
  36095. /**
  36096. * This represents a texture coming from an HDR input.
  36097. *
  36098. * The only supported format is currently panorama picture stored in RGBE format.
  36099. * Example of such files can be found on HDRLib: http://hdrlib.com/
  36100. */
  36101. class HDRCubeTexture extends BaseTexture {
  36102. private static _facesMapping;
  36103. private _generateHarmonics;
  36104. private _noMipmap;
  36105. private _textureMatrix;
  36106. private _size;
  36107. private _onLoad;
  36108. private _onError;
  36109. /**
  36110. * The texture URL.
  36111. */
  36112. url: string;
  36113. /**
  36114. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  36115. */
  36116. coordinatesMode: number;
  36117. protected _isBlocking: boolean;
  36118. /**
  36119. * Sets wether or not the texture is blocking during loading.
  36120. */
  36121. /**
  36122. * Gets wether or not the texture is blocking during loading.
  36123. */
  36124. isBlocking: boolean;
  36125. protected _rotationY: number;
  36126. /**
  36127. * Sets texture matrix rotation angle around Y axis in radians.
  36128. */
  36129. /**
  36130. * Gets texture matrix rotation angle around Y axis radians.
  36131. */
  36132. rotationY: number;
  36133. /**
  36134. * Gets or sets the center of the bounding box associated with the cube texture
  36135. * It must define where the camera used to render the texture was set
  36136. */
  36137. boundingBoxPosition: Vector3;
  36138. private _boundingBoxSize;
  36139. /**
  36140. * Gets or sets the size of the bounding box associated with the cube texture
  36141. * When defined, the cubemap will switch to local mode
  36142. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  36143. * @example https://www.babylonjs-playground.com/#RNASML
  36144. */
  36145. boundingBoxSize: Vector3;
  36146. /**
  36147. * Instantiates an HDRTexture from the following parameters.
  36148. *
  36149. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  36150. * @param scene The scene the texture will be used in
  36151. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  36152. * @param noMipmap Forces to not generate the mipmap if true
  36153. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  36154. * @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)
  36155. * @param reserved Reserved flag for internal use.
  36156. */
  36157. 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>);
  36158. /**
  36159. * Occurs when the file is raw .hdr file.
  36160. */
  36161. private loadTexture;
  36162. clone(): HDRCubeTexture;
  36163. delayLoad(): void;
  36164. getReflectionTextureMatrix(): Matrix;
  36165. setReflectionTextureMatrix(value: Matrix): void;
  36166. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  36167. serialize(): any;
  36168. }
  36169. }
  36170. declare module BABYLON {
  36171. /**
  36172. * Class used to store data associated with WebGL texture data for the engine
  36173. * This class should not be used directly
  36174. */
  36175. class InternalTexture implements IInternalTextureTracker {
  36176. /**
  36177. * The source of the texture data is unknown
  36178. */
  36179. static DATASOURCE_UNKNOWN: number;
  36180. /**
  36181. * Texture data comes from an URL
  36182. */
  36183. static DATASOURCE_URL: number;
  36184. /**
  36185. * Texture data is only used for temporary storage
  36186. */
  36187. static DATASOURCE_TEMP: number;
  36188. /**
  36189. * Texture data comes from raw data (ArrayBuffer)
  36190. */
  36191. static DATASOURCE_RAW: number;
  36192. /**
  36193. * Texture content is dynamic (video or dynamic texture)
  36194. */
  36195. static DATASOURCE_DYNAMIC: number;
  36196. /**
  36197. * Texture content is generated by rendering to it
  36198. */
  36199. static DATASOURCE_RENDERTARGET: number;
  36200. /**
  36201. * Texture content is part of a multi render target process
  36202. */
  36203. static DATASOURCE_MULTIRENDERTARGET: number;
  36204. /**
  36205. * Texture data comes from a cube data file
  36206. */
  36207. static DATASOURCE_CUBE: number;
  36208. /**
  36209. * Texture data comes from a raw cube data
  36210. */
  36211. static DATASOURCE_CUBERAW: number;
  36212. /**
  36213. * Texture data come from a prefiltered cube data file
  36214. */
  36215. static DATASOURCE_CUBEPREFILTERED: number;
  36216. /**
  36217. * Texture content is raw 3D data
  36218. */
  36219. static DATASOURCE_RAW3D: number;
  36220. /**
  36221. * Texture content is a depth texture
  36222. */
  36223. static DATASOURCE_DEPTHTEXTURE: number;
  36224. /**
  36225. * Texture data comes from a raw cube data encoded with RGBD
  36226. */
  36227. static DATASOURCE_CUBERAW_RGBD: number;
  36228. /**
  36229. * Defines if the texture is ready
  36230. */
  36231. isReady: boolean;
  36232. /**
  36233. * Defines if the texture is a cube texture
  36234. */
  36235. isCube: boolean;
  36236. /**
  36237. * Defines if the texture contains 3D data
  36238. */
  36239. is3D: boolean;
  36240. /**
  36241. * Gets the URL used to load this texture
  36242. */
  36243. url: string;
  36244. /**
  36245. * Gets the sampling mode of the texture
  36246. */
  36247. samplingMode: number;
  36248. /**
  36249. * Gets a boolean indicating if the texture needs mipmaps generation
  36250. */
  36251. generateMipMaps: boolean;
  36252. /**
  36253. * Gets the number of samples used by the texture (WebGL2+ only)
  36254. */
  36255. samples: number;
  36256. /**
  36257. * Gets the type of the texture
  36258. */
  36259. type: number;
  36260. /**
  36261. * Gets the format of the texture
  36262. */
  36263. format: number;
  36264. /**
  36265. * Observable called when the texture is loaded
  36266. */
  36267. onLoadedObservable: Observable<InternalTexture>;
  36268. /**
  36269. * Gets the width of the texture
  36270. */
  36271. width: number;
  36272. /**
  36273. * Gets the height of the texture
  36274. */
  36275. height: number;
  36276. /**
  36277. * Gets the depth of the texture
  36278. */
  36279. depth: number;
  36280. /**
  36281. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36282. */
  36283. baseWidth: number;
  36284. /**
  36285. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36286. */
  36287. baseHeight: number;
  36288. /**
  36289. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36290. */
  36291. baseDepth: number;
  36292. /**
  36293. * Gets a boolean indicating if the texture is inverted on Y axis
  36294. */
  36295. invertY: boolean;
  36296. /**
  36297. * Gets or set the previous tracker in the list
  36298. */
  36299. previous: Nullable<IInternalTextureTracker>;
  36300. /**
  36301. * Gets or set the next tracker in the list
  36302. */
  36303. next: Nullable<IInternalTextureTracker>;
  36304. /** @hidden */
  36305. _initialSlot: number;
  36306. /** @hidden */
  36307. _designatedSlot: number;
  36308. /** @hidden */
  36309. _dataSource: number;
  36310. /** @hidden */
  36311. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  36312. /** @hidden */
  36313. _bufferView: Nullable<ArrayBufferView>;
  36314. /** @hidden */
  36315. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36316. /** @hidden */
  36317. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36318. /** @hidden */
  36319. _size: number;
  36320. /** @hidden */
  36321. _extension: string;
  36322. /** @hidden */
  36323. _files: Nullable<string[]>;
  36324. /** @hidden */
  36325. _workingCanvas: HTMLCanvasElement;
  36326. /** @hidden */
  36327. _workingContext: CanvasRenderingContext2D;
  36328. /** @hidden */
  36329. _framebuffer: Nullable<WebGLFramebuffer>;
  36330. /** @hidden */
  36331. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36332. /** @hidden */
  36333. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36334. /** @hidden */
  36335. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36336. /** @hidden */
  36337. _attachments: Nullable<number[]>;
  36338. /** @hidden */
  36339. _cachedCoordinatesMode: Nullable<number>;
  36340. /** @hidden */
  36341. _cachedWrapU: Nullable<number>;
  36342. /** @hidden */
  36343. _cachedWrapV: Nullable<number>;
  36344. /** @hidden */
  36345. _cachedWrapR: Nullable<number>;
  36346. /** @hidden */
  36347. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36348. /** @hidden */
  36349. _isDisabled: boolean;
  36350. /** @hidden */
  36351. _compression: Nullable<string>;
  36352. /** @hidden */
  36353. _generateStencilBuffer: boolean;
  36354. /** @hidden */
  36355. _generateDepthBuffer: boolean;
  36356. /** @hidden */
  36357. _comparisonFunction: number;
  36358. /** @hidden */
  36359. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36360. /** @hidden */
  36361. _lodGenerationScale: number;
  36362. /** @hidden */
  36363. _lodGenerationOffset: number;
  36364. /** @hidden */
  36365. _lodTextureHigh: BaseTexture;
  36366. /** @hidden */
  36367. _lodTextureMid: BaseTexture;
  36368. /** @hidden */
  36369. _lodTextureLow: BaseTexture;
  36370. /** @hidden */
  36371. _isRGBD: boolean;
  36372. /** @hidden */
  36373. _webGLTexture: Nullable<WebGLTexture>;
  36374. /** @hidden */
  36375. _references: number;
  36376. private _engine;
  36377. /**
  36378. * Gets the Engine the texture belongs to.
  36379. * @returns The babylon engine
  36380. */
  36381. getEngine(): Engine;
  36382. /**
  36383. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  36384. */
  36385. readonly dataSource: number;
  36386. /**
  36387. * Creates a new InternalTexture
  36388. * @param engine defines the engine to use
  36389. * @param dataSource defines the type of data that will be used
  36390. */
  36391. constructor(engine: Engine, dataSource: number);
  36392. /**
  36393. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  36394. */
  36395. incrementReferences(): void;
  36396. /**
  36397. * Change the size of the texture (not the size of the content)
  36398. * @param width defines the new width
  36399. * @param height defines the new height
  36400. * @param depth defines the new depth (1 by default)
  36401. */
  36402. updateSize(width: int, height: int, depth?: int): void;
  36403. /** @hidden */
  36404. _rebuild(): void;
  36405. /** @hidden */
  36406. _swapAndDie(target: InternalTexture): void;
  36407. /**
  36408. * Dispose the current allocated resources
  36409. */
  36410. dispose(): void;
  36411. }
  36412. }
  36413. declare module BABYLON {
  36414. /**
  36415. * This represents the required contract to create a new type of texture loader.
  36416. */
  36417. interface IInternalTextureLoader {
  36418. /**
  36419. * Defines wether the loader supports cascade loading the different faces.
  36420. */
  36421. supportCascades: boolean;
  36422. /**
  36423. * This returns if the loader support the current file information.
  36424. * @param extension defines the file extension of the file being loaded
  36425. * @param textureFormatInUse defines the current compressed format in use iun the engine
  36426. * @param fallback defines the fallback internal texture if any
  36427. * @param isBase64 defines whether the texture is encoded as a base64
  36428. * @param isBuffer defines whether the texture data are stored as a buffer
  36429. * @returns true if the loader can load the specified file
  36430. */
  36431. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  36432. /**
  36433. * Transform the url before loading if required.
  36434. * @param rootUrl the url of the texture
  36435. * @param textureFormatInUse defines the current compressed format in use iun the engine
  36436. * @returns the transformed texture
  36437. */
  36438. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  36439. /**
  36440. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  36441. * @param rootUrl the url of the texture
  36442. * @param textureFormatInUse defines the current compressed format in use iun the engine
  36443. * @returns the fallback texture
  36444. */
  36445. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  36446. /**
  36447. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  36448. * @param data contains the texture data
  36449. * @param texture defines the BabylonJS internal texture
  36450. * @param createPolynomials will be true if polynomials have been requested
  36451. * @param onLoad defines the callback to trigger once the texture is ready
  36452. * @param onError defines the callback to trigger in case of error
  36453. */
  36454. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  36455. /**
  36456. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  36457. * @param data contains the texture data
  36458. * @param texture defines the BabylonJS internal texture
  36459. * @param callback defines the method to call once ready to upload
  36460. */
  36461. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  36462. }
  36463. }
  36464. declare module BABYLON {
  36465. /**
  36466. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  36467. */
  36468. interface IInternalTextureTracker {
  36469. /**
  36470. * Gets or set the previous tracker in the list
  36471. */
  36472. previous: Nullable<IInternalTextureTracker>;
  36473. /**
  36474. * Gets or set the next tracker in the list
  36475. */
  36476. next: Nullable<IInternalTextureTracker>;
  36477. }
  36478. /**
  36479. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  36480. */
  36481. class DummyInternalTextureTracker {
  36482. /**
  36483. * Gets or set the previous tracker in the list
  36484. */
  36485. previous: Nullable<IInternalTextureTracker>;
  36486. /**
  36487. * Gets or set the next tracker in the list
  36488. */
  36489. next: Nullable<IInternalTextureTracker>;
  36490. }
  36491. }
  36492. declare module BABYLON {
  36493. class MirrorTexture extends RenderTargetTexture {
  36494. private scene;
  36495. mirrorPlane: Plane;
  36496. private _transformMatrix;
  36497. private _mirrorMatrix;
  36498. private _savedViewMatrix;
  36499. private _blurX;
  36500. private _blurY;
  36501. private _adaptiveBlurKernel;
  36502. private _blurKernelX;
  36503. private _blurKernelY;
  36504. private _blurRatio;
  36505. blurRatio: number;
  36506. adaptiveBlurKernel: number;
  36507. blurKernel: number;
  36508. blurKernelX: number;
  36509. blurKernelY: number;
  36510. private _autoComputeBlurKernel;
  36511. protected _onRatioRescale(): void;
  36512. private _updateGammaSpace;
  36513. private _imageProcessingConfigChangeObserver;
  36514. constructor(name: string, size: number | {
  36515. width: number;
  36516. height: number;
  36517. } | {
  36518. ratio: number;
  36519. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  36520. private _preparePostProcesses;
  36521. clone(): MirrorTexture;
  36522. serialize(): any;
  36523. dispose(): void;
  36524. }
  36525. }
  36526. declare module BABYLON {
  36527. interface IMultiRenderTargetOptions {
  36528. generateMipMaps?: boolean;
  36529. types?: number[];
  36530. samplingModes?: number[];
  36531. generateDepthBuffer?: boolean;
  36532. generateStencilBuffer?: boolean;
  36533. generateDepthTexture?: boolean;
  36534. textureCount?: number;
  36535. doNotChangeAspectRatio?: boolean;
  36536. defaultType?: number;
  36537. }
  36538. class MultiRenderTarget extends RenderTargetTexture {
  36539. private _internalTextures;
  36540. private _textures;
  36541. readonly isSupported: boolean;
  36542. private _multiRenderTargetOptions;
  36543. readonly textures: Texture[];
  36544. readonly depthTexture: Texture;
  36545. wrapU: number;
  36546. wrapV: number;
  36547. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  36548. /** @hidden */
  36549. _rebuild(): void;
  36550. private _createInternalTextures;
  36551. private _createTextures;
  36552. samples: number;
  36553. resize(size: any): void;
  36554. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  36555. dispose(): void;
  36556. releaseInternalTextures(): void;
  36557. }
  36558. }
  36559. declare module BABYLON {
  36560. /**
  36561. * Raw cube texture where the raw buffers are passed in
  36562. */
  36563. class RawCubeTexture extends CubeTexture {
  36564. /**
  36565. * Creates a cube texture where the raw buffers are passed in.
  36566. * @param scene defines the scene the texture is attached to
  36567. * @param data defines the array of data to use to create each face
  36568. * @param size defines the size of the textures
  36569. * @param format defines the format of the data
  36570. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  36571. * @param generateMipMaps defines if the engine should generate the mip levels
  36572. * @param invertY defines if data must be stored with Y axis inverted
  36573. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  36574. * @param compression defines the compression used (null by default)
  36575. */
  36576. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  36577. /**
  36578. * Updates the raw cube texture.
  36579. * @param data defines the data to store
  36580. * @param format defines the data format
  36581. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  36582. * @param invertY defines if data must be stored with Y axis inverted
  36583. * @param compression defines the compression used (null by default)
  36584. * @param level defines which level of the texture to update
  36585. */
  36586. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  36587. /**
  36588. * Updates a raw cube texture with RGBD encoded data.
  36589. * @param data defines the array of data [mipmap][face] to use to create each face
  36590. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  36591. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  36592. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  36593. * @returns a promsie that resolves when the operation is complete
  36594. */
  36595. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  36596. /**
  36597. * Clones the raw cube texture.
  36598. * @return a new cube texture
  36599. */
  36600. clone(): CubeTexture;
  36601. /** @hidden */
  36602. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  36603. }
  36604. }
  36605. declare module BABYLON {
  36606. class RawTexture extends Texture {
  36607. format: number;
  36608. private _engine;
  36609. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  36610. update(data: ArrayBufferView): void;
  36611. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  36612. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  36613. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  36614. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  36615. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  36616. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  36617. }
  36618. }
  36619. declare module BABYLON {
  36620. /**
  36621. * Class used to store 3D textures containing user data
  36622. */
  36623. class RawTexture3D extends Texture {
  36624. /** Gets or sets the texture format to use */
  36625. format: number;
  36626. private _engine;
  36627. /**
  36628. * Create a new RawTexture3D
  36629. * @param data defines the data of the texture
  36630. * @param width defines the width of the texture
  36631. * @param height defines the height of the texture
  36632. * @param depth defines the depth of the texture
  36633. * @param format defines the texture format to use
  36634. * @param scene defines the hosting scene
  36635. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  36636. * @param invertY defines if texture must be stored with Y axis inverted
  36637. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  36638. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  36639. */
  36640. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  36641. /** Gets or sets the texture format to use */
  36642. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  36643. /**
  36644. * Update the texture with new data
  36645. * @param data defines the data to store in the texture
  36646. */
  36647. update(data: ArrayBufferView): void;
  36648. }
  36649. }
  36650. declare module BABYLON {
  36651. /**
  36652. * Creates a refraction texture used by refraction channel of the standard material.
  36653. * @param name the texture name
  36654. * @param size size of the underlying texture
  36655. * @param scene root scene
  36656. */
  36657. class RefractionTexture extends RenderTargetTexture {
  36658. refractionPlane: Plane;
  36659. depth: number;
  36660. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  36661. clone(): RefractionTexture;
  36662. serialize(): any;
  36663. }
  36664. }
  36665. declare module BABYLON {
  36666. class RenderTargetTexture extends Texture {
  36667. isCube: boolean;
  36668. static _REFRESHRATE_RENDER_ONCE: number;
  36669. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  36670. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  36671. static readonly REFRESHRATE_RENDER_ONCE: number;
  36672. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  36673. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  36674. /**
  36675. * Use this predicate to dynamically define the list of mesh you want to render.
  36676. * If set, the renderList property will be overwritten.
  36677. */
  36678. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  36679. private _renderList;
  36680. /**
  36681. * Use this list to define the list of mesh you want to render.
  36682. */
  36683. renderList: Nullable<Array<AbstractMesh>>;
  36684. private _hookArray;
  36685. renderParticles: boolean;
  36686. renderSprites: boolean;
  36687. coordinatesMode: number;
  36688. activeCamera: Nullable<Camera>;
  36689. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  36690. useCameraPostProcesses: boolean;
  36691. ignoreCameraViewport: boolean;
  36692. private _postProcessManager;
  36693. private _postProcesses;
  36694. private _resizeObserver;
  36695. /**
  36696. * An event triggered when the texture is unbind.
  36697. */
  36698. onBeforeBindObservable: Observable<RenderTargetTexture>;
  36699. /**
  36700. * An event triggered when the texture is unbind.
  36701. */
  36702. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  36703. private _onAfterUnbindObserver;
  36704. onAfterUnbind: () => void;
  36705. /**
  36706. * An event triggered before rendering the texture
  36707. */
  36708. onBeforeRenderObservable: Observable<number>;
  36709. private _onBeforeRenderObserver;
  36710. onBeforeRender: (faceIndex: number) => void;
  36711. /**
  36712. * An event triggered after rendering the texture
  36713. */
  36714. onAfterRenderObservable: Observable<number>;
  36715. private _onAfterRenderObserver;
  36716. onAfterRender: (faceIndex: number) => void;
  36717. /**
  36718. * An event triggered after the texture clear
  36719. */
  36720. onClearObservable: Observable<Engine>;
  36721. private _onClearObserver;
  36722. onClear: (Engine: Engine) => void;
  36723. clearColor: Color4;
  36724. protected _size: number | {
  36725. width: number;
  36726. height: number;
  36727. };
  36728. protected _initialSizeParameter: number | {
  36729. width: number;
  36730. height: number;
  36731. } | {
  36732. ratio: number;
  36733. };
  36734. protected _sizeRatio: Nullable<number>;
  36735. /** @hidden */
  36736. _generateMipMaps: boolean;
  36737. protected _renderingManager: RenderingManager;
  36738. /** @hidden */
  36739. _waitingRenderList: string[];
  36740. protected _doNotChangeAspectRatio: boolean;
  36741. protected _currentRefreshId: number;
  36742. protected _refreshRate: number;
  36743. protected _textureMatrix: Matrix;
  36744. protected _samples: number;
  36745. protected _renderTargetOptions: RenderTargetCreationOptions;
  36746. readonly renderTargetOptions: RenderTargetCreationOptions;
  36747. protected _engine: Engine;
  36748. protected _onRatioRescale(): void;
  36749. /**
  36750. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  36751. * It must define where the camera used to render the texture is set
  36752. */
  36753. boundingBoxPosition: Vector3;
  36754. private _boundingBoxSize;
  36755. /**
  36756. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  36757. * When defined, the cubemap will switch to local mode
  36758. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  36759. * @example https://www.babylonjs-playground.com/#RNASML
  36760. */
  36761. boundingBoxSize: Vector3;
  36762. /**
  36763. * In case the RTT has been created with a depth texture, get the associated
  36764. * depth texture.
  36765. * Otherwise, return null.
  36766. */
  36767. depthStencilTexture: Nullable<InternalTexture>;
  36768. /**
  36769. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  36770. * or used a shadow, depth texture...
  36771. * @param name The friendly name of the texture
  36772. * @param size The size of the RTT (number if square, or {with: number, height:number} or {ratio:} to define a ratio from the main scene)
  36773. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  36774. * @param generateMipMaps True if mip maps need to be generated after render.
  36775. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  36776. * @param type The type of the buffer in the RTT (int, half float, float...)
  36777. * @param isCube True if a cube texture needs to be created
  36778. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  36779. * @param generateDepthBuffer True to generate a depth buffer
  36780. * @param generateStencilBuffer True to generate a stencil buffer
  36781. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  36782. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  36783. */
  36784. constructor(name: string, size: number | {
  36785. width: number;
  36786. height: number;
  36787. } | {
  36788. ratio: number;
  36789. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  36790. /**
  36791. * Creates a depth stencil texture.
  36792. * This is only available in WebGL 2 or with the depth texture extension available.
  36793. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  36794. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  36795. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  36796. */
  36797. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  36798. private _processSizeParameter;
  36799. samples: number;
  36800. resetRefreshCounter(): void;
  36801. refreshRate: number;
  36802. addPostProcess(postProcess: PostProcess): void;
  36803. clearPostProcesses(dispose?: boolean): void;
  36804. removePostProcess(postProcess: PostProcess): void;
  36805. /** @hidden */
  36806. _shouldRender(): boolean;
  36807. getRenderSize(): number;
  36808. getRenderWidth(): number;
  36809. getRenderHeight(): number;
  36810. readonly canRescale: boolean;
  36811. scale(ratio: number): void;
  36812. getReflectionTextureMatrix(): Matrix;
  36813. resize(size: number | {
  36814. width: number;
  36815. height: number;
  36816. } | {
  36817. ratio: number;
  36818. }): void;
  36819. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  36820. private _bestReflectionRenderTargetDimension;
  36821. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  36822. private renderToTarget;
  36823. /**
  36824. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36825. * This allowed control for front to back rendering or reversly depending of the special needs.
  36826. *
  36827. * @param renderingGroupId The rendering group id corresponding to its index
  36828. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36829. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36830. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36831. */
  36832. 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;
  36833. /**
  36834. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36835. *
  36836. * @param renderingGroupId The rendering group id corresponding to its index
  36837. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36838. */
  36839. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  36840. clone(): RenderTargetTexture;
  36841. serialize(): any;
  36842. disposeFramebufferObjects(): void;
  36843. dispose(): void;
  36844. /** @hidden */
  36845. _rebuild(): void;
  36846. /**
  36847. * Clear the info related to rendering groups preventing retention point in material dispose.
  36848. */
  36849. freeRenderingGroups(): void;
  36850. }
  36851. }
  36852. declare module BABYLON {
  36853. class Texture extends BaseTexture {
  36854. static NEAREST_SAMPLINGMODE: number;
  36855. static NEAREST_NEAREST_MIPLINEAR: number;
  36856. static BILINEAR_SAMPLINGMODE: number;
  36857. static LINEAR_LINEAR_MIPNEAREST: number;
  36858. static TRILINEAR_SAMPLINGMODE: number;
  36859. static LINEAR_LINEAR_MIPLINEAR: number;
  36860. static NEAREST_NEAREST_MIPNEAREST: number;
  36861. static NEAREST_LINEAR_MIPNEAREST: number;
  36862. static NEAREST_LINEAR_MIPLINEAR: number;
  36863. static NEAREST_LINEAR: number;
  36864. static NEAREST_NEAREST: number;
  36865. static LINEAR_NEAREST_MIPNEAREST: number;
  36866. static LINEAR_NEAREST_MIPLINEAR: number;
  36867. static LINEAR_LINEAR: number;
  36868. static LINEAR_NEAREST: number;
  36869. static EXPLICIT_MODE: number;
  36870. static SPHERICAL_MODE: number;
  36871. static PLANAR_MODE: number;
  36872. static CUBIC_MODE: number;
  36873. static PROJECTION_MODE: number;
  36874. static SKYBOX_MODE: number;
  36875. static INVCUBIC_MODE: number;
  36876. static EQUIRECTANGULAR_MODE: number;
  36877. static FIXED_EQUIRECTANGULAR_MODE: number;
  36878. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36879. static readonly CLAMP_ADDRESSMODE: number;
  36880. static readonly WRAP_ADDRESSMODE: number;
  36881. static readonly MIRROR_ADDRESSMODE: number;
  36882. /**
  36883. * 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
  36884. */
  36885. static UseSerializedUrlIfAny: boolean;
  36886. url: Nullable<string>;
  36887. uOffset: number;
  36888. vOffset: number;
  36889. uScale: number;
  36890. vScale: number;
  36891. uAng: number;
  36892. vAng: number;
  36893. wAng: number;
  36894. /**
  36895. * Defines the center of rotation (U)
  36896. */
  36897. uRotationCenter: number;
  36898. /**
  36899. * Defines the center of rotation (V)
  36900. */
  36901. vRotationCenter: number;
  36902. /**
  36903. * Defines the center of rotation (W)
  36904. */
  36905. wRotationCenter: number;
  36906. readonly noMipmap: boolean;
  36907. private _noMipmap;
  36908. /** @hidden */
  36909. _invertY: boolean;
  36910. private _rowGenerationMatrix;
  36911. private _cachedTextureMatrix;
  36912. private _projectionModeMatrix;
  36913. private _t0;
  36914. private _t1;
  36915. private _t2;
  36916. private _cachedUOffset;
  36917. private _cachedVOffset;
  36918. private _cachedUScale;
  36919. private _cachedVScale;
  36920. private _cachedUAng;
  36921. private _cachedVAng;
  36922. private _cachedWAng;
  36923. private _cachedProjectionMatrixId;
  36924. private _cachedCoordinatesMode;
  36925. /** @hidden */
  36926. _samplingMode: number;
  36927. /** @hidden */
  36928. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  36929. private _deleteBuffer;
  36930. protected _format: Nullable<number>;
  36931. private _delayedOnLoad;
  36932. private _delayedOnError;
  36933. protected _onLoadObservable: Nullable<Observable<Texture>>;
  36934. protected _isBlocking: boolean;
  36935. isBlocking: boolean;
  36936. readonly samplingMode: number;
  36937. 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);
  36938. /**
  36939. * Update the url (and optional buffer) of this texture if url was null during construction.
  36940. * @param url the url of the texture
  36941. * @param buffer the buffer of the texture (defaults to null)
  36942. */
  36943. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  36944. delayLoad(): void;
  36945. updateSamplingMode(samplingMode: number): void;
  36946. private _prepareRowForTextureGeneration;
  36947. getTextureMatrix(): Matrix;
  36948. getReflectionTextureMatrix(): Matrix;
  36949. clone(): Texture;
  36950. readonly onLoadObservable: Observable<Texture>;
  36951. serialize(): any;
  36952. getClassName(): string;
  36953. dispose(): void;
  36954. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  36955. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  36956. 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;
  36957. }
  36958. }
  36959. declare module BABYLON {
  36960. /**
  36961. * Settings for finer control over video usage
  36962. */
  36963. interface VideoTextureSettings {
  36964. /**
  36965. * Applies `autoplay` to video, if specified
  36966. */
  36967. autoPlay?: boolean;
  36968. /**
  36969. * Applies `loop` to video, if specified
  36970. */
  36971. loop?: boolean;
  36972. /**
  36973. * Automatically updates internal texture from video at every frame in the render loop
  36974. */
  36975. autoUpdateTexture: boolean;
  36976. /**
  36977. * Image src displayed during the video loading or until the user interacts with the video.
  36978. */
  36979. poster?: string;
  36980. }
  36981. class VideoTexture extends Texture {
  36982. /**
  36983. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36984. */
  36985. readonly autoUpdateTexture: boolean;
  36986. /**
  36987. * The video instance used by the texture internally
  36988. */
  36989. readonly video: HTMLVideoElement;
  36990. private _onUserActionRequestedObservable;
  36991. readonly onUserActionRequestedObservable: Observable<Texture>;
  36992. private _generateMipMaps;
  36993. private _engine;
  36994. private _stillImageCaptured;
  36995. private _poster;
  36996. /**
  36997. * Creates a video texture.
  36998. * Sample : https://doc.babylonjs.com/how_to/video_texture
  36999. * @param {string | null} name optional name, will detect from video source, if not defined
  37000. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  37001. * @param {BABYLON.Scene} scene is obviously the current scene.
  37002. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  37003. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  37004. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  37005. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  37006. */
  37007. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  37008. private _getName;
  37009. private _getVideo;
  37010. private _createInternalTexture;
  37011. private reset;
  37012. /**
  37013. * @hidden Internal method to initiate `update`.
  37014. */
  37015. _rebuild(): void;
  37016. /**
  37017. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  37018. */
  37019. update(): void;
  37020. /**
  37021. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  37022. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  37023. */
  37024. updateTexture(isVisible: boolean): void;
  37025. protected _updateInternalTexture: (e?: Event | undefined) => void;
  37026. /**
  37027. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  37028. * @param url New url.
  37029. */
  37030. updateURL(url: string): void;
  37031. dispose(): void;
  37032. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  37033. minWidth: number;
  37034. maxWidth: number;
  37035. minHeight: number;
  37036. maxHeight: number;
  37037. deviceId: string;
  37038. }): void;
  37039. }
  37040. }
  37041. declare var DracoDecoderModule: any;
  37042. declare var WebAssembly: any;
  37043. declare module BABYLON {
  37044. /**
  37045. * Configuration for Draco compression
  37046. */
  37047. interface IDracoCompressionConfiguration {
  37048. /**
  37049. * Configuration for the decoder.
  37050. */
  37051. decoder?: {
  37052. /**
  37053. * The url to the WebAssembly module.
  37054. */
  37055. wasmUrl?: string;
  37056. /**
  37057. * The url to the WebAssembly binary.
  37058. */
  37059. wasmBinaryUrl?: string;
  37060. /**
  37061. * The url to the fallback JavaScript module.
  37062. */
  37063. fallbackUrl?: string;
  37064. };
  37065. }
  37066. /**
  37067. * Draco compression (https://google.github.io/draco/)
  37068. *
  37069. * This class wraps the Draco module.
  37070. *
  37071. * **Encoder**
  37072. *
  37073. * The encoder is not currently implemented.
  37074. *
  37075. * **Decoder**
  37076. *
  37077. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  37078. *
  37079. * To update the configuration, use the following code:
  37080. * ```javascript
  37081. * BABYLON.DracoCompression.Configuration = {
  37082. * decoder: {
  37083. * wasmUrl: "<url to the WebAssembly library>",
  37084. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  37085. * fallbackUrl: "<url to the fallback JavaScript library>",
  37086. * }
  37087. * };
  37088. * ```
  37089. *
  37090. * 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.
  37091. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  37092. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  37093. *
  37094. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  37095. * ```javascript
  37096. * var dracoCompression = new BABYLON.DracoCompression();
  37097. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  37098. * [BABYLON.VertexBuffer.PositionKind]: 0
  37099. * });
  37100. * ```
  37101. *
  37102. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  37103. */
  37104. class DracoCompression implements IDisposable {
  37105. private static _DecoderModulePromise;
  37106. /**
  37107. * The configuration. Defaults to the following urls:
  37108. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  37109. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  37110. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  37111. */
  37112. static Configuration: IDracoCompressionConfiguration;
  37113. /**
  37114. * Returns true if the decoder is available.
  37115. */
  37116. static readonly DecoderAvailable: boolean;
  37117. /**
  37118. * Constructor
  37119. */
  37120. constructor();
  37121. /**
  37122. * Stop all async operations and release resources.
  37123. */
  37124. dispose(): void;
  37125. /**
  37126. * Decode Draco compressed mesh data to vertex data.
  37127. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  37128. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  37129. * @returns A promise that resolves with the decoded vertex data
  37130. */
  37131. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  37132. [kind: string]: number;
  37133. }): Promise<VertexData>;
  37134. private static _GetDecoderModule;
  37135. private static _LoadScriptAsync;
  37136. private static _LoadFileAsync;
  37137. }
  37138. }
  37139. declare module BABYLON {
  37140. /**
  37141. * Particle emitter emitting particles from the inside of a box.
  37142. * It emits the particles randomly between 2 given directions.
  37143. */
  37144. class BoxParticleEmitter implements IParticleEmitterType {
  37145. /**
  37146. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  37147. */
  37148. direction1: Vector3;
  37149. /**
  37150. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  37151. */
  37152. direction2: Vector3;
  37153. /**
  37154. * 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.
  37155. */
  37156. minEmitBox: Vector3;
  37157. /**
  37158. * 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.
  37159. */
  37160. maxEmitBox: Vector3;
  37161. /**
  37162. * Creates a new instance BoxParticleEmitter
  37163. */
  37164. constructor();
  37165. /**
  37166. * Called by the particle System when the direction is computed for the created particle.
  37167. * @param worldMatrix is the world matrix of the particle system
  37168. * @param directionToUpdate is the direction vector to update with the result
  37169. * @param particle is the particle we are computed the direction for
  37170. */
  37171. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37172. /**
  37173. * Called by the particle System when the position is computed for the created particle.
  37174. * @param worldMatrix is the world matrix of the particle system
  37175. * @param positionToUpdate is the position vector to update with the result
  37176. * @param particle is the particle we are computed the position for
  37177. */
  37178. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37179. /**
  37180. * Clones the current emitter and returns a copy of it
  37181. * @returns the new emitter
  37182. */
  37183. clone(): BoxParticleEmitter;
  37184. /**
  37185. * Called by the GPUParticleSystem to setup the update shader
  37186. * @param effect defines the update shader
  37187. */
  37188. applyToShader(effect: Effect): void;
  37189. /**
  37190. * Returns a string to use to update the GPU particles update shader
  37191. * @returns a string containng the defines string
  37192. */
  37193. getEffectDefines(): string;
  37194. /**
  37195. * Returns the string "BoxParticleEmitter"
  37196. * @returns a string containing the class name
  37197. */
  37198. getClassName(): string;
  37199. /**
  37200. * Serializes the particle system to a JSON object.
  37201. * @returns the JSON object
  37202. */
  37203. serialize(): any;
  37204. /**
  37205. * Parse properties from a JSON object
  37206. * @param serializationObject defines the JSON object
  37207. */
  37208. parse(serializationObject: any): void;
  37209. }
  37210. }
  37211. declare module BABYLON {
  37212. /**
  37213. * Particle emitter emitting particles from the inside of a cone.
  37214. * It emits the particles alongside the cone volume from the base to the particle.
  37215. * The emission direction might be randomized.
  37216. */
  37217. class ConeParticleEmitter implements IParticleEmitterType {
  37218. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  37219. directionRandomizer: number;
  37220. private _radius;
  37221. private _angle;
  37222. private _height;
  37223. /**
  37224. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  37225. */
  37226. radiusRange: number;
  37227. /**
  37228. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  37229. */
  37230. heightRange: number;
  37231. /**
  37232. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  37233. */
  37234. emitFromSpawnPointOnly: boolean;
  37235. /**
  37236. * Gets or sets the radius of the emission cone
  37237. */
  37238. radius: number;
  37239. /**
  37240. * Gets or sets the angle of the emission cone
  37241. */
  37242. angle: number;
  37243. private _buildHeight;
  37244. /**
  37245. * Creates a new instance ConeParticleEmitter
  37246. * @param radius the radius of the emission cone (1 by default)
  37247. * @param angles the cone base angle (PI by default)
  37248. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  37249. */
  37250. constructor(radius?: number, angle?: number,
  37251. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  37252. directionRandomizer?: number);
  37253. /**
  37254. * Called by the particle System when the direction is computed for the created particle.
  37255. * @param worldMatrix is the world matrix of the particle system
  37256. * @param directionToUpdate is the direction vector to update with the result
  37257. * @param particle is the particle we are computed the direction for
  37258. */
  37259. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37260. /**
  37261. * Called by the particle System when the position is computed for the created particle.
  37262. * @param worldMatrix is the world matrix of the particle system
  37263. * @param positionToUpdate is the position vector to update with the result
  37264. * @param particle is the particle we are computed the position for
  37265. */
  37266. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37267. /**
  37268. * Clones the current emitter and returns a copy of it
  37269. * @returns the new emitter
  37270. */
  37271. clone(): ConeParticleEmitter;
  37272. /**
  37273. * Called by the GPUParticleSystem to setup the update shader
  37274. * @param effect defines the update shader
  37275. */
  37276. applyToShader(effect: Effect): void;
  37277. /**
  37278. * Returns a string to use to update the GPU particles update shader
  37279. * @returns a string containng the defines string
  37280. */
  37281. getEffectDefines(): string;
  37282. /**
  37283. * Returns the string "ConeParticleEmitter"
  37284. * @returns a string containing the class name
  37285. */
  37286. getClassName(): string;
  37287. /**
  37288. * Serializes the particle system to a JSON object.
  37289. * @returns the JSON object
  37290. */
  37291. serialize(): any;
  37292. /**
  37293. * Parse properties from a JSON object
  37294. * @param serializationObject defines the JSON object
  37295. */
  37296. parse(serializationObject: any): void;
  37297. }
  37298. }
  37299. declare module BABYLON {
  37300. /**
  37301. * Particle emitter emitting particles from the inside of a hemisphere.
  37302. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  37303. */
  37304. class HemisphericParticleEmitter implements IParticleEmitterType {
  37305. /**
  37306. * The radius of the emission hemisphere.
  37307. */
  37308. radius: number;
  37309. /**
  37310. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  37311. */
  37312. radiusRange: number;
  37313. /**
  37314. * How much to randomize the particle direction [0-1].
  37315. */
  37316. directionRandomizer: number;
  37317. /**
  37318. * Creates a new instance HemisphericParticleEmitter
  37319. * @param radius the radius of the emission hemisphere (1 by default)
  37320. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  37321. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  37322. */
  37323. constructor(
  37324. /**
  37325. * The radius of the emission hemisphere.
  37326. */
  37327. radius?: number,
  37328. /**
  37329. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  37330. */
  37331. radiusRange?: number,
  37332. /**
  37333. * How much to randomize the particle direction [0-1].
  37334. */
  37335. directionRandomizer?: number);
  37336. /**
  37337. * Called by the particle System when the direction is computed for the created particle.
  37338. * @param worldMatrix is the world matrix of the particle system
  37339. * @param directionToUpdate is the direction vector to update with the result
  37340. * @param particle is the particle we are computed the direction for
  37341. */
  37342. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37343. /**
  37344. * Called by the particle System when the position is computed for the created particle.
  37345. * @param worldMatrix is the world matrix of the particle system
  37346. * @param positionToUpdate is the position vector to update with the result
  37347. * @param particle is the particle we are computed the position for
  37348. */
  37349. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37350. /**
  37351. * Clones the current emitter and returns a copy of it
  37352. * @returns the new emitter
  37353. */
  37354. clone(): HemisphericParticleEmitter;
  37355. /**
  37356. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  37357. * @param effect defines the update shader
  37358. */
  37359. applyToShader(effect: Effect): void;
  37360. /**
  37361. * Returns a string to use to update the GPU particles update shader
  37362. * @returns a string containng the defines string
  37363. */
  37364. getEffectDefines(): string;
  37365. /**
  37366. * Returns the string "HemisphericParticleEmitter"
  37367. * @returns a string containing the class name
  37368. */
  37369. getClassName(): string;
  37370. /**
  37371. * Serializes the particle system to a JSON object.
  37372. * @returns the JSON object
  37373. */
  37374. serialize(): any;
  37375. /**
  37376. * Parse properties from a JSON object
  37377. * @param serializationObject defines the JSON object
  37378. */
  37379. parse(serializationObject: any): void;
  37380. }
  37381. }
  37382. declare module BABYLON {
  37383. /**
  37384. * Particle emitter represents a volume emitting particles.
  37385. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  37386. */
  37387. interface IParticleEmitterType {
  37388. /**
  37389. * Called by the particle System when the direction is computed for the created particle.
  37390. * @param worldMatrix is the world matrix of the particle system
  37391. * @param directionToUpdate is the direction vector to update with the result
  37392. * @param particle is the particle we are computed the direction for
  37393. */
  37394. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37395. /**
  37396. * Called by the particle System when the position is computed for the created particle.
  37397. * @param worldMatrix is the world matrix of the particle system
  37398. * @param positionToUpdate is the position vector to update with the result
  37399. * @param particle is the particle we are computed the position for
  37400. */
  37401. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37402. /**
  37403. * Clones the current emitter and returns a copy of it
  37404. * @returns the new emitter
  37405. */
  37406. clone(): IParticleEmitterType;
  37407. /**
  37408. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  37409. * @param effect defines the update shader
  37410. */
  37411. applyToShader(effect: Effect): void;
  37412. /**
  37413. * Returns a string to use to update the GPU particles update shader
  37414. * @returns the effect defines string
  37415. */
  37416. getEffectDefines(): string;
  37417. /**
  37418. * Returns a string representing the class name
  37419. * @returns a string containing the class name
  37420. */
  37421. getClassName(): string;
  37422. /**
  37423. * Serializes the particle system to a JSON object.
  37424. * @returns the JSON object
  37425. */
  37426. serialize(): any;
  37427. /**
  37428. * Parse properties from a JSON object
  37429. * @param serializationObject defines the JSON object
  37430. */
  37431. parse(serializationObject: any): void;
  37432. }
  37433. }
  37434. declare module BABYLON {
  37435. /**
  37436. * Particle emitter emitting particles from a point.
  37437. * It emits the particles randomly between 2 given directions.
  37438. */
  37439. class PointParticleEmitter implements IParticleEmitterType {
  37440. /**
  37441. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  37442. */
  37443. direction1: Vector3;
  37444. /**
  37445. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  37446. */
  37447. direction2: Vector3;
  37448. /**
  37449. * Creates a new instance PointParticleEmitter
  37450. */
  37451. constructor();
  37452. /**
  37453. * Called by the particle System when the direction is computed for the created particle.
  37454. * @param worldMatrix is the world matrix of the particle system
  37455. * @param directionToUpdate is the direction vector to update with the result
  37456. * @param particle is the particle we are computed the direction for
  37457. */
  37458. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37459. /**
  37460. * Called by the particle System when the position is computed for the created particle.
  37461. * @param worldMatrix is the world matrix of the particle system
  37462. * @param positionToUpdate is the position vector to update with the result
  37463. * @param particle is the particle we are computed the position for
  37464. */
  37465. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37466. /**
  37467. * Clones the current emitter and returns a copy of it
  37468. * @returns the new emitter
  37469. */
  37470. clone(): PointParticleEmitter;
  37471. /**
  37472. * Called by the GPUParticleSystem to setup the update shader
  37473. * @param effect defines the update shader
  37474. */
  37475. applyToShader(effect: Effect): void;
  37476. /**
  37477. * Returns a string to use to update the GPU particles update shader
  37478. * @returns a string containng the defines string
  37479. */
  37480. getEffectDefines(): string;
  37481. /**
  37482. * Returns the string "PointParticleEmitter"
  37483. * @returns a string containing the class name
  37484. */
  37485. getClassName(): string;
  37486. /**
  37487. * Serializes the particle system to a JSON object.
  37488. * @returns the JSON object
  37489. */
  37490. serialize(): any;
  37491. /**
  37492. * Parse properties from a JSON object
  37493. * @param serializationObject defines the JSON object
  37494. */
  37495. parse(serializationObject: any): void;
  37496. }
  37497. }
  37498. declare module BABYLON {
  37499. /**
  37500. * Particle emitter emitting particles from the inside of a sphere.
  37501. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  37502. */
  37503. class SphereParticleEmitter implements IParticleEmitterType {
  37504. /**
  37505. * The radius of the emission sphere.
  37506. */
  37507. radius: number;
  37508. /**
  37509. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  37510. */
  37511. radiusRange: number;
  37512. /**
  37513. * How much to randomize the particle direction [0-1].
  37514. */
  37515. directionRandomizer: number;
  37516. /**
  37517. * Creates a new instance SphereParticleEmitter
  37518. * @param radius the radius of the emission sphere (1 by default)
  37519. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  37520. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  37521. */
  37522. constructor(
  37523. /**
  37524. * The radius of the emission sphere.
  37525. */
  37526. radius?: number,
  37527. /**
  37528. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  37529. */
  37530. radiusRange?: number,
  37531. /**
  37532. * How much to randomize the particle direction [0-1].
  37533. */
  37534. directionRandomizer?: number);
  37535. /**
  37536. * Called by the particle System when the direction is computed for the created particle.
  37537. * @param worldMatrix is the world matrix of the particle system
  37538. * @param directionToUpdate is the direction vector to update with the result
  37539. * @param particle is the particle we are computed the direction for
  37540. */
  37541. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37542. /**
  37543. * Called by the particle System when the position is computed for the created particle.
  37544. * @param worldMatrix is the world matrix of the particle system
  37545. * @param positionToUpdate is the position vector to update with the result
  37546. * @param particle is the particle we are computed the position for
  37547. */
  37548. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37549. /**
  37550. * Clones the current emitter and returns a copy of it
  37551. * @returns the new emitter
  37552. */
  37553. clone(): SphereParticleEmitter;
  37554. /**
  37555. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  37556. * @param effect defines the update shader
  37557. */
  37558. applyToShader(effect: Effect): void;
  37559. /**
  37560. * Returns a string to use to update the GPU particles update shader
  37561. * @returns a string containng the defines string
  37562. */
  37563. getEffectDefines(): string;
  37564. /**
  37565. * Returns the string "SphereParticleEmitter"
  37566. * @returns a string containing the class name
  37567. */
  37568. getClassName(): string;
  37569. /**
  37570. * Serializes the particle system to a JSON object.
  37571. * @returns the JSON object
  37572. */
  37573. serialize(): any;
  37574. /**
  37575. * Parse properties from a JSON object
  37576. * @param serializationObject defines the JSON object
  37577. */
  37578. parse(serializationObject: any): void;
  37579. }
  37580. /**
  37581. * Particle emitter emitting particles from the inside of a sphere.
  37582. * It emits the particles randomly between two vectors.
  37583. */
  37584. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  37585. /**
  37586. * The min limit of the emission direction.
  37587. */
  37588. direction1: Vector3;
  37589. /**
  37590. * The max limit of the emission direction.
  37591. */
  37592. direction2: Vector3;
  37593. /**
  37594. * Creates a new instance SphereDirectedParticleEmitter
  37595. * @param radius the radius of the emission sphere (1 by default)
  37596. * @param direction1 the min limit of the emission direction (up vector by default)
  37597. * @param direction2 the max limit of the emission direction (up vector by default)
  37598. */
  37599. constructor(radius?: number,
  37600. /**
  37601. * The min limit of the emission direction.
  37602. */
  37603. direction1?: Vector3,
  37604. /**
  37605. * The max limit of the emission direction.
  37606. */
  37607. direction2?: Vector3);
  37608. /**
  37609. * Called by the particle System when the direction is computed for the created particle.
  37610. * @param worldMatrix is the world matrix of the particle system
  37611. * @param directionToUpdate is the direction vector to update with the result
  37612. * @param particle is the particle we are computed the direction for
  37613. */
  37614. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37615. /**
  37616. * Clones the current emitter and returns a copy of it
  37617. * @returns the new emitter
  37618. */
  37619. clone(): SphereDirectedParticleEmitter;
  37620. /**
  37621. * Called by the GPUParticleSystem to setup the update shader
  37622. * @param effect defines the update shader
  37623. */
  37624. applyToShader(effect: Effect): void;
  37625. /**
  37626. * Returns a string to use to update the GPU particles update shader
  37627. * @returns a string containng the defines string
  37628. */
  37629. getEffectDefines(): string;
  37630. /**
  37631. * Returns the string "SphereDirectedParticleEmitter"
  37632. * @returns a string containing the class name
  37633. */
  37634. getClassName(): string;
  37635. /**
  37636. * Serializes the particle system to a JSON object.
  37637. * @returns the JSON object
  37638. */
  37639. serialize(): any;
  37640. /**
  37641. * Parse properties from a JSON object
  37642. * @param serializationObject defines the JSON object
  37643. */
  37644. parse(serializationObject: any): void;
  37645. }
  37646. }
  37647. declare module BABYLON {
  37648. class CannonJSPlugin implements IPhysicsEnginePlugin {
  37649. private _useDeltaForWorldStep;
  37650. world: any;
  37651. name: string;
  37652. private _physicsMaterials;
  37653. private _fixedTimeStep;
  37654. BJSCANNON: any;
  37655. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  37656. setGravity(gravity: Vector3): void;
  37657. setTimeStep(timeStep: number): void;
  37658. getTimeStep(): number;
  37659. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  37660. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  37661. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  37662. generatePhysicsBody(impostor: PhysicsImpostor): void;
  37663. private _processChildMeshes;
  37664. removePhysicsBody(impostor: PhysicsImpostor): void;
  37665. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  37666. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  37667. private _addMaterial;
  37668. private _checkWithEpsilon;
  37669. private _createShape;
  37670. private _createHeightmap;
  37671. private _minus90X;
  37672. private _plus90X;
  37673. private _tmpPosition;
  37674. private _tmpDeltaPosition;
  37675. private _tmpUnityRotation;
  37676. private _updatePhysicsBodyTransformation;
  37677. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  37678. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  37679. isSupported(): boolean;
  37680. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  37681. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  37682. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  37683. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  37684. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  37685. getBodyMass(impostor: PhysicsImpostor): number;
  37686. getBodyFriction(impostor: PhysicsImpostor): number;
  37687. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  37688. getBodyRestitution(impostor: PhysicsImpostor): number;
  37689. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  37690. sleepBody(impostor: PhysicsImpostor): void;
  37691. wakeUpBody(impostor: PhysicsImpostor): void;
  37692. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  37693. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  37694. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  37695. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  37696. getRadius(impostor: PhysicsImpostor): number;
  37697. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  37698. dispose(): void;
  37699. private _extendNamespace;
  37700. }
  37701. }
  37702. declare module BABYLON {
  37703. class OimoJSPlugin implements IPhysicsEnginePlugin {
  37704. world: any;
  37705. name: string;
  37706. BJSOIMO: any;
  37707. constructor(iterations?: number);
  37708. setGravity(gravity: Vector3): void;
  37709. setTimeStep(timeStep: number): void;
  37710. getTimeStep(): number;
  37711. private _tmpImpostorsArray;
  37712. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  37713. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  37714. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  37715. generatePhysicsBody(impostor: PhysicsImpostor): void;
  37716. private _tmpPositionVector;
  37717. removePhysicsBody(impostor: PhysicsImpostor): void;
  37718. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  37719. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  37720. isSupported(): boolean;
  37721. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  37722. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  37723. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  37724. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  37725. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  37726. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  37727. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  37728. getBodyMass(impostor: PhysicsImpostor): number;
  37729. getBodyFriction(impostor: PhysicsImpostor): number;
  37730. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  37731. getBodyRestitution(impostor: PhysicsImpostor): number;
  37732. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  37733. sleepBody(impostor: PhysicsImpostor): void;
  37734. wakeUpBody(impostor: PhysicsImpostor): void;
  37735. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  37736. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  37737. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  37738. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  37739. getRadius(impostor: PhysicsImpostor): number;
  37740. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  37741. dispose(): void;
  37742. }
  37743. }
  37744. declare module BABYLON {
  37745. /**
  37746. * This represents a set of one or more post processes in Babylon.
  37747. * A post process can be used to apply a shader to a texture after it is rendered.
  37748. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  37749. */
  37750. class PostProcessRenderEffect {
  37751. private _postProcesses;
  37752. private _getPostProcesses;
  37753. private _singleInstance;
  37754. private _cameras;
  37755. private _indicesForCamera;
  37756. /**
  37757. * Name of the effect
  37758. * @hidden
  37759. */
  37760. _name: string;
  37761. /**
  37762. * Instantiates a post process render effect.
  37763. * A post process can be used to apply a shader to a texture after it is rendered.
  37764. * @param engine The engine the effect is tied to
  37765. * @param name The name of the effect
  37766. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  37767. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  37768. */
  37769. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  37770. /**
  37771. * Checks if all the post processes in the effect are supported.
  37772. */
  37773. readonly isSupported: boolean;
  37774. /**
  37775. * Updates the current state of the effect
  37776. * @hidden
  37777. */
  37778. _update(): void;
  37779. /**
  37780. * Attaches the effect on cameras
  37781. * @param cameras The camera to attach to.
  37782. * @hidden
  37783. */
  37784. _attachCameras(cameras: Camera): void;
  37785. /**
  37786. * Attaches the effect on cameras
  37787. * @param cameras The camera to attach to.
  37788. * @hidden
  37789. */
  37790. _attachCameras(cameras: Camera[]): void;
  37791. /**
  37792. * Detatches the effect on cameras
  37793. * @param cameras The camera to detatch from.
  37794. * @hidden
  37795. */
  37796. _detachCameras(cameras: Camera): void;
  37797. /**
  37798. * Detatches the effect on cameras
  37799. * @param cameras The camera to detatch from.
  37800. * @hidden
  37801. */
  37802. _detachCameras(cameras: Camera[]): void;
  37803. /**
  37804. * Enables the effect on given cameras
  37805. * @param cameras The camera to enable.
  37806. * @hidden
  37807. */
  37808. _enable(cameras: Camera): void;
  37809. /**
  37810. * Enables the effect on given cameras
  37811. * @param cameras The camera to enable.
  37812. * @hidden
  37813. */
  37814. _enable(cameras: Nullable<Camera[]>): void;
  37815. /**
  37816. * Disables the effect on the given cameras
  37817. * @param cameras The camera to disable.
  37818. * @hidden
  37819. */
  37820. _disable(cameras: Camera): void;
  37821. /**
  37822. * Disables the effect on the given cameras
  37823. * @param cameras The camera to disable.
  37824. * @hidden
  37825. */
  37826. _disable(cameras: Nullable<Camera[]>): void;
  37827. /**
  37828. * Gets a list of the post processes contained in the effect.
  37829. * @param camera The camera to get the post processes on.
  37830. * @returns The list of the post processes in the effect.
  37831. */
  37832. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  37833. }
  37834. }
  37835. declare module BABYLON {
  37836. class PostProcessRenderPipeline {
  37837. private engine;
  37838. private _renderEffects;
  37839. private _renderEffectsForIsolatedPass;
  37840. protected _cameras: Camera[];
  37841. /** @hidden */
  37842. _name: string;
  37843. constructor(engine: Engine, name: string);
  37844. getClassName(): string;
  37845. readonly isSupported: boolean;
  37846. addEffect(renderEffect: PostProcessRenderEffect): void;
  37847. /** @hidden */
  37848. _rebuild(): void;
  37849. /** @hidden */
  37850. _enableEffect(renderEffectName: string, cameras: Camera): void;
  37851. /** @hidden */
  37852. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  37853. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  37854. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  37855. /** @hidden */
  37856. _attachCameras(cameras: Camera, unique: boolean): void;
  37857. /** @hidden */
  37858. _attachCameras(cameras: Camera[], unique: boolean): void;
  37859. /** @hidden */
  37860. _detachCameras(cameras: Camera): void;
  37861. /** @hidden */
  37862. _detachCameras(cameras: Nullable<Camera[]>): void;
  37863. /** @hidden */
  37864. _update(): void;
  37865. /** @hidden */
  37866. _reset(): void;
  37867. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  37868. dispose(): void;
  37869. }
  37870. }
  37871. declare module BABYLON {
  37872. class PostProcessRenderPipelineManager {
  37873. private _renderPipelines;
  37874. constructor();
  37875. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  37876. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  37877. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  37878. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  37879. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  37880. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  37881. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  37882. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  37883. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  37884. update(): void;
  37885. /** @hidden */
  37886. _rebuild(): void;
  37887. dispose(): void;
  37888. }
  37889. }
  37890. declare module BABYLON {
  37891. /**
  37892. * Helper class dealing with the extraction of spherical polynomial dataArray
  37893. * from a cube map.
  37894. */
  37895. class CubeMapToSphericalPolynomialTools {
  37896. private static FileFaces;
  37897. /**
  37898. * Converts a texture to the according Spherical Polynomial data.
  37899. * This extracts the first 3 orders only as they are the only one used in the lighting.
  37900. *
  37901. * @param texture The texture to extract the information from.
  37902. * @return The Spherical Polynomial data.
  37903. */
  37904. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  37905. /**
  37906. * Converts a cubemap to the according Spherical Polynomial data.
  37907. * This extracts the first 3 orders only as they are the only one used in the lighting.
  37908. *
  37909. * @param cubeInfo The Cube map to extract the information from.
  37910. * @return The Spherical Polynomial data.
  37911. */
  37912. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  37913. }
  37914. }
  37915. declare module BABYLON {
  37916. /**
  37917. * Header information of HDR texture files.
  37918. */
  37919. interface HDRInfo {
  37920. /**
  37921. * The height of the texture in pixels.
  37922. */
  37923. height: number;
  37924. /**
  37925. * The width of the texture in pixels.
  37926. */
  37927. width: number;
  37928. /**
  37929. * The index of the beginning of the data in the binary file.
  37930. */
  37931. dataPosition: number;
  37932. }
  37933. /**
  37934. * This groups tools to convert HDR texture to native colors array.
  37935. */
  37936. class HDRTools {
  37937. private static Ldexp;
  37938. private static Rgbe2float;
  37939. private static readStringLine;
  37940. /**
  37941. * Reads header information from an RGBE texture stored in a native array.
  37942. * More information on this format are available here:
  37943. * https://en.wikipedia.org/wiki/RGBE_image_format
  37944. *
  37945. * @param uint8array The binary file stored in native array.
  37946. * @return The header information.
  37947. */
  37948. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  37949. /**
  37950. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  37951. * This RGBE texture needs to store the information as a panorama.
  37952. *
  37953. * More information on this format are available here:
  37954. * https://en.wikipedia.org/wiki/RGBE_image_format
  37955. *
  37956. * @param buffer The binary file stored in an array buffer.
  37957. * @param size The expected size of the extracted cubemap.
  37958. * @return The Cube Map information.
  37959. */
  37960. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  37961. /**
  37962. * Returns the pixels data extracted from an RGBE texture.
  37963. * This pixels will be stored left to right up to down in the R G B order in one array.
  37964. *
  37965. * More information on this format are available here:
  37966. * https://en.wikipedia.org/wiki/RGBE_image_format
  37967. *
  37968. * @param uint8array The binary file stored in an array buffer.
  37969. * @param hdrInfo The header information of the file.
  37970. * @return The pixels data in RGB right to left up to down order.
  37971. */
  37972. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  37973. private static RGBE_ReadPixels_RLE;
  37974. }
  37975. }
  37976. declare module BABYLON {
  37977. /**
  37978. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  37979. */
  37980. interface CubeMapInfo {
  37981. /**
  37982. * The pixel array for the front face.
  37983. * This is stored in format, left to right, up to down format.
  37984. */
  37985. front: Nullable<ArrayBufferView>;
  37986. /**
  37987. * The pixel array for the back face.
  37988. * This is stored in format, left to right, up to down format.
  37989. */
  37990. back: Nullable<ArrayBufferView>;
  37991. /**
  37992. * The pixel array for the left face.
  37993. * This is stored in format, left to right, up to down format.
  37994. */
  37995. left: Nullable<ArrayBufferView>;
  37996. /**
  37997. * The pixel array for the right face.
  37998. * This is stored in format, left to right, up to down format.
  37999. */
  38000. right: Nullable<ArrayBufferView>;
  38001. /**
  38002. * The pixel array for the up face.
  38003. * This is stored in format, left to right, up to down format.
  38004. */
  38005. up: Nullable<ArrayBufferView>;
  38006. /**
  38007. * The pixel array for the down face.
  38008. * This is stored in format, left to right, up to down format.
  38009. */
  38010. down: Nullable<ArrayBufferView>;
  38011. /**
  38012. * The size of the cubemap stored.
  38013. *
  38014. * Each faces will be size * size pixels.
  38015. */
  38016. size: number;
  38017. /**
  38018. * The format of the texture.
  38019. *
  38020. * RGBA, RGB.
  38021. */
  38022. format: number;
  38023. /**
  38024. * The type of the texture data.
  38025. *
  38026. * UNSIGNED_INT, FLOAT.
  38027. */
  38028. type: number;
  38029. /**
  38030. * Specifies whether the texture is in gamma space.
  38031. */
  38032. gammaSpace: boolean;
  38033. }
  38034. /**
  38035. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  38036. */
  38037. class PanoramaToCubeMapTools {
  38038. private static FACE_FRONT;
  38039. private static FACE_BACK;
  38040. private static FACE_RIGHT;
  38041. private static FACE_LEFT;
  38042. private static FACE_DOWN;
  38043. private static FACE_UP;
  38044. /**
  38045. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  38046. *
  38047. * @param float32Array The source data.
  38048. * @param inputWidth The width of the input panorama.
  38049. * @param inputhHeight The height of the input panorama.
  38050. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  38051. * @return The cubemap data
  38052. */
  38053. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  38054. private static CreateCubemapTexture;
  38055. private static CalcProjectionSpherical;
  38056. }
  38057. }
  38058. declare module BABYLON {
  38059. }
  38060. declare module BABYLON {
  38061. }
  38062. declare module BABYLON {
  38063. }
  38064. declare module BABYLON {
  38065. }
  38066. declare module BABYLON {
  38067. class CustomProceduralTexture extends ProceduralTexture {
  38068. private _animate;
  38069. private _time;
  38070. private _config;
  38071. private _texturePath;
  38072. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  38073. private loadJson;
  38074. isReady(): boolean;
  38075. render(useCameraPostProcess?: boolean): void;
  38076. updateTextures(): void;
  38077. updateShaderUniforms(): void;
  38078. animate: boolean;
  38079. }
  38080. }
  38081. declare module BABYLON {
  38082. /**
  38083. * Class used to generate noise procedural textures
  38084. */
  38085. class NoiseProceduralTexture extends ProceduralTexture {
  38086. private _time;
  38087. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  38088. brightness: number;
  38089. /** Defines the number of octaves to process */
  38090. octaves: number;
  38091. /** Defines the level of persistence (0.8 by default) */
  38092. persistence: number;
  38093. /** Gets or sets animation speed factor (default is 1) */
  38094. animationSpeedFactor: number;
  38095. /**
  38096. * Creates a new NoiseProceduralTexture
  38097. * @param name defines the name fo the texture
  38098. * @param size defines the size of the texture (default is 256)
  38099. * @param scene defines the hosting scene
  38100. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  38101. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  38102. */
  38103. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  38104. private _updateShaderUniforms;
  38105. /** Generate the current state of the procedural texture */
  38106. render(useCameraPostProcess?: boolean): void;
  38107. /**
  38108. * Serializes this noise procedural texture
  38109. * @returns a serialized noise procedural texture object
  38110. */
  38111. serialize(): any;
  38112. /**
  38113. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  38114. * @param parsedTexture defines parsed texture data
  38115. * @param scene defines the current scene
  38116. * @param rootUrl defines the root URL containing noise procedural texture information
  38117. * @returns a parsed NoiseProceduralTexture
  38118. */
  38119. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  38120. }
  38121. }
  38122. declare module BABYLON {
  38123. class ProceduralTexture extends Texture {
  38124. isCube: boolean;
  38125. private _size;
  38126. /** @hidden */
  38127. _generateMipMaps: boolean;
  38128. isEnabled: boolean;
  38129. private _currentRefreshId;
  38130. private _refreshRate;
  38131. onGenerated: () => void;
  38132. private _vertexBuffers;
  38133. private _indexBuffer;
  38134. private _effect;
  38135. private _uniforms;
  38136. private _samplers;
  38137. private _fragment;
  38138. /** @hidden */
  38139. _textures: {
  38140. [key: string]: Texture;
  38141. };
  38142. private _floats;
  38143. private _ints;
  38144. private _floatsArrays;
  38145. private _colors3;
  38146. private _colors4;
  38147. private _vectors2;
  38148. private _vectors3;
  38149. private _matrices;
  38150. private _fallbackTexture;
  38151. private _fallbackTextureUsed;
  38152. private _engine;
  38153. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  38154. private _createIndexBuffer;
  38155. /** @hidden */
  38156. _rebuild(): void;
  38157. reset(): void;
  38158. isReady(): boolean;
  38159. resetRefreshCounter(): void;
  38160. setFragment(fragment: any): void;
  38161. refreshRate: number;
  38162. /** @hidden */
  38163. _shouldRender(): boolean;
  38164. getRenderSize(): number;
  38165. resize(size: number, generateMipMaps: boolean): void;
  38166. private _checkUniform;
  38167. setTexture(name: string, texture: Texture): ProceduralTexture;
  38168. setFloat(name: string, value: number): ProceduralTexture;
  38169. /**
  38170. * Set the value of an uniform to an integer value
  38171. * @param name defines the name of the uniform
  38172. * @param value defines the value to set
  38173. * @returns the current procedural texture
  38174. */
  38175. setInt(name: string, value: number): ProceduralTexture;
  38176. setFloats(name: string, value: number[]): ProceduralTexture;
  38177. setColor3(name: string, value: Color3): ProceduralTexture;
  38178. setColor4(name: string, value: Color4): ProceduralTexture;
  38179. setVector2(name: string, value: Vector2): ProceduralTexture;
  38180. setVector3(name: string, value: Vector3): ProceduralTexture;
  38181. setMatrix(name: string, value: Matrix): ProceduralTexture;
  38182. render(useCameraPostProcess?: boolean): void;
  38183. clone(): ProceduralTexture;
  38184. dispose(): void;
  38185. }
  38186. }
  38187. declare module BABYLON {
  38188. /**
  38189. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  38190. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  38191. */
  38192. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  38193. private _scene;
  38194. private _camerasToBeAttached;
  38195. /**
  38196. * ID of the sharpen post process,
  38197. */
  38198. private readonly SharpenPostProcessId;
  38199. /**
  38200. * ID of the image processing post process;
  38201. */
  38202. readonly ImageProcessingPostProcessId: string;
  38203. /**
  38204. * ID of the Fast Approximate Anti-Aliasing post process;
  38205. */
  38206. readonly FxaaPostProcessId: string;
  38207. /**
  38208. * ID of the chromatic aberration post process,
  38209. */
  38210. private readonly ChromaticAberrationPostProcessId;
  38211. /**
  38212. * ID of the grain post process
  38213. */
  38214. private readonly GrainPostProcessId;
  38215. /**
  38216. * Sharpen post process which will apply a sharpen convolution to enhance edges
  38217. */
  38218. sharpen: SharpenPostProcess;
  38219. private _sharpenEffect;
  38220. private bloom;
  38221. /**
  38222. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  38223. */
  38224. depthOfField: DepthOfFieldEffect;
  38225. /**
  38226. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  38227. */
  38228. fxaa: FxaaPostProcess;
  38229. /**
  38230. * Image post processing pass used to perform operations such as tone mapping or color grading.
  38231. */
  38232. imageProcessing: ImageProcessingPostProcess;
  38233. /**
  38234. * Chromatic aberration post process which will shift rgb colors in the image
  38235. */
  38236. chromaticAberration: ChromaticAberrationPostProcess;
  38237. private _chromaticAberrationEffect;
  38238. /**
  38239. * Grain post process which add noise to the image
  38240. */
  38241. grain: GrainPostProcess;
  38242. private _grainEffect;
  38243. /**
  38244. * Glow post process which adds a glow to emmisive areas of the image
  38245. */
  38246. private _glowLayer;
  38247. /**
  38248. * Animations which can be used to tweak settings over a period of time
  38249. */
  38250. animations: Animation[];
  38251. private _imageProcessingConfigurationObserver;
  38252. private _sharpenEnabled;
  38253. private _bloomEnabled;
  38254. private _depthOfFieldEnabled;
  38255. private _depthOfFieldBlurLevel;
  38256. private _fxaaEnabled;
  38257. private _imageProcessingEnabled;
  38258. private _defaultPipelineTextureType;
  38259. private _bloomScale;
  38260. private _chromaticAberrationEnabled;
  38261. private _grainEnabled;
  38262. private _buildAllowed;
  38263. /**
  38264. * Enable or disable the sharpen process from the pipeline
  38265. */
  38266. sharpenEnabled: boolean;
  38267. private _resizeObserver;
  38268. private _hardwareScaleLevel;
  38269. private _bloomKernel;
  38270. /**
  38271. * Specifies the size of the bloom blur kernel, relative to the final output size
  38272. */
  38273. bloomKernel: number;
  38274. /**
  38275. * Specifies the weight of the bloom in the final rendering
  38276. */
  38277. private _bloomWeight;
  38278. /**
  38279. * Specifies the luma threshold for the area that will be blurred by the bloom
  38280. */
  38281. private _bloomThreshold;
  38282. private _hdr;
  38283. /**
  38284. * The strength of the bloom.
  38285. */
  38286. bloomWeight: number;
  38287. /**
  38288. * The strength of the bloom.
  38289. */
  38290. bloomThreshold: number;
  38291. /**
  38292. * The scale of the bloom, lower value will provide better performance.
  38293. */
  38294. bloomScale: number;
  38295. /**
  38296. * Enable or disable the bloom from the pipeline
  38297. */
  38298. bloomEnabled: boolean;
  38299. private _rebuildBloom;
  38300. /**
  38301. * If the depth of field is enabled.
  38302. */
  38303. depthOfFieldEnabled: boolean;
  38304. /**
  38305. * Blur level of the depth of field effect. (Higher blur will effect performance)
  38306. */
  38307. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  38308. /**
  38309. * If the anti aliasing is enabled.
  38310. */
  38311. fxaaEnabled: boolean;
  38312. private _samples;
  38313. /**
  38314. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  38315. */
  38316. samples: number;
  38317. /**
  38318. * If image processing is enabled.
  38319. */
  38320. imageProcessingEnabled: boolean;
  38321. /**
  38322. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  38323. */
  38324. glowLayerEnabled: boolean;
  38325. /**
  38326. * Enable or disable the chromaticAberration process from the pipeline
  38327. */
  38328. chromaticAberrationEnabled: boolean;
  38329. /**
  38330. * Enable or disable the grain process from the pipeline
  38331. */
  38332. grainEnabled: boolean;
  38333. /**
  38334. * @constructor
  38335. * @param {string} name - The rendering pipeline name (default: "")
  38336. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  38337. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  38338. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  38339. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  38340. */
  38341. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  38342. /**
  38343. * Force the compilation of the entire pipeline.
  38344. */
  38345. prepare(): void;
  38346. private _hasCleared;
  38347. private _prevPostProcess;
  38348. private _prevPrevPostProcess;
  38349. private _setAutoClearAndTextureSharing;
  38350. private _buildPipeline;
  38351. private _disposePostProcesses;
  38352. /**
  38353. * Adds a camera to the pipeline
  38354. * @param camera the camera to be added
  38355. */
  38356. addCamera(camera: Camera): void;
  38357. /**
  38358. * Removes a camera from the pipeline
  38359. * @param camera the camera to remove
  38360. */
  38361. removeCamera(camera: Camera): void;
  38362. /**
  38363. * Dispose of the pipeline and stop all post processes
  38364. */
  38365. dispose(): void;
  38366. /**
  38367. * Serialize the rendering pipeline (Used when exporting)
  38368. * @returns the serialized object
  38369. */
  38370. serialize(): any;
  38371. /**
  38372. * Parse the serialized pipeline
  38373. * @param source Source pipeline.
  38374. * @param scene The scene to load the pipeline to.
  38375. * @param rootUrl The URL of the serialized pipeline.
  38376. * @returns An instantiated pipeline from the serialized object.
  38377. */
  38378. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  38379. }
  38380. }
  38381. declare module BABYLON {
  38382. class LensRenderingPipeline extends PostProcessRenderPipeline {
  38383. /**
  38384. * The chromatic aberration PostProcess id in the pipeline
  38385. */
  38386. LensChromaticAberrationEffect: string;
  38387. /**
  38388. * The highlights enhancing PostProcess id in the pipeline
  38389. */
  38390. HighlightsEnhancingEffect: string;
  38391. /**
  38392. * The depth-of-field PostProcess id in the pipeline
  38393. */
  38394. LensDepthOfFieldEffect: string;
  38395. private _scene;
  38396. private _depthTexture;
  38397. private _grainTexture;
  38398. private _chromaticAberrationPostProcess;
  38399. private _highlightsPostProcess;
  38400. private _depthOfFieldPostProcess;
  38401. private _edgeBlur;
  38402. private _grainAmount;
  38403. private _chromaticAberration;
  38404. private _distortion;
  38405. private _highlightsGain;
  38406. private _highlightsThreshold;
  38407. private _dofDistance;
  38408. private _dofAperture;
  38409. private _dofDarken;
  38410. private _dofPentagon;
  38411. private _blurNoise;
  38412. /**
  38413. * @constructor
  38414. *
  38415. * Effect parameters are as follow:
  38416. * {
  38417. * chromatic_aberration: number; // from 0 to x (1 for realism)
  38418. * edge_blur: number; // from 0 to x (1 for realism)
  38419. * distortion: number; // from 0 to x (1 for realism)
  38420. * grain_amount: number; // from 0 to 1
  38421. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  38422. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  38423. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  38424. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  38425. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  38426. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  38427. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  38428. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  38429. * }
  38430. * Note: if an effect parameter is unset, effect is disabled
  38431. *
  38432. * @param {string} name - The rendering pipeline name
  38433. * @param {object} parameters - An object containing all parameters (see above)
  38434. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  38435. * @param {number} 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)
  38436. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  38437. */
  38438. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  38439. setEdgeBlur(amount: number): void;
  38440. disableEdgeBlur(): void;
  38441. setGrainAmount(amount: number): void;
  38442. disableGrain(): void;
  38443. setChromaticAberration(amount: number): void;
  38444. disableChromaticAberration(): void;
  38445. setEdgeDistortion(amount: number): void;
  38446. disableEdgeDistortion(): void;
  38447. setFocusDistance(amount: number): void;
  38448. disableDepthOfField(): void;
  38449. setAperture(amount: number): void;
  38450. setDarkenOutOfFocus(amount: number): void;
  38451. enablePentagonBokeh(): void;
  38452. disablePentagonBokeh(): void;
  38453. enableNoiseBlur(): void;
  38454. disableNoiseBlur(): void;
  38455. setHighlightsGain(amount: number): void;
  38456. setHighlightsThreshold(amount: number): void;
  38457. disableHighlights(): void;
  38458. /**
  38459. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  38460. */
  38461. dispose(disableDepthRender?: boolean): void;
  38462. private _createChromaticAberrationPostProcess;
  38463. private _createHighlightsPostProcess;
  38464. private _createDepthOfFieldPostProcess;
  38465. private _createGrainTexture;
  38466. }
  38467. }
  38468. declare module BABYLON {
  38469. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  38470. /**
  38471. * The PassPostProcess id in the pipeline that contains the original scene color
  38472. */
  38473. SSAOOriginalSceneColorEffect: string;
  38474. /**
  38475. * The SSAO PostProcess id in the pipeline
  38476. */
  38477. SSAORenderEffect: string;
  38478. /**
  38479. * The horizontal blur PostProcess id in the pipeline
  38480. */
  38481. SSAOBlurHRenderEffect: string;
  38482. /**
  38483. * The vertical blur PostProcess id in the pipeline
  38484. */
  38485. SSAOBlurVRenderEffect: string;
  38486. /**
  38487. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  38488. */
  38489. SSAOCombineRenderEffect: string;
  38490. /**
  38491. * The output strength of the SSAO post-process. Default value is 1.0.
  38492. */
  38493. totalStrength: number;
  38494. /**
  38495. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  38496. */
  38497. maxZ: number;
  38498. /**
  38499. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  38500. */
  38501. minZAspect: number;
  38502. /**
  38503. * Number of samples used for the SSAO calculations. Default value is 8
  38504. */
  38505. private _samples;
  38506. /**
  38507. * Ratio object used for SSAO ratio and blur ratio
  38508. */
  38509. private _ratio;
  38510. /**
  38511. * Dynamically generated sphere sampler.
  38512. */
  38513. private _sampleSphere;
  38514. /**
  38515. * Blur filter offsets
  38516. */
  38517. private _samplerOffsets;
  38518. samples: number;
  38519. /**
  38520. * Are we using bilateral blur ?
  38521. */
  38522. private _expensiveBlur;
  38523. expensiveBlur: boolean;
  38524. /**
  38525. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  38526. */
  38527. radius: number;
  38528. /**
  38529. * The base color of the SSAO post-process
  38530. * The final result is "base + ssao" between [0, 1]
  38531. */
  38532. base: number;
  38533. /**
  38534. * Support test.
  38535. */
  38536. static readonly IsSupported: boolean;
  38537. private _scene;
  38538. private _depthTexture;
  38539. private _normalTexture;
  38540. private _randomTexture;
  38541. private _originalColorPostProcess;
  38542. private _ssaoPostProcess;
  38543. private _blurHPostProcess;
  38544. private _blurVPostProcess;
  38545. private _ssaoCombinePostProcess;
  38546. private _firstUpdate;
  38547. /**
  38548. * @constructor
  38549. * @param {string} name - The rendering pipeline name
  38550. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  38551. * @param {any} 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 }
  38552. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  38553. */
  38554. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  38555. /**
  38556. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  38557. */
  38558. dispose(disableGeometryBufferRenderer?: boolean): void;
  38559. private _createBlurPostProcess;
  38560. /** @hidden */
  38561. _rebuild(): void;
  38562. private _generateHemisphere;
  38563. private _createSSAOPostProcess;
  38564. private _createSSAOCombinePostProcess;
  38565. private _createRandomTexture;
  38566. /**
  38567. * Serialize the rendering pipeline (Used when exporting)
  38568. * @returns the serialized object
  38569. */
  38570. serialize(): any;
  38571. /**
  38572. * Parse the serialized pipeline
  38573. * @param source Source pipeline.
  38574. * @param scene The scene to load the pipeline to.
  38575. * @param rootUrl The URL of the serialized pipeline.
  38576. * @returns An instantiated pipeline from the serialized object.
  38577. */
  38578. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  38579. }
  38580. }
  38581. declare module BABYLON {
  38582. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  38583. /**
  38584. * The PassPostProcess id in the pipeline that contains the original scene color
  38585. */
  38586. SSAOOriginalSceneColorEffect: string;
  38587. /**
  38588. * The SSAO PostProcess id in the pipeline
  38589. */
  38590. SSAORenderEffect: string;
  38591. /**
  38592. * The horizontal blur PostProcess id in the pipeline
  38593. */
  38594. SSAOBlurHRenderEffect: string;
  38595. /**
  38596. * The vertical blur PostProcess id in the pipeline
  38597. */
  38598. SSAOBlurVRenderEffect: string;
  38599. /**
  38600. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  38601. */
  38602. SSAOCombineRenderEffect: string;
  38603. /**
  38604. * The output strength of the SSAO post-process. Default value is 1.0.
  38605. */
  38606. totalStrength: number;
  38607. /**
  38608. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  38609. */
  38610. radius: number;
  38611. /**
  38612. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  38613. * Must not be equal to fallOff and superior to fallOff.
  38614. * Default value is 0.975
  38615. */
  38616. area: number;
  38617. /**
  38618. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  38619. * Must not be equal to area and inferior to area.
  38620. * Default value is 0.0
  38621. */
  38622. fallOff: number;
  38623. /**
  38624. * The base color of the SSAO post-process
  38625. * The final result is "base + ssao" between [0, 1]
  38626. */
  38627. base: number;
  38628. private _scene;
  38629. private _depthTexture;
  38630. private _randomTexture;
  38631. private _originalColorPostProcess;
  38632. private _ssaoPostProcess;
  38633. private _blurHPostProcess;
  38634. private _blurVPostProcess;
  38635. private _ssaoCombinePostProcess;
  38636. private _firstUpdate;
  38637. /**
  38638. * @constructor
  38639. * @param {string} name - The rendering pipeline name
  38640. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  38641. * @param {any} 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 }
  38642. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  38643. */
  38644. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  38645. /**
  38646. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  38647. */
  38648. dispose(disableDepthRender?: boolean): void;
  38649. private _createBlurPostProcess;
  38650. /** @hidden */
  38651. _rebuild(): void;
  38652. private _createSSAOPostProcess;
  38653. private _createSSAOCombinePostProcess;
  38654. private _createRandomTexture;
  38655. }
  38656. }
  38657. declare module BABYLON {
  38658. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  38659. /**
  38660. * Public members
  38661. */
  38662. originalPostProcess: Nullable<PostProcess>;
  38663. downSampleX4PostProcess: Nullable<PostProcess>;
  38664. brightPassPostProcess: Nullable<PostProcess>;
  38665. blurHPostProcesses: PostProcess[];
  38666. blurVPostProcesses: PostProcess[];
  38667. textureAdderPostProcess: Nullable<PostProcess>;
  38668. volumetricLightPostProcess: Nullable<PostProcess>;
  38669. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  38670. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  38671. volumetricLightMergePostProces: Nullable<PostProcess>;
  38672. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  38673. luminancePostProcess: Nullable<PostProcess>;
  38674. luminanceDownSamplePostProcesses: PostProcess[];
  38675. hdrPostProcess: Nullable<PostProcess>;
  38676. textureAdderFinalPostProcess: Nullable<PostProcess>;
  38677. lensFlareFinalPostProcess: Nullable<PostProcess>;
  38678. hdrFinalPostProcess: Nullable<PostProcess>;
  38679. lensFlarePostProcess: Nullable<PostProcess>;
  38680. lensFlareComposePostProcess: Nullable<PostProcess>;
  38681. motionBlurPostProcess: Nullable<PostProcess>;
  38682. depthOfFieldPostProcess: Nullable<PostProcess>;
  38683. brightThreshold: number;
  38684. blurWidth: number;
  38685. horizontalBlur: boolean;
  38686. exposure: number;
  38687. lensTexture: Nullable<Texture>;
  38688. volumetricLightCoefficient: number;
  38689. volumetricLightPower: number;
  38690. volumetricLightBlurScale: number;
  38691. sourceLight: Nullable<SpotLight | DirectionalLight>;
  38692. hdrMinimumLuminance: number;
  38693. hdrDecreaseRate: number;
  38694. hdrIncreaseRate: number;
  38695. lensColorTexture: Nullable<Texture>;
  38696. lensFlareStrength: number;
  38697. lensFlareGhostDispersal: number;
  38698. lensFlareHaloWidth: number;
  38699. lensFlareDistortionStrength: number;
  38700. lensStarTexture: Nullable<Texture>;
  38701. lensFlareDirtTexture: Nullable<Texture>;
  38702. depthOfFieldDistance: number;
  38703. depthOfFieldBlurWidth: number;
  38704. motionStrength: number;
  38705. animations: Animation[];
  38706. /**
  38707. * Private members
  38708. */
  38709. private _scene;
  38710. private _currentDepthOfFieldSource;
  38711. private _basePostProcess;
  38712. private _hdrCurrentLuminance;
  38713. private _floatTextureType;
  38714. private _ratio;
  38715. private _bloomEnabled;
  38716. private _depthOfFieldEnabled;
  38717. private _vlsEnabled;
  38718. private _lensFlareEnabled;
  38719. private _hdrEnabled;
  38720. private _motionBlurEnabled;
  38721. private _motionBlurSamples;
  38722. private _volumetricLightStepsCount;
  38723. BloomEnabled: boolean;
  38724. DepthOfFieldEnabled: boolean;
  38725. LensFlareEnabled: boolean;
  38726. HDREnabled: boolean;
  38727. VLSEnabled: boolean;
  38728. MotionBlurEnabled: boolean;
  38729. volumetricLightStepsCount: number;
  38730. motionBlurSamples: number;
  38731. /**
  38732. * @constructor
  38733. * @param {string} name - The rendering pipeline name
  38734. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  38735. * @param {any} 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)
  38736. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  38737. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  38738. */
  38739. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  38740. private _buildPipeline;
  38741. private _createDownSampleX4PostProcess;
  38742. private _createBrightPassPostProcess;
  38743. private _createBlurPostProcesses;
  38744. private _createTextureAdderPostProcess;
  38745. private _createVolumetricLightPostProcess;
  38746. private _createLuminancePostProcesses;
  38747. private _createHdrPostProcess;
  38748. private _createLensFlarePostProcess;
  38749. private _createDepthOfFieldPostProcess;
  38750. private _createMotionBlurPostProcess;
  38751. private _getDepthTexture;
  38752. private _disposePostProcesses;
  38753. /**
  38754. * Dispose of the pipeline and stop all post processes
  38755. */
  38756. dispose(): void;
  38757. /**
  38758. * Serialize the rendering pipeline (Used when exporting)
  38759. * @returns the serialized object
  38760. */
  38761. serialize(): any;
  38762. /**
  38763. * Parse the serialized pipeline
  38764. * @param source Source pipeline.
  38765. * @param scene The scene to load the pipeline to.
  38766. * @param rootUrl The URL of the serialized pipeline.
  38767. * @returns An instantiated pipeline from the serialized object.
  38768. */
  38769. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  38770. static LuminanceSteps: number;
  38771. }
  38772. }