babylon.d.ts 1.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /**
  62. * Gets the list of root nodes (ie. nodes with no parent)
  63. */
  64. rootNodes: Node[];
  65. /** All of the cameras added to this scene
  66. * @see http://doc.babylonjs.com/babylon101/cameras
  67. */
  68. cameras: Camera[];
  69. /**
  70. * All of the lights added to this scene
  71. * @see http://doc.babylonjs.com/babylon101/lights
  72. */
  73. lights: Light[];
  74. /**
  75. * All of the (abstract) meshes added to this scene
  76. */
  77. meshes: AbstractMesh[];
  78. /**
  79. * The list of skeletons added to the scene
  80. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81. */
  82. skeletons: Skeleton[];
  83. /**
  84. * All of the particle systems added to this scene
  85. * @see http://doc.babylonjs.com/babylon101/particles
  86. */
  87. particleSystems: IParticleSystem[];
  88. /**
  89. * Gets a list of Animations associated with the scene
  90. */
  91. animations: Animation[];
  92. /**
  93. * All of the animation groups added to this scene
  94. * @see http://doc.babylonjs.com/how_to/group
  95. */
  96. animationGroups: AnimationGroup[];
  97. /**
  98. * All of the multi-materials added to this scene
  99. * @see http://doc.babylonjs.com/how_to/multi_materials
  100. */
  101. multiMaterials: MultiMaterial[];
  102. /**
  103. * All of the materials added to this scene
  104. * @see http://doc.babylonjs.com/babylon101/materials
  105. */
  106. materials: Material[];
  107. /**
  108. * The list of morph target managers added to the scene
  109. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110. */
  111. morphTargetManagers: MorphTargetManager[];
  112. /**
  113. * The list of geometries used in the scene.
  114. */
  115. geometries: Geometry[];
  116. /**
  117. * All of the tranform nodes added to this scene
  118. * @see http://doc.babylonjs.com/how_to/transformnode
  119. */
  120. transformNodes: TransformNode[];
  121. /**
  122. * ActionManagers available on the scene.
  123. */
  124. actionManagers: ActionManager[];
  125. /**
  126. * Sounds to keep.
  127. */
  128. sounds: Sound[];
  129. /**
  130. * Textures to keep.
  131. */
  132. textures: BaseTexture[];
  133. }
  134. }
  135. declare module BABYLON {
  136. /**
  137. * Set of assets to keep when moving a scene into an asset container.
  138. */
  139. class KeepAssets extends AbstractScene {
  140. }
  141. /**
  142. * Container with a set of assets that can be added or removed from a scene.
  143. */
  144. class AssetContainer extends AbstractScene {
  145. /**
  146. * The scene the AssetContainer belongs to.
  147. */
  148. scene: Scene;
  149. /**
  150. * Instantiates an AssetContainer.
  151. * @param scene The scene the AssetContainer belongs to.
  152. */
  153. constructor(scene: Scene);
  154. /**
  155. * Adds all the assets from the container to the scene.
  156. */
  157. addAllToScene(): void;
  158. /**
  159. * Removes all the assets in the container from the scene
  160. */
  161. removeAllFromScene(): void;
  162. private _moveAssets;
  163. /**
  164. * Removes all the assets contained in the scene and adds them to the container.
  165. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  166. */
  167. moveAllFromScene(keepAssets?: KeepAssets): void;
  168. /**
  169. * 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.
  170. * @returns the root mesh
  171. */
  172. createRootMesh(): Mesh;
  173. }
  174. }
  175. interface Window {
  176. mozIndexedDB: IDBFactory;
  177. webkitIndexedDB: IDBFactory;
  178. msIndexedDB: IDBFactory;
  179. webkitURL: typeof URL;
  180. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  181. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  182. WebGLRenderingContext: WebGLRenderingContext;
  183. MSGesture: MSGesture;
  184. CANNON: any;
  185. AudioContext: AudioContext;
  186. webkitAudioContext: AudioContext;
  187. PointerEvent: any;
  188. Math: Math;
  189. Uint8Array: Uint8ArrayConstructor;
  190. Float32Array: Float32ArrayConstructor;
  191. mozURL: typeof URL;
  192. msURL: typeof URL;
  193. VRFrameData: any;
  194. DracoDecoderModule: any;
  195. }
  196. interface WebGLRenderingContext {
  197. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  198. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  199. vertexAttribDivisor(index: number, divisor: number): void;
  200. createVertexArray(): any;
  201. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  202. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  203. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  204. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  205. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  206. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  207. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  208. createQuery(): WebGLQuery;
  209. deleteQuery(query: WebGLQuery): void;
  210. beginQuery(target: number, query: WebGLQuery): void;
  211. endQuery(target: number): void;
  212. getQueryParameter(query: WebGLQuery, pname: number): any;
  213. getQuery(target: number, pname: number): any;
  214. MAX_SAMPLES: number;
  215. RGBA8: number;
  216. READ_FRAMEBUFFER: number;
  217. DRAW_FRAMEBUFFER: number;
  218. UNIFORM_BUFFER: number;
  219. HALF_FLOAT_OES: number;
  220. RGBA16F: number;
  221. RGBA32F: number;
  222. R32F: number;
  223. RG32F: number;
  224. RGB32F: number;
  225. R16F: number;
  226. RG16F: number;
  227. RGB16F: number;
  228. RED: number;
  229. RG: number;
  230. R8: number;
  231. RG8: number;
  232. UNSIGNED_INT_24_8: number;
  233. DEPTH24_STENCIL8: number;
  234. drawBuffers(buffers: number[]): void;
  235. readBuffer(src: number): void;
  236. readonly COLOR_ATTACHMENT0: number;
  237. readonly COLOR_ATTACHMENT1: number;
  238. readonly COLOR_ATTACHMENT2: number;
  239. readonly COLOR_ATTACHMENT3: number;
  240. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  241. ANY_SAMPLES_PASSED: number;
  242. QUERY_RESULT_AVAILABLE: number;
  243. QUERY_RESULT: number;
  244. }
  245. interface Document {
  246. mozCancelFullScreen(): void;
  247. msCancelFullScreen(): void;
  248. mozFullScreen: boolean;
  249. msIsFullScreen: boolean;
  250. fullscreen: boolean;
  251. mozPointerLockElement: HTMLElement;
  252. msPointerLockElement: HTMLElement;
  253. webkitPointerLockElement: HTMLElement;
  254. }
  255. interface HTMLCanvasElement {
  256. msRequestPointerLock?(): void;
  257. mozRequestPointerLock?(): void;
  258. webkitRequestPointerLock?(): void;
  259. }
  260. interface CanvasRenderingContext2D {
  261. msImageSmoothingEnabled: boolean;
  262. }
  263. interface WebGLBuffer {
  264. references: number;
  265. capacity: number;
  266. is32Bits: boolean;
  267. }
  268. interface WebGLProgram {
  269. transformFeedback?: WebGLTransformFeedback | null;
  270. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  271. }
  272. interface MouseEvent {
  273. mozMovementX: number;
  274. mozMovementY: number;
  275. webkitMovementX: number;
  276. webkitMovementY: number;
  277. msMovementX: number;
  278. msMovementY: number;
  279. }
  280. interface Navigator {
  281. mozGetVRDevices: (any: any) => any;
  282. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  283. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  284. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  285. webkitGetGamepads(): Gamepad[];
  286. msGetGamepads(): Gamepad[];
  287. webkitGamepads(): Gamepad[];
  288. }
  289. interface HTMLVideoElement {
  290. mozSrcObject: any;
  291. }
  292. interface Screen {
  293. orientation: string;
  294. mozOrientation: string;
  295. }
  296. interface Math {
  297. fround(x: number): number;
  298. imul(a: number, b: number): number;
  299. }
  300. interface EXT_disjoint_timer_query {
  301. QUERY_COUNTER_BITS_EXT: number;
  302. TIME_ELAPSED_EXT: number;
  303. TIMESTAMP_EXT: number;
  304. GPU_DISJOINT_EXT: number;
  305. QUERY_RESULT_EXT: number;
  306. QUERY_RESULT_AVAILABLE_EXT: number;
  307. queryCounterEXT(query: WebGLQuery, target: number): void;
  308. createQueryEXT(): WebGLQuery;
  309. beginQueryEXT(target: number, query: WebGLQuery): void;
  310. endQueryEXT(target: number): void;
  311. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  312. deleteQueryEXT(query: WebGLQuery): void;
  313. }
  314. interface WebGLUniformLocation {
  315. _currentState: any;
  316. }
  317. declare module BABYLON {
  318. /**
  319. * Defines how a node can be built from a string name.
  320. */
  321. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  322. /**
  323. * Node is the basic class for all scene objects (Mesh, Light Camera).
  324. */
  325. class Node implements IBehaviorAware<Node> {
  326. private static _NodeConstructors;
  327. /**
  328. * Add a new node constructor
  329. * @param type defines the type name of the node to construct
  330. * @param constructorFunc defines the constructor function
  331. */
  332. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  333. /**
  334. * Returns a node constructor based on type name
  335. * @param type defines the type name
  336. * @param name defines the new node name
  337. * @param scene defines the hosting scene
  338. * @param options defines optional options to transmit to constructors
  339. * @returns the new constructor or null
  340. */
  341. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  342. /**
  343. * Gets or sets the name of the node
  344. */
  345. name: string;
  346. /**
  347. * Gets or sets the id of the node
  348. */
  349. id: string;
  350. /**
  351. * Gets or sets the unique id of the node
  352. */
  353. uniqueId: number;
  354. /**
  355. * Gets or sets a string used to store user defined state for the node
  356. */
  357. state: string;
  358. /**
  359. * Gets or sets an object used to store user defined information for the node
  360. */
  361. metadata: any;
  362. /**
  363. * Gets or sets a boolean used to define if the node must be serialized
  364. */
  365. doNotSerialize: boolean;
  366. /** @hidden */
  367. _isDisposed: boolean;
  368. /**
  369. * Gets a list of Animations associated with the node
  370. */
  371. animations: Animation[];
  372. protected _ranges: {
  373. [name: string]: Nullable<AnimationRange>;
  374. };
  375. /**
  376. * Callback raised when the node is ready to be used
  377. */
  378. onReady: (node: Node) => void;
  379. private _isEnabled;
  380. private _isReady;
  381. /** @hidden */
  382. _currentRenderId: number;
  383. private _parentRenderId;
  384. protected _childRenderId: number;
  385. /** @hidden */
  386. _waitingParentId: Nullable<string>;
  387. /** @hidden */
  388. _scene: Scene;
  389. /** @hidden */
  390. _cache: any;
  391. private _parentNode;
  392. private _children;
  393. /** @hidden */
  394. _worldMatrix: Matrix;
  395. /** @hidden */
  396. _worldMatrixDeterminant: number;
  397. /**
  398. * Gets a boolean indicating if the node has been disposed
  399. * @returns true if the node was disposed
  400. */
  401. isDisposed(): boolean;
  402. /**
  403. * Gets or sets the parent of the node
  404. */
  405. parent: Nullable<Node>;
  406. private _animationPropertiesOverride;
  407. /**
  408. * Gets or sets the animation properties override
  409. */
  410. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  411. /**
  412. * Gets a string idenfifying the name of the class
  413. * @returns "Node" string
  414. */
  415. getClassName(): string;
  416. /**
  417. * An event triggered when the mesh is disposed
  418. */
  419. onDisposeObservable: Observable<Node>;
  420. private _onDisposeObserver;
  421. /**
  422. * Sets a callback that will be raised when the node will be disposed
  423. */
  424. onDispose: () => void;
  425. /**
  426. * Creates a new Node
  427. * @param {string} name - the name and id to be given to this node
  428. * @param {BABYLON.Scene} the scene this node will be added to
  429. */
  430. constructor(name: string, scene?: Nullable<Scene>);
  431. /**
  432. * Gets the scene of the node
  433. * @returns a {BABYLON.Scene}
  434. */
  435. getScene(): Scene;
  436. /**
  437. * Gets the engine of the node
  438. * @returns a {BABYLON.Engine}
  439. */
  440. getEngine(): Engine;
  441. private _behaviors;
  442. /**
  443. * Attach a behavior to the node
  444. * @see http://doc.babylonjs.com/features/behaviour
  445. * @param behavior defines the behavior to attach
  446. * @returns the current Node
  447. */
  448. addBehavior(behavior: Behavior<Node>): Node;
  449. /**
  450. * Remove an attached behavior
  451. * @see http://doc.babylonjs.com/features/behaviour
  452. * @param behavior defines the behavior to attach
  453. * @returns the current Node
  454. */
  455. removeBehavior(behavior: Behavior<Node>): Node;
  456. /**
  457. * Gets the list of attached behaviors
  458. * @see http://doc.babylonjs.com/features/behaviour
  459. */
  460. readonly behaviors: Behavior<Node>[];
  461. /**
  462. * Gets an attached behavior by name
  463. * @param name defines the name of the behavior to look for
  464. * @see http://doc.babylonjs.com/features/behaviour
  465. * @returns null if behavior was not found else the requested behavior
  466. */
  467. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  468. /**
  469. * Returns the latest update of the World matrix
  470. * @returns a Matrix
  471. */
  472. getWorldMatrix(): Matrix;
  473. /** @hidden */
  474. _getWorldMatrixDeterminant(): number;
  475. /**
  476. * Returns directly the latest state of the mesh World matrix.
  477. * A Matrix is returned.
  478. */
  479. readonly worldMatrixFromCache: Matrix;
  480. /** @hidden */
  481. _initCache(): void;
  482. /** @hidden */
  483. updateCache(force?: boolean): void;
  484. /** @hidden */
  485. _updateCache(ignoreParentClass?: boolean): void;
  486. /** @hidden */
  487. _isSynchronized(): boolean;
  488. /** @hidden */
  489. _markSyncedWithParent(): void;
  490. /** @hidden */
  491. isSynchronizedWithParent(): boolean;
  492. /** @hidden */
  493. isSynchronized(): boolean;
  494. /**
  495. * Is this node ready to be used/rendered
  496. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  497. * @return true if the node is ready
  498. */
  499. isReady(completeCheck?: boolean): boolean;
  500. /**
  501. * Is this node enabled?
  502. * 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
  503. * @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
  504. * @return whether this node (and its parent) is enabled
  505. */
  506. isEnabled(checkAncestors?: boolean): boolean;
  507. /**
  508. * Set the enabled state of this node
  509. * @param value defines the new enabled state
  510. */
  511. setEnabled(value: boolean): void;
  512. /**
  513. * Is this node a descendant of the given node?
  514. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  515. * @param ancestor defines the parent node to inspect
  516. * @returns a boolean indicating if this node is a descendant of the given node
  517. */
  518. isDescendantOf(ancestor: Node): boolean;
  519. /** @hidden */
  520. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  521. /**
  522. * Will return all nodes that have this node as ascendant
  523. * @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
  524. * @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
  525. * @return all children nodes of all types
  526. */
  527. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  528. /**
  529. * Get all child-meshes of this node
  530. * @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
  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.AbstractMesh}
  533. */
  534. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  535. /**
  536. * Get all child-transformNodes of this node
  537. * @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
  538. * @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
  539. * @returns an array of {BABYLON.TransformNode}
  540. */
  541. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  542. /**
  543. * Get all direct children of this node
  544. * @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
  545. * @returns an array of {BABYLON.Node}
  546. */
  547. getChildren(predicate?: (node: Node) => boolean): Node[];
  548. /** @hidden */
  549. _setReady(state: boolean): void;
  550. /**
  551. * Get an animation by name
  552. * @param name defines the name of the animation to look for
  553. * @returns null if not found else the requested animation
  554. */
  555. getAnimationByName(name: string): Nullable<Animation>;
  556. /**
  557. * Creates an animation range for this node
  558. * @param name defines the name of the range
  559. * @param from defines the starting key
  560. * @param to defines the end key
  561. */
  562. createAnimationRange(name: string, from: number, to: number): void;
  563. /**
  564. * Delete a specific animation range
  565. * @param name defines the name of the range to delete
  566. * @param deleteFrames defines if animation frames from the range must be deleted as well
  567. */
  568. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  569. /**
  570. * Get an animation range by name
  571. * @param name defines the name of the animation range to look for
  572. * @returns null if not found else the requested animation range
  573. */
  574. getAnimationRange(name: string): Nullable<AnimationRange>;
  575. /**
  576. * Will start the animation sequence
  577. * @param name defines the range frames for animation sequence
  578. * @param loop defines if the animation should loop (false by default)
  579. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  580. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  581. * @returns the object created for this animation. If range does not exist, it will return null
  582. */
  583. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  584. /**
  585. * Serialize animation ranges into a JSON compatible object
  586. * @returns serialization object
  587. */
  588. serializeAnimationRanges(): any;
  589. /**
  590. * Computes the world matrix of the node
  591. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  592. * @returns the world matrix
  593. */
  594. computeWorldMatrix(force?: boolean): Matrix;
  595. /**
  596. * Releases resources associated with this node.
  597. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  598. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  599. */
  600. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  601. /**
  602. * Parse animation range data from a serialization object and store them into a given node
  603. * @param node defines where to store the animation ranges
  604. * @param parsedNode defines the serialization object to read data from
  605. * @param scene defines the hosting scene
  606. */
  607. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  608. }
  609. }
  610. declare module BABYLON {
  611. /**
  612. * Define an interface for all classes that will hold resources
  613. */
  614. interface IDisposable {
  615. /**
  616. * Releases all held resources
  617. */
  618. dispose(): void;
  619. }
  620. /**
  621. * This class is used by the onRenderingGroupObservable
  622. */
  623. class RenderingGroupInfo {
  624. /**
  625. * The Scene that being rendered
  626. */
  627. scene: Scene;
  628. /**
  629. * The camera currently used for the rendering pass
  630. */
  631. camera: Nullable<Camera>;
  632. /**
  633. * The ID of the renderingGroup being processed
  634. */
  635. renderingGroupId: number;
  636. }
  637. /**
  638. * Represents a scene to be rendered by the engine.
  639. * @see http://doc.babylonjs.com/features/scene
  640. */
  641. class Scene extends AbstractScene implements IAnimatable {
  642. private static _uniqueIdCounter;
  643. /** The fog is deactivated */
  644. static readonly FOGMODE_NONE: number;
  645. /** The fog density is following an exponential function */
  646. static readonly FOGMODE_EXP: number;
  647. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  648. static readonly FOGMODE_EXP2: number;
  649. /** The fog density is following a linear function. */
  650. static readonly FOGMODE_LINEAR: number;
  651. /**
  652. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  653. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  654. */
  655. static MinDeltaTime: number;
  656. /**
  657. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  658. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  659. */
  660. static MaxDeltaTime: number;
  661. /**
  662. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  663. */
  664. autoClear: boolean;
  665. /**
  666. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  667. */
  668. autoClearDepthAndStencil: boolean;
  669. /**
  670. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  671. */
  672. clearColor: Color4;
  673. /**
  674. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  675. */
  676. ambientColor: Color3;
  677. /** @hidden */
  678. _environmentBRDFTexture: BaseTexture;
  679. /** @hidden */
  680. protected _environmentTexture: BaseTexture;
  681. /**
  682. * Texture used in all pbr material as the reflection texture.
  683. * As in the majority of the scene they are the same (exception for multi room and so on),
  684. * this is easier to reference from here than from all the materials.
  685. */
  686. /**
  687. * Texture used in all pbr material as the reflection texture.
  688. * As in the majority of the scene they are the same (exception for multi room and so on),
  689. * this is easier to set here than in all the materials.
  690. */
  691. environmentTexture: BaseTexture;
  692. /** @hidden */
  693. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  694. /**
  695. * Default image processing configuration used either in the rendering
  696. * Forward main pass or through the imageProcessingPostProcess if present.
  697. * As in the majority of the scene they are the same (exception for multi camera),
  698. * this is easier to reference from here than from all the materials and post process.
  699. *
  700. * No setter as we it is a shared configuration, you can set the values instead.
  701. */
  702. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  703. private _forceWireframe;
  704. /**
  705. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  706. */
  707. forceWireframe: boolean;
  708. private _forcePointsCloud;
  709. /**
  710. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  711. */
  712. forcePointsCloud: boolean;
  713. /**
  714. * Gets or sets the active clipplane 1
  715. */
  716. clipPlane: Nullable<Plane>;
  717. /**
  718. * Gets or sets the active clipplane 2
  719. */
  720. clipPlane2: Nullable<Plane>;
  721. /**
  722. * Gets or sets the active clipplane 3
  723. */
  724. clipPlane3: Nullable<Plane>;
  725. /**
  726. * Gets or sets the active clipplane 4
  727. */
  728. clipPlane4: Nullable<Plane>;
  729. /**
  730. * Gets or sets a boolean indicating if animations are enabled
  731. */
  732. animationsEnabled: boolean;
  733. private _animationPropertiesOverride;
  734. /**
  735. * Gets or sets the animation properties override
  736. */
  737. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  738. /**
  739. * Gets or sets a boolean indicating if a constant deltatime has to be used
  740. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  741. */
  742. useConstantAnimationDeltaTime: boolean;
  743. /**
  744. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  745. * Please note that it requires to run a ray cast through the scene on every frame
  746. */
  747. constantlyUpdateMeshUnderPointer: boolean;
  748. /**
  749. * Defines the HTML cursor to use when hovering over interactive elements
  750. */
  751. hoverCursor: string;
  752. /**
  753. * Defines the HTML default cursor to use (empty by default)
  754. */
  755. defaultCursor: string;
  756. /**
  757. * This is used to call preventDefault() on pointer down
  758. * in order to block unwanted artifacts like system double clicks
  759. */
  760. preventDefaultOnPointerDown: boolean;
  761. /**
  762. * Gets or sets user defined metadata
  763. */
  764. metadata: any;
  765. /**
  766. * Gets the name of the plugin used to load this scene (null by default)
  767. */
  768. loadingPluginName: string;
  769. /**
  770. * Use this array to add regular expressions used to disable offline support for specific urls
  771. */
  772. disableOfflineSupportExceptionRules: RegExp[];
  773. /**
  774. * An event triggered when the scene is disposed.
  775. */
  776. onDisposeObservable: Observable<Scene>;
  777. private _onDisposeObserver;
  778. /** Sets a function to be executed when this scene is disposed. */
  779. onDispose: () => void;
  780. /**
  781. * An event triggered before rendering the scene (right after animations and physics)
  782. */
  783. onBeforeRenderObservable: Observable<Scene>;
  784. private _onBeforeRenderObserver;
  785. /** Sets a function to be executed before rendering this scene */
  786. beforeRender: Nullable<() => void>;
  787. /**
  788. * An event triggered after rendering the scene
  789. */
  790. onAfterRenderObservable: Observable<Scene>;
  791. private _onAfterRenderObserver;
  792. /** Sets a function to be executed after rendering this scene */
  793. afterRender: Nullable<() => void>;
  794. /**
  795. * An event triggered before animating the scene
  796. */
  797. onBeforeAnimationsObservable: Observable<Scene>;
  798. /**
  799. * An event triggered after animations processing
  800. */
  801. onAfterAnimationsObservable: Observable<Scene>;
  802. /**
  803. * An event triggered before draw calls are ready to be sent
  804. */
  805. onBeforeDrawPhaseObservable: Observable<Scene>;
  806. /**
  807. * An event triggered after draw calls have been sent
  808. */
  809. onAfterDrawPhaseObservable: Observable<Scene>;
  810. /**
  811. * An event triggered when physic simulation is about to be run
  812. */
  813. onBeforePhysicsObservable: Observable<Scene>;
  814. /**
  815. * An event triggered when physic simulation has been done
  816. */
  817. onAfterPhysicsObservable: Observable<Scene>;
  818. /**
  819. * An event triggered when the scene is ready
  820. */
  821. onReadyObservable: Observable<Scene>;
  822. /**
  823. * An event triggered before rendering a camera
  824. */
  825. onBeforeCameraRenderObservable: Observable<Camera>;
  826. private _onBeforeCameraRenderObserver;
  827. /** Sets a function to be executed before rendering a camera*/
  828. beforeCameraRender: () => void;
  829. /**
  830. * An event triggered after rendering a camera
  831. */
  832. onAfterCameraRenderObservable: Observable<Camera>;
  833. private _onAfterCameraRenderObserver;
  834. /** Sets a function to be executed after rendering a camera*/
  835. afterCameraRender: () => void;
  836. /**
  837. * An event triggered when active meshes evaluation is about to start
  838. */
  839. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  840. /**
  841. * An event triggered when active meshes evaluation is done
  842. */
  843. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  844. /**
  845. * An event triggered when particles rendering is about to start
  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. onBeforeParticlesRenderingObservable: Observable<Scene>;
  849. /**
  850. * An event triggered when particles rendering is done
  851. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  852. */
  853. onAfterParticlesRenderingObservable: Observable<Scene>;
  854. /**
  855. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  856. */
  857. onDataLoadedObservable: Observable<Scene>;
  858. /**
  859. * An event triggered when a camera is created
  860. */
  861. onNewCameraAddedObservable: Observable<Camera>;
  862. /**
  863. * An event triggered when a camera is removed
  864. */
  865. onCameraRemovedObservable: Observable<Camera>;
  866. /**
  867. * An event triggered when a light is created
  868. */
  869. onNewLightAddedObservable: Observable<Light>;
  870. /**
  871. * An event triggered when a light is removed
  872. */
  873. onLightRemovedObservable: Observable<Light>;
  874. /**
  875. * An event triggered when a geometry is created
  876. */
  877. onNewGeometryAddedObservable: Observable<Geometry>;
  878. /**
  879. * An event triggered when a geometry is removed
  880. */
  881. onGeometryRemovedObservable: Observable<Geometry>;
  882. /**
  883. * An event triggered when a transform node is created
  884. */
  885. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  886. /**
  887. * An event triggered when a transform node is removed
  888. */
  889. onTransformNodeRemovedObservable: Observable<TransformNode>;
  890. /**
  891. * An event triggered when a mesh is created
  892. */
  893. onNewMeshAddedObservable: Observable<AbstractMesh>;
  894. /**
  895. * An event triggered when a mesh is removed
  896. */
  897. onMeshRemovedObservable: Observable<AbstractMesh>;
  898. /**
  899. * An event triggered when render targets are about to be rendered
  900. * Can happen multiple times per frame.
  901. */
  902. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  903. /**
  904. * An event triggered when render targets were rendered.
  905. * Can happen multiple times per frame.
  906. */
  907. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  908. /**
  909. * An event triggered before calculating deterministic simulation step
  910. */
  911. onBeforeStepObservable: Observable<Scene>;
  912. /**
  913. * An event triggered after calculating deterministic simulation step
  914. */
  915. onAfterStepObservable: Observable<Scene>;
  916. /**
  917. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  918. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  919. * 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)
  920. */
  921. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  922. /**
  923. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  924. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  925. * 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)
  926. */
  927. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  928. /**
  929. * This Observable will when a mesh has been imported into the scene.
  930. */
  931. onMeshImportedObservable: Observable<AbstractMesh>;
  932. private _registeredForLateAnimationBindings;
  933. /**
  934. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  935. */
  936. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  937. /**
  938. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  939. */
  940. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  941. /**
  942. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  943. */
  944. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  945. private _onPointerMove;
  946. private _onPointerDown;
  947. private _onPointerUp;
  948. /** Deprecated. Use onPointerObservable instead */
  949. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  950. /** Deprecated. Use onPointerObservable instead */
  951. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  952. /** Deprecated. Use onPointerObservable instead */
  953. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  954. /** Deprecated. Use onPointerObservable instead */
  955. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  956. /**
  957. * 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).
  958. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  959. */
  960. onPrePointerObservable: Observable<PointerInfoPre>;
  961. /**
  962. * Observable event triggered each time an input event is received from the rendering canvas
  963. */
  964. onPointerObservable: Observable<PointerInfo>;
  965. /**
  966. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  967. */
  968. readonly unTranslatedPointer: Vector2;
  969. /** The distance in pixel that you have to move to prevent some events */
  970. static DragMovementThreshold: number;
  971. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  972. static LongPressDelay: number;
  973. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  974. static DoubleClickDelay: number;
  975. /** If you need to check double click without raising a single click at first click, enable this flag */
  976. static ExclusiveDoubleClickMode: boolean;
  977. private _initClickEvent;
  978. private _initActionManager;
  979. private _delayedSimpleClick;
  980. private _delayedSimpleClickTimeout;
  981. private _previousDelayedSimpleClickTimeout;
  982. private _meshPickProceed;
  983. private _previousButtonPressed;
  984. private _currentPickResult;
  985. private _previousPickResult;
  986. private _totalPointersPressed;
  987. private _doubleClickOccured;
  988. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  989. cameraToUseForPointers: Nullable<Camera>;
  990. private _pointerX;
  991. private _pointerY;
  992. private _unTranslatedPointerX;
  993. private _unTranslatedPointerY;
  994. private _startingPointerPosition;
  995. private _previousStartingPointerPosition;
  996. private _startingPointerTime;
  997. private _previousStartingPointerTime;
  998. private _pointerCaptures;
  999. private _timeAccumulator;
  1000. private _currentStepId;
  1001. private _currentInternalStep;
  1002. /** @hidden */
  1003. _mirroredCameraPosition: Nullable<Vector3>;
  1004. /**
  1005. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1006. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1007. */
  1008. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1009. /**
  1010. * Observable event triggered each time an keyboard event is received from the hosting window
  1011. */
  1012. onKeyboardObservable: Observable<KeyboardInfo>;
  1013. private _onKeyDown;
  1014. private _onKeyUp;
  1015. private _onCanvasFocusObserver;
  1016. private _onCanvasBlurObserver;
  1017. private _useRightHandedSystem;
  1018. /**
  1019. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1020. */
  1021. useRightHandedSystem: boolean;
  1022. /**
  1023. * Sets the step Id used by deterministic lock step
  1024. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1025. * @param newStepId defines the step Id
  1026. */
  1027. setStepId(newStepId: number): void;
  1028. /**
  1029. * Gets the step Id used by deterministic lock step
  1030. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1031. * @returns the step Id
  1032. */
  1033. getStepId(): number;
  1034. /**
  1035. * Gets the internal step used by deterministic lock step
  1036. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1037. * @returns the internal step
  1038. */
  1039. getInternalStep(): number;
  1040. private _fogEnabled;
  1041. /**
  1042. * Gets or sets a boolean indicating if fog is enabled on this scene
  1043. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1044. */
  1045. fogEnabled: boolean;
  1046. private _fogMode;
  1047. /**
  1048. * Gets or sets the fog mode to use
  1049. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1050. */
  1051. fogMode: number;
  1052. /**
  1053. * Gets or sets the fog color to use
  1054. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1055. */
  1056. fogColor: Color3;
  1057. /**
  1058. * Gets or sets the fog density to use
  1059. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1060. */
  1061. fogDensity: number;
  1062. /**
  1063. * Gets or sets the fog start distance to use
  1064. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1065. */
  1066. fogStart: number;
  1067. /**
  1068. * Gets or sets the fog end distance to use
  1069. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1070. */
  1071. fogEnd: number;
  1072. private _shadowsEnabled;
  1073. /**
  1074. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1075. */
  1076. shadowsEnabled: boolean;
  1077. private _lightsEnabled;
  1078. /**
  1079. * Gets or sets a boolean indicating if lights are enabled on this scene
  1080. */
  1081. lightsEnabled: boolean;
  1082. /** All of the active cameras added to this scene. */
  1083. activeCameras: Camera[];
  1084. /** The current active camera */
  1085. activeCamera: Nullable<Camera>;
  1086. private _defaultMaterial;
  1087. /** The default material used on meshes when no material is affected */
  1088. /** The default material used on meshes when no material is affected */
  1089. defaultMaterial: Material;
  1090. private _texturesEnabled;
  1091. /**
  1092. * Gets or sets a boolean indicating if textures are enabled on this scene
  1093. */
  1094. texturesEnabled: boolean;
  1095. /**
  1096. * Gets or sets a boolean indicating if particles are enabled on this scene
  1097. */
  1098. particlesEnabled: boolean;
  1099. /**
  1100. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1101. */
  1102. spritesEnabled: boolean;
  1103. private _skeletonsEnabled;
  1104. /**
  1105. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1106. */
  1107. skeletonsEnabled: boolean;
  1108. /**
  1109. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1110. */
  1111. lensFlaresEnabled: boolean;
  1112. /**
  1113. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1114. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1115. */
  1116. collisionsEnabled: boolean;
  1117. private _workerCollisions;
  1118. /** @hidden */
  1119. collisionCoordinator: ICollisionCoordinator;
  1120. /**
  1121. * Defines the gravity applied to this scene (used only for collisions)
  1122. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1123. */
  1124. gravity: Vector3;
  1125. /**
  1126. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1127. */
  1128. postProcessesEnabled: boolean;
  1129. /**
  1130. * The list of postprocesses added to the scene
  1131. */
  1132. postProcesses: PostProcess[];
  1133. /**
  1134. * Gets the current postprocess manager
  1135. */
  1136. postProcessManager: PostProcessManager;
  1137. /**
  1138. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1139. */
  1140. renderTargetsEnabled: boolean;
  1141. /**
  1142. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1143. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1144. */
  1145. dumpNextRenderTargets: boolean;
  1146. /**
  1147. * The list of user defined render targets added to the scene
  1148. */
  1149. customRenderTargets: RenderTargetTexture[];
  1150. /**
  1151. * Defines if texture loading must be delayed
  1152. * If true, textures will only be loaded when they need to be rendered
  1153. */
  1154. useDelayedTextureLoading: boolean;
  1155. /**
  1156. * Gets the list of meshes imported to the scene through SceneLoader
  1157. */
  1158. importedMeshesFiles: String[];
  1159. /**
  1160. * Gets or sets a boolean indicating if probes are enabled on this scene
  1161. */
  1162. probesEnabled: boolean;
  1163. /**
  1164. * @hidden
  1165. */
  1166. database: Database;
  1167. /**
  1168. * Gets or sets the action manager associated with the scene
  1169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1170. */
  1171. actionManager: ActionManager;
  1172. private _meshesForIntersections;
  1173. /**
  1174. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1175. */
  1176. proceduralTexturesEnabled: boolean;
  1177. private _mainSoundTrack;
  1178. /**
  1179. * The list of sound tracks added to the scene
  1180. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1181. */
  1182. soundTracks: SoundTrack[];
  1183. private _audioEnabled;
  1184. private _headphone;
  1185. /**
  1186. * Gets the main soundtrack associated with the scene
  1187. */
  1188. readonly mainSoundTrack: SoundTrack;
  1189. private _engine;
  1190. private _totalVertices;
  1191. /** @hidden */
  1192. _activeIndices: PerfCounter;
  1193. /** @hidden */
  1194. _activeParticles: PerfCounter;
  1195. /** @hidden */
  1196. _activeBones: PerfCounter;
  1197. private _animationRatio;
  1198. private _animationTimeLast;
  1199. private _animationTime;
  1200. /**
  1201. * Gets or sets a general scale for animation speed
  1202. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1203. */
  1204. animationTimeScale: number;
  1205. /** @hidden */
  1206. _cachedMaterial: Nullable<Material>;
  1207. /** @hidden */
  1208. _cachedEffect: Nullable<Effect>;
  1209. /** @hidden */
  1210. _cachedVisibility: Nullable<number>;
  1211. private _renderId;
  1212. private _frameId;
  1213. private _executeWhenReadyTimeoutId;
  1214. private _intermediateRendering;
  1215. private _viewUpdateFlag;
  1216. private _projectionUpdateFlag;
  1217. private _alternateViewUpdateFlag;
  1218. private _alternateProjectionUpdateFlag;
  1219. /** @hidden */
  1220. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1221. private _activeRequests;
  1222. private _pendingData;
  1223. private _isDisposed;
  1224. /**
  1225. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1226. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1227. */
  1228. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1229. private _activeMeshes;
  1230. private _processedMaterials;
  1231. private _renderTargets;
  1232. /** @hidden */
  1233. _activeParticleSystems: SmartArray<IParticleSystem>;
  1234. private _activeSkeletons;
  1235. private _softwareSkinnedMeshes;
  1236. private _renderingManager;
  1237. private _physicsEngine;
  1238. /** @hidden */
  1239. _activeAnimatables: Animatable[];
  1240. private _transformMatrix;
  1241. private _sceneUbo;
  1242. private _alternateSceneUbo;
  1243. private _pickWithRayInverseMatrix;
  1244. private _viewMatrix;
  1245. private _projectionMatrix;
  1246. private _alternateViewMatrix;
  1247. private _alternateProjectionMatrix;
  1248. private _alternateTransformMatrix;
  1249. private _useAlternateCameraConfiguration;
  1250. private _alternateRendering;
  1251. /** @hidden */
  1252. _forcedViewPosition: Nullable<Vector3>;
  1253. /** @hidden */
  1254. readonly _isAlternateRenderingEnabled: boolean;
  1255. private _frustumPlanes;
  1256. /**
  1257. * Gets the list of frustum planes (built from the active camera)
  1258. */
  1259. readonly frustumPlanes: Plane[];
  1260. /**
  1261. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1262. * This is useful if there are more lights that the maximum simulteanous authorized
  1263. */
  1264. requireLightSorting: boolean;
  1265. private _pointerOverMesh;
  1266. private _pickedDownMesh;
  1267. private _pickedUpMesh;
  1268. private _externalData;
  1269. private _uid;
  1270. /**
  1271. * @hidden
  1272. * Backing store of defined scene components.
  1273. */
  1274. _components: ISceneComponent[];
  1275. /**
  1276. * @hidden
  1277. * Backing store of defined scene components.
  1278. */
  1279. _serializableComponents: ISceneSerializableComponent[];
  1280. /**
  1281. * List of components to register on the next registration step.
  1282. */
  1283. private _transientComponents;
  1284. /**
  1285. * Registers the transient components if needed.
  1286. */
  1287. private _registerTransientComponents;
  1288. /**
  1289. * @hidden
  1290. * Add a component to the scene.
  1291. * Note that the ccomponent could be registered on th next frame if this is called after
  1292. * the register component stage.
  1293. * @param component Defines the component to add to the scene
  1294. */
  1295. _addComponent(component: ISceneComponent): void;
  1296. /**
  1297. * @hidden
  1298. * Gets a component from the scene.
  1299. * @param name defines the name of the component to retrieve
  1300. * @returns the component or null if not present
  1301. */
  1302. _getComponent(name: string): Nullable<ISceneComponent>;
  1303. /**
  1304. * @hidden
  1305. * Defines the actions happening before camera updates.
  1306. */
  1307. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1308. /**
  1309. * @hidden
  1310. * Defines the actions happening before clear the canvas.
  1311. */
  1312. _beforeClearStage: Stage<SimpleStageAction>;
  1313. /**
  1314. * @hidden
  1315. * Defines the actions when collecting render targets for the frame.
  1316. */
  1317. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1318. /**
  1319. * @hidden
  1320. * Defines the actions happening for one camera in the frame.
  1321. */
  1322. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1323. /**
  1324. * @hidden
  1325. * Defines the actions happening during the per mesh ready checks.
  1326. */
  1327. _isReadyForMeshStage: Stage<MeshStageAction>;
  1328. /**
  1329. * @hidden
  1330. * Defines the actions happening before evaluate active mesh checks.
  1331. */
  1332. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1333. /**
  1334. * @hidden
  1335. * Defines the actions happening during the evaluate sub mesh checks.
  1336. */
  1337. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1338. /**
  1339. * @hidden
  1340. * Defines the actions happening during the active mesh stage.
  1341. */
  1342. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1343. /**
  1344. * @hidden
  1345. * Defines the actions happening during the per camera render target step.
  1346. */
  1347. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1348. /**
  1349. * @hidden
  1350. * Defines the actions happening just before the active camera is drawing.
  1351. */
  1352. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1353. /**
  1354. * @hidden
  1355. * Defines the actions happening just before a rendering group is drawing.
  1356. */
  1357. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1358. /**
  1359. * @hidden
  1360. * Defines the actions happening just before a mesh is drawing.
  1361. */
  1362. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1363. /**
  1364. * @hidden
  1365. * Defines the actions happening just after a mesh has been drawn.
  1366. */
  1367. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1368. /**
  1369. * @hidden
  1370. * Defines the actions happening just after a rendering group has been drawn.
  1371. */
  1372. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1373. /**
  1374. * @hidden
  1375. * Defines the actions happening just after the active camera has been drawn.
  1376. */
  1377. _afterCameraDrawStage: Stage<CameraStageAction>;
  1378. /**
  1379. * @hidden
  1380. * Defines the actions happening when a pointer move event happens.
  1381. */
  1382. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1383. /**
  1384. * @hidden
  1385. * Defines the actions happening when a pointer down event happens.
  1386. */
  1387. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1388. /**
  1389. * @hidden
  1390. * Defines the actions happening when a pointer up event happens.
  1391. */
  1392. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1393. /**
  1394. * Creates a new Scene
  1395. * @param engine defines the engine to use to render this scene
  1396. */
  1397. constructor(engine: Engine);
  1398. private _defaultMeshCandidates;
  1399. /**
  1400. * @hidden
  1401. */
  1402. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1403. private _defaultSubMeshCandidates;
  1404. /**
  1405. * @hidden
  1406. */
  1407. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1408. /**
  1409. * Sets the default candidate providers for the scene.
  1410. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1411. * and getCollidingSubMeshCandidates to their default function
  1412. */
  1413. setDefaultCandidateProviders(): void;
  1414. /**
  1415. * Gets a boolean indicating if collisions are processed on a web worker
  1416. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1417. */
  1418. workerCollisions: boolean;
  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 engine associated with the scene
  1456. * @returns an Engine
  1457. */
  1458. getEngine(): Engine;
  1459. /**
  1460. * Gets the total number of vertices rendered per frame
  1461. * @returns the total number of vertices rendered per frame
  1462. */
  1463. getTotalVertices(): number;
  1464. /**
  1465. * Gets the performance counter for total vertices
  1466. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1467. */
  1468. readonly totalVerticesPerfCounter: PerfCounter;
  1469. /**
  1470. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1471. * @returns the total number of active indices rendered per frame
  1472. */
  1473. getActiveIndices(): number;
  1474. /**
  1475. * Gets the performance counter for active indices
  1476. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1477. */
  1478. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1479. /**
  1480. * Gets the total number of active particles rendered per frame
  1481. * @returns the total number of active particles rendered per frame
  1482. */
  1483. getActiveParticles(): number;
  1484. /**
  1485. * Gets the performance counter for active particles
  1486. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1487. */
  1488. readonly activeParticlesPerfCounter: PerfCounter;
  1489. /**
  1490. * Gets the total number of active bones rendered per frame
  1491. * @returns the total number of active bones rendered per frame
  1492. */
  1493. getActiveBones(): number;
  1494. /**
  1495. * Gets the performance counter for active bones
  1496. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1497. */
  1498. readonly activeBonesPerfCounter: PerfCounter;
  1499. /** @hidden */
  1500. getInterFramePerfCounter(): number;
  1501. /** @hidden */
  1502. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1503. /** @hidden */
  1504. getLastFrameDuration(): number;
  1505. /** @hidden */
  1506. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1507. /** @hidden */
  1508. getEvaluateActiveMeshesDuration(): number;
  1509. /** @hidden */
  1510. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1511. /**
  1512. * Gets the array of active meshes
  1513. * @returns an array of AbstractMesh
  1514. */
  1515. getActiveMeshes(): SmartArray<AbstractMesh>;
  1516. /** @hidden */
  1517. getRenderTargetsDuration(): number;
  1518. /** @hidden */
  1519. getRenderDuration(): number;
  1520. /** @hidden */
  1521. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1522. /** @hidden */
  1523. getParticlesDuration(): number;
  1524. /** @hidden */
  1525. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1526. /** @hidden */
  1527. getSpritesDuration(): number;
  1528. /** @hidden */
  1529. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1530. /**
  1531. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1532. * @returns a number
  1533. */
  1534. getAnimationRatio(): number;
  1535. /**
  1536. * Gets an unique Id for the current render phase
  1537. * @returns a number
  1538. */
  1539. getRenderId(): number;
  1540. /**
  1541. * Gets an unique Id for the current frame
  1542. * @returns a number
  1543. */
  1544. getFrameId(): 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 _setRayOnPointerInfo;
  1551. /**
  1552. * Use this method to simulate a pointer move on a mesh
  1553. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1554. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1555. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1556. * @returns the current scene
  1557. */
  1558. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1559. private _processPointerMove;
  1560. private _checkPrePointerObservable;
  1561. /**
  1562. * Use this method to simulate a pointer down on a mesh
  1563. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1564. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1565. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1566. * @returns the current scene
  1567. */
  1568. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1569. private _processPointerDown;
  1570. /**
  1571. * Use this method to simulate a pointer up on a mesh
  1572. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1573. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1574. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1575. * @returns the current scene
  1576. */
  1577. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1578. private _processPointerUp;
  1579. /**
  1580. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1581. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1582. * @returns true if the pointer was captured
  1583. */
  1584. isPointerCaptured(pointerId?: number): boolean;
  1585. /** @hidden */
  1586. _isPointerSwiping(): boolean;
  1587. /**
  1588. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1589. * @param attachUp defines if you want to attach events to pointerup
  1590. * @param attachDown defines if you want to attach events to pointerdown
  1591. * @param attachMove defines if you want to attach events to pointermove
  1592. */
  1593. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1594. /** Detaches all event handlers*/
  1595. detachControl(): void;
  1596. /**
  1597. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1598. * Delay loaded resources are not taking in account
  1599. * @return true if all required resources are ready
  1600. */
  1601. isReady(): boolean;
  1602. /** Resets all cached information relative to material (including effect and visibility) */
  1603. resetCachedMaterial(): void;
  1604. /**
  1605. * Registers a function to be called before every frame render
  1606. * @param func defines the function to register
  1607. */
  1608. registerBeforeRender(func: () => void): void;
  1609. /**
  1610. * Unregisters a function called before every frame render
  1611. * @param func defines the function to unregister
  1612. */
  1613. unregisterBeforeRender(func: () => void): void;
  1614. /**
  1615. * Registers a function to be called after every frame render
  1616. * @param func defines the function to register
  1617. */
  1618. registerAfterRender(func: () => void): void;
  1619. /**
  1620. * Unregisters a function called after every frame render
  1621. * @param func defines the function to unregister
  1622. */
  1623. unregisterAfterRender(func: () => void): void;
  1624. private _executeOnceBeforeRender;
  1625. /**
  1626. * The provided function will run before render once and will be disposed afterwards.
  1627. * A timeout delay can be provided so that the function will be executed in N ms.
  1628. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1629. * @param func The function to be executed.
  1630. * @param timeout optional delay in ms
  1631. */
  1632. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1633. /** @hidden */
  1634. _addPendingData(data: any): void;
  1635. /** @hidden */
  1636. _removePendingData(data: any): void;
  1637. /**
  1638. * Returns the number of items waiting to be loaded
  1639. * @returns the number of items waiting to be loaded
  1640. */
  1641. getWaitingItemsCount(): number;
  1642. /**
  1643. * Returns a boolean indicating if the scene is still loading data
  1644. */
  1645. readonly isLoading: boolean;
  1646. /**
  1647. * Registers a function to be executed when the scene is ready
  1648. * @param {Function} func - the function to be executed
  1649. */
  1650. executeWhenReady(func: () => void): void;
  1651. /**
  1652. * Returns a promise that resolves when the scene is ready
  1653. * @returns A promise that resolves when the scene is ready
  1654. */
  1655. whenReadyAsync(): Promise<void>;
  1656. /** @hidden */
  1657. _checkIsReady(): void;
  1658. /**
  1659. * Will start the animation sequence of a given target
  1660. * @param target defines the target
  1661. * @param from defines from which frame should animation start
  1662. * @param to defines until which frame should animation run.
  1663. * @param weight defines the weight to apply to the animation (1.0 by default)
  1664. * @param loop defines if the animation loops
  1665. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1666. * @param onAnimationEnd defines the function to be executed when the animation ends
  1667. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1668. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1669. * @returns the animatable object created for this animation
  1670. */
  1671. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1672. /**
  1673. * Will start the animation sequence of a given target
  1674. * @param target defines the target
  1675. * @param from defines from which frame should animation start
  1676. * @param to defines until which frame should animation run.
  1677. * @param loop defines if the animation loops
  1678. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1679. * @param onAnimationEnd defines the function to be executed when the animation ends
  1680. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1681. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1682. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1683. * @returns the animatable object created for this animation
  1684. */
  1685. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1686. /**
  1687. * Begin a new animation on a given node
  1688. * @param target defines the target where the animation will take place
  1689. * @param animations defines the list of animations to start
  1690. * @param from defines the initial value
  1691. * @param to defines the final value
  1692. * @param loop defines if you want animation to loop (off by default)
  1693. * @param speedRatio defines the speed ratio to apply to all animations
  1694. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1695. * @returns the list of created animatables
  1696. */
  1697. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1698. /**
  1699. * Begin a new animation on a given node and its hierarchy
  1700. * @param target defines the root node where the animation will take place
  1701. * @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.
  1702. * @param animations defines the list of animations to start
  1703. * @param from defines the initial value
  1704. * @param to defines the final value
  1705. * @param loop defines if you want animation to loop (off by default)
  1706. * @param speedRatio defines the speed ratio to apply to all animations
  1707. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1708. * @returns the list of animatables created for all nodes
  1709. */
  1710. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1711. /**
  1712. * Gets the animatable associated with a specific target
  1713. * @param target defines the target of the animatable
  1714. * @returns the required animatable if found
  1715. */
  1716. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1717. /**
  1718. * Gets all animatables associated with a given target
  1719. * @param target defines the target to look animatables for
  1720. * @returns an array of Animatables
  1721. */
  1722. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1723. /**
  1724. * Gets all animatable attached to the scene
  1725. */
  1726. readonly animatables: Animatable[];
  1727. /**
  1728. * Will stop the animation of the given target
  1729. * @param target - the target
  1730. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1731. * @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)
  1732. */
  1733. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1734. /**
  1735. * Stops and removes all animations that have been applied to the scene
  1736. */
  1737. stopAllAnimations(): void;
  1738. private _animate;
  1739. /** @hidden */
  1740. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1741. private _processLateAnimationBindingsForMatrices;
  1742. private _processLateAnimationBindingsForQuaternions;
  1743. private _processLateAnimationBindings;
  1744. /** @hidden */
  1745. _switchToAlternateCameraConfiguration(active: boolean): void;
  1746. /**
  1747. * Gets the current view matrix
  1748. * @returns a Matrix
  1749. */
  1750. getViewMatrix(): Matrix;
  1751. /**
  1752. * Gets the current projection matrix
  1753. * @returns a Matrix
  1754. */
  1755. getProjectionMatrix(): Matrix;
  1756. /**
  1757. * Gets the current transform matrix
  1758. * @returns a Matrix made of View * Projection
  1759. */
  1760. getTransformMatrix(): Matrix;
  1761. /**
  1762. * Sets the current transform matrix
  1763. * @param view defines the View matrix to use
  1764. * @param projection defines the Projection matrix to use
  1765. */
  1766. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1767. /** @hidden */
  1768. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1769. /**
  1770. * Gets the uniform buffer used to store scene data
  1771. * @returns a UniformBuffer
  1772. */
  1773. getSceneUniformBuffer(): UniformBuffer;
  1774. /**
  1775. * Gets an unique (relatively to the current scene) Id
  1776. * @returns an unique number for the scene
  1777. */
  1778. getUniqueId(): number;
  1779. /**
  1780. * Add a mesh to the list of scene's meshes
  1781. * @param newMesh defines the mesh to add
  1782. * @param recursive if all child meshes should also be added to the scene
  1783. */
  1784. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1785. /**
  1786. * Remove a mesh for the list of scene's meshes
  1787. * @param toRemove defines the mesh to remove
  1788. * @param recursive if all child meshes should also be removed from the scene
  1789. * @returns the index where the mesh was in the mesh list
  1790. */
  1791. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1792. /**
  1793. * Add a transform node to the list of scene's transform nodes
  1794. * @param newTransformNode defines the transform node to add
  1795. */
  1796. addTransformNode(newTransformNode: TransformNode): void;
  1797. /**
  1798. * Remove a transform node for the list of scene's transform nodes
  1799. * @param toRemove defines the transform node to remove
  1800. * @returns the index where the transform node was in the transform node list
  1801. */
  1802. removeTransformNode(toRemove: TransformNode): number;
  1803. /**
  1804. * Remove a skeleton for the list of scene's skeletons
  1805. * @param toRemove defines the skeleton to remove
  1806. * @returns the index where the skeleton was in the skeleton list
  1807. */
  1808. removeSkeleton(toRemove: Skeleton): number;
  1809. /**
  1810. * Remove a morph target for the list of scene's morph targets
  1811. * @param toRemove defines the morph target to remove
  1812. * @returns the index where the morph target was in the morph target list
  1813. */
  1814. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1815. /**
  1816. * Remove a light for the list of scene's lights
  1817. * @param toRemove defines the light to remove
  1818. * @returns the index where the light was in the light list
  1819. */
  1820. removeLight(toRemove: Light): number;
  1821. /**
  1822. * Remove a camera for the list of scene's cameras
  1823. * @param toRemove defines the camera to remove
  1824. * @returns the index where the camera was in the camera list
  1825. */
  1826. removeCamera(toRemove: Camera): number;
  1827. /**
  1828. * Remove a particle system for the list of scene's particle systems
  1829. * @param toRemove defines the particle system to remove
  1830. * @returns the index where the particle system was in the particle system list
  1831. */
  1832. removeParticleSystem(toRemove: IParticleSystem): number;
  1833. /**
  1834. * Remove a animation for the list of scene's animations
  1835. * @param toRemove defines the animation to remove
  1836. * @returns the index where the animation was in the animation list
  1837. */
  1838. removeAnimation(toRemove: Animation): number;
  1839. /**
  1840. * Removes the given animation group from this scene.
  1841. * @param toRemove The animation group to remove
  1842. * @returns The index of the removed animation group
  1843. */
  1844. removeAnimationGroup(toRemove: AnimationGroup): number;
  1845. /**
  1846. * Removes the given multi-material from this scene.
  1847. * @param toRemove The multi-material to remove
  1848. * @returns The index of the removed multi-material
  1849. */
  1850. removeMultiMaterial(toRemove: MultiMaterial): number;
  1851. /**
  1852. * Removes the given material from this scene.
  1853. * @param toRemove The material to remove
  1854. * @returns The index of the removed material
  1855. */
  1856. removeMaterial(toRemove: Material): number;
  1857. /**
  1858. * Removes the given action manager from this scene.
  1859. * @param toRemove The action manager to remove
  1860. * @returns The index of the removed action manager
  1861. */
  1862. removeActionManager(toRemove: ActionManager): number;
  1863. /**
  1864. * Removes the given texture from this scene.
  1865. * @param toRemove The texture to remove
  1866. * @returns The index of the removed texture
  1867. */
  1868. removeTexture(toRemove: BaseTexture): number;
  1869. /**
  1870. * Adds the given light to this scene
  1871. * @param newLight The light to add
  1872. */
  1873. addLight(newLight: Light): void;
  1874. /**
  1875. * Sorts the list list based on light priorities
  1876. */
  1877. sortLightsByPriority(): void;
  1878. /**
  1879. * Adds the given camera to this scene
  1880. * @param newCamera The camera to add
  1881. */
  1882. addCamera(newCamera: Camera): void;
  1883. /**
  1884. * Adds the given skeleton to this scene
  1885. * @param newSkeleton The skeleton to add
  1886. */
  1887. addSkeleton(newSkeleton: Skeleton): void;
  1888. /**
  1889. * Adds the given particle system to this scene
  1890. * @param newParticleSystem The particle system to add
  1891. */
  1892. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1893. /**
  1894. * Adds the given animation to this scene
  1895. * @param newAnimation The animation to add
  1896. */
  1897. addAnimation(newAnimation: Animation): void;
  1898. /**
  1899. * Adds the given animation group to this scene.
  1900. * @param newAnimationGroup The animation group to add
  1901. */
  1902. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1903. /**
  1904. * Adds the given multi-material to this scene
  1905. * @param newMultiMaterial The multi-material to add
  1906. */
  1907. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1908. /**
  1909. * Adds the given material to this scene
  1910. * @param newMaterial The material to add
  1911. */
  1912. addMaterial(newMaterial: Material): void;
  1913. /**
  1914. * Adds the given morph target to this scene
  1915. * @param newMorphTargetManager The morph target to add
  1916. */
  1917. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1918. /**
  1919. * Adds the given geometry to this scene
  1920. * @param newGeometry The geometry to add
  1921. */
  1922. addGeometry(newGeometry: Geometry): void;
  1923. /**
  1924. * Adds the given action manager to this scene
  1925. * @param newActionManager The action manager to add
  1926. */
  1927. addActionManager(newActionManager: ActionManager): void;
  1928. /**
  1929. * Adds the given texture to this scene.
  1930. * @param newTexture The texture to add
  1931. */
  1932. addTexture(newTexture: BaseTexture): void;
  1933. /**
  1934. * Switch active camera
  1935. * @param newCamera defines the new active camera
  1936. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1937. */
  1938. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1939. /**
  1940. * sets the active camera of the scene using its ID
  1941. * @param id defines the camera's ID
  1942. * @return the new active camera or null if none found.
  1943. */
  1944. setActiveCameraByID(id: string): Nullable<Camera>;
  1945. /**
  1946. * sets the active camera of the scene using its name
  1947. * @param name defines the camera's name
  1948. * @returns the new active camera or null if none found.
  1949. */
  1950. setActiveCameraByName(name: string): Nullable<Camera>;
  1951. /**
  1952. * get an animation group using its name
  1953. * @param name defines the material's name
  1954. * @return the animation group or null if none found.
  1955. */
  1956. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1957. /**
  1958. * get a material using its id
  1959. * @param id defines the material's ID
  1960. * @return the material or null if none found.
  1961. */
  1962. getMaterialByID(id: string): Nullable<Material>;
  1963. /**
  1964. * Gets a material using its name
  1965. * @param name defines the material's name
  1966. * @return the material or null if none found.
  1967. */
  1968. getMaterialByName(name: string): Nullable<Material>;
  1969. /**
  1970. * Gets a camera using its id
  1971. * @param id defines the id to look for
  1972. * @returns the camera or null if not found
  1973. */
  1974. getCameraByID(id: string): Nullable<Camera>;
  1975. /**
  1976. * Gets a camera using its unique id
  1977. * @param uniqueId defines the unique id to look for
  1978. * @returns the camera or null if not found
  1979. */
  1980. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1981. /**
  1982. * Gets a camera using its name
  1983. * @param name defines the camera's name
  1984. * @return the camera or null if none found.
  1985. */
  1986. getCameraByName(name: string): Nullable<Camera>;
  1987. /**
  1988. * Gets a bone using its id
  1989. * @param id defines the bone's id
  1990. * @return the bone or null if not found
  1991. */
  1992. getBoneByID(id: string): Nullable<Bone>;
  1993. /**
  1994. * Gets a bone using its id
  1995. * @param name defines the bone's name
  1996. * @return the bone or null if not found
  1997. */
  1998. getBoneByName(name: string): Nullable<Bone>;
  1999. /**
  2000. * Gets a light node using its name
  2001. * @param name defines the the light's name
  2002. * @return the light or null if none found.
  2003. */
  2004. getLightByName(name: string): Nullable<Light>;
  2005. /**
  2006. * Gets a light node using its id
  2007. * @param id defines the light's id
  2008. * @return the light or null if none found.
  2009. */
  2010. getLightByID(id: string): Nullable<Light>;
  2011. /**
  2012. * Gets a light node using its scene-generated unique ID
  2013. * @param uniqueId defines the light's unique id
  2014. * @return the light or null if none found.
  2015. */
  2016. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2017. /**
  2018. * Gets a particle system by id
  2019. * @param id defines the particle system id
  2020. * @return the corresponding system or null if none found
  2021. */
  2022. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2023. /**
  2024. * Gets a geometry using its ID
  2025. * @param id defines the geometry's id
  2026. * @return the geometry or null if none found.
  2027. */
  2028. getGeometryByID(id: string): Nullable<Geometry>;
  2029. /**
  2030. * Add a new geometry to this scene
  2031. * @param geometry defines the geometry to be added to the scene.
  2032. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2033. * @return a boolean defining if the geometry was added or not
  2034. */
  2035. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2036. /**
  2037. * Removes an existing geometry
  2038. * @param geometry defines the geometry to be removed from the scene
  2039. * @return a boolean defining if the geometry was removed or not
  2040. */
  2041. removeGeometry(geometry: Geometry): boolean;
  2042. /**
  2043. * Gets the list of geometries attached to the scene
  2044. * @returns an array of Geometry
  2045. */
  2046. getGeometries(): Geometry[];
  2047. /**
  2048. * Gets the first added mesh found of a given ID
  2049. * @param id defines the id to search for
  2050. * @return the mesh found or null if not found at all
  2051. */
  2052. getMeshByID(id: string): Nullable<AbstractMesh>;
  2053. /**
  2054. * Gets a list of meshes using their id
  2055. * @param id defines the id to search for
  2056. * @returns a list of meshes
  2057. */
  2058. getMeshesByID(id: string): Array<AbstractMesh>;
  2059. /**
  2060. * Gets the first added transform node found of a given ID
  2061. * @param id defines the id to search for
  2062. * @return the found transform node or null if not found at all.
  2063. */
  2064. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2065. /**
  2066. * Gets a list of transform nodes using their id
  2067. * @param id defines the id to search for
  2068. * @returns a list of transform nodes
  2069. */
  2070. getTransformNodesByID(id: string): Array<TransformNode>;
  2071. /**
  2072. * Gets a mesh with its auto-generated unique id
  2073. * @param uniqueId defines the unique id to search for
  2074. * @return the found mesh or null if not found at all.
  2075. */
  2076. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2077. /**
  2078. * Gets a the last added mesh using a given id
  2079. * @param id defines the id to search for
  2080. * @return the found mesh or null if not found at all.
  2081. */
  2082. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2083. /**
  2084. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2085. * @param id defines the id to search for
  2086. * @return the found node or null if not found at all
  2087. */
  2088. getLastEntryByID(id: string): Nullable<Node>;
  2089. /**
  2090. * Gets a node (Mesh, Camera, Light) using a given id
  2091. * @param id defines the id to search for
  2092. * @return the found node or null if not found at all
  2093. */
  2094. getNodeByID(id: string): Nullable<Node>;
  2095. /**
  2096. * Gets a node (Mesh, Camera, Light) using a given name
  2097. * @param name defines the name to search for
  2098. * @return the found node or null if not found at all.
  2099. */
  2100. getNodeByName(name: string): Nullable<Node>;
  2101. /**
  2102. * Gets a mesh using a given name
  2103. * @param name defines the name to search for
  2104. * @return the found mesh or null if not found at all.
  2105. */
  2106. getMeshByName(name: string): Nullable<AbstractMesh>;
  2107. /**
  2108. * Gets a transform node using a given name
  2109. * @param name defines the name to search for
  2110. * @return the found transform node or null if not found at all.
  2111. */
  2112. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2113. /**
  2114. * Gets a sound using a given name
  2115. * @param name defines the name to search for
  2116. * @return the found sound or null if not found at all.
  2117. */
  2118. getSoundByName(name: string): Nullable<Sound>;
  2119. /**
  2120. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2121. * @param id defines the id to search for
  2122. * @return the found skeleton or null if not found at all.
  2123. */
  2124. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2125. /**
  2126. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2127. * @param id defines the id to search for
  2128. * @return the found skeleton or null if not found at all.
  2129. */
  2130. getSkeletonById(id: string): Nullable<Skeleton>;
  2131. /**
  2132. * Gets a skeleton using a given name
  2133. * @param name defines the name to search for
  2134. * @return the found skeleton or null if not found at all.
  2135. */
  2136. getSkeletonByName(name: string): Nullable<Skeleton>;
  2137. /**
  2138. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2139. * @param id defines the id to search for
  2140. * @return the found morph target manager or null if not found at all.
  2141. */
  2142. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2143. /**
  2144. * Gets a boolean indicating if the given mesh is active
  2145. * @param mesh defines the mesh to look for
  2146. * @returns true if the mesh is in the active list
  2147. */
  2148. isActiveMesh(mesh: AbstractMesh): boolean;
  2149. /**
  2150. * Return a unique id as a string which can serve as an identifier for the scene
  2151. */
  2152. readonly uid: string;
  2153. /**
  2154. * Add an externaly attached data from its key.
  2155. * This method call will fail and return false, if such key already exists.
  2156. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2157. * @param key the unique key that identifies the data
  2158. * @param data the data object to associate to the key for this Engine instance
  2159. * @return true if no such key were already present and the data was added successfully, false otherwise
  2160. */
  2161. addExternalData<T>(key: string, data: T): boolean;
  2162. /**
  2163. * Get an externaly attached data from its key
  2164. * @param key the unique key that identifies the data
  2165. * @return the associated data, if present (can be null), or undefined if not present
  2166. */
  2167. getExternalData<T>(key: string): Nullable<T>;
  2168. /**
  2169. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2170. * @param key the unique key that identifies the data
  2171. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2172. * @return the associated data, can be null if the factory returned null.
  2173. */
  2174. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2175. /**
  2176. * Remove an externaly attached data from the Engine instance
  2177. * @param key the unique key that identifies the data
  2178. * @return true if the data was successfully removed, false if it doesn't exist
  2179. */
  2180. removeExternalData(key: string): boolean;
  2181. private _evaluateSubMesh;
  2182. /**
  2183. * Clear the processed materials smart array preventing retention point in material dispose.
  2184. */
  2185. freeProcessedMaterials(): void;
  2186. /**
  2187. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2188. */
  2189. freeActiveMeshes(): void;
  2190. /**
  2191. * Clear the info related to rendering groups preventing retention points during dispose.
  2192. */
  2193. freeRenderingGroups(): void;
  2194. /** @hidden */
  2195. _isInIntermediateRendering(): boolean;
  2196. /**
  2197. * Lambda returning the list of potentially active meshes.
  2198. */
  2199. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2200. /**
  2201. * Lambda returning the list of potentially active sub meshes.
  2202. */
  2203. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2204. /**
  2205. * Lambda returning the list of potentially intersecting sub meshes.
  2206. */
  2207. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2208. /**
  2209. * Lambda returning the list of potentially colliding sub meshes.
  2210. */
  2211. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2212. private _activeMeshesFrozen;
  2213. /**
  2214. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2215. * @returns the current scene
  2216. */
  2217. freezeActiveMeshes(): Scene;
  2218. /**
  2219. * Use this function to restart evaluating active meshes on every frame
  2220. * @returns the current scene
  2221. */
  2222. unfreezeActiveMeshes(): Scene;
  2223. private _evaluateActiveMeshes;
  2224. private _activeMesh;
  2225. /**
  2226. * Update the transform matrix to update from the current active camera
  2227. * @param force defines a boolean used to force the update even if cache is up to date
  2228. */
  2229. updateTransformMatrix(force?: boolean): void;
  2230. /**
  2231. * 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)
  2232. * @param alternateCamera defines the camera to use
  2233. */
  2234. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2235. /** @hidden */
  2236. _allowPostProcessClearColor: boolean;
  2237. private _renderForCamera;
  2238. private _processSubCameras;
  2239. private _checkIntersections;
  2240. /**
  2241. * Render the scene
  2242. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2243. */
  2244. render(updateCameras?: boolean): void;
  2245. private _updateAudioParameters;
  2246. /**
  2247. * Gets or sets if audio support is enabled
  2248. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2249. */
  2250. audioEnabled: boolean;
  2251. private _disableAudio;
  2252. private _enableAudio;
  2253. /**
  2254. * Gets or sets if audio will be output to headphones
  2255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2256. */
  2257. headphone: boolean;
  2258. private _switchAudioModeForHeadphones;
  2259. private _switchAudioModeForNormalSpeakers;
  2260. /**
  2261. * Freeze all materials
  2262. * A frozen material will not be updatable but should be faster to render
  2263. */
  2264. freezeMaterials(): void;
  2265. /**
  2266. * Unfreeze all materials
  2267. * A frozen material will not be updatable but should be faster to render
  2268. */
  2269. unfreezeMaterials(): void;
  2270. /**
  2271. * Releases all held ressources
  2272. */
  2273. dispose(): void;
  2274. /**
  2275. * Gets if the scene is already disposed
  2276. */
  2277. readonly isDisposed: boolean;
  2278. /**
  2279. * Releases sounds & soundtracks
  2280. */
  2281. disposeSounds(): void;
  2282. /**
  2283. * Call this function to reduce memory footprint of the scene.
  2284. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2285. */
  2286. clearCachedVertexData(): void;
  2287. /**
  2288. * This function will remove the local cached buffer data from texture.
  2289. * It will save memory but will prevent the texture from being rebuilt
  2290. */
  2291. cleanCachedTextureBuffer(): void;
  2292. /**
  2293. * Get the world extend vectors with an optional filter
  2294. *
  2295. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2296. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2297. */
  2298. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2299. min: Vector3;
  2300. max: Vector3;
  2301. };
  2302. /**
  2303. * Creates a ray that can be used to pick in the scene
  2304. * @param x defines the x coordinate of the origin (on-screen)
  2305. * @param y defines the y coordinate of the origin (on-screen)
  2306. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2307. * @param camera defines the camera to use for the picking
  2308. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2309. * @returns a Ray
  2310. */
  2311. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2312. /**
  2313. * Creates a ray that can be used to pick in the scene
  2314. * @param x defines the x coordinate of the origin (on-screen)
  2315. * @param y defines the y coordinate of the origin (on-screen)
  2316. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2317. * @param result defines the ray where to store the picking ray
  2318. * @param camera defines the camera to use for the picking
  2319. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2320. * @returns the current scene
  2321. */
  2322. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2323. /**
  2324. * Creates a ray that can be used to pick in the scene
  2325. * @param x defines the x coordinate of the origin (on-screen)
  2326. * @param y defines the y coordinate of the origin (on-screen)
  2327. * @param camera defines the camera to use for the picking
  2328. * @returns a Ray
  2329. */
  2330. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2331. /**
  2332. * Creates a ray that can be used to pick in the scene
  2333. * @param x defines the x coordinate of the origin (on-screen)
  2334. * @param y defines the y coordinate of the origin (on-screen)
  2335. * @param result defines the ray where to store the picking ray
  2336. * @param camera defines the camera to use for the picking
  2337. * @returns the current scene
  2338. */
  2339. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2340. private _internalPick;
  2341. private _internalMultiPick;
  2342. private _tempPickingRay;
  2343. /** Launch a ray to try to pick a mesh in the scene
  2344. * @param x position on screen
  2345. * @param y position on screen
  2346. * @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
  2347. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2348. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2349. * @returns a PickingInfo
  2350. */
  2351. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2352. private _cachedRayForTransform;
  2353. /** Use the given ray to pick a mesh in the scene
  2354. * @param ray The ray to use to pick meshes
  2355. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  2356. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2357. * @returns a PickingInfo
  2358. */
  2359. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2360. /**
  2361. * Launch a ray to try to pick a mesh in the scene
  2362. * @param x X position on screen
  2363. * @param y Y position on screen
  2364. * @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
  2365. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2366. * @returns an array of PickingInfo
  2367. */
  2368. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2369. /**
  2370. * Launch a ray to try to pick a mesh in the scene
  2371. * @param ray Ray to use
  2372. * @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
  2373. * @returns an array of PickingInfo
  2374. */
  2375. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2376. /**
  2377. * Force the value of meshUnderPointer
  2378. * @param mesh defines the mesh to use
  2379. */
  2380. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2381. /**
  2382. * Gets the mesh under the pointer
  2383. * @returns a Mesh or null if no mesh is under the pointer
  2384. */
  2385. getPointerOverMesh(): Nullable<AbstractMesh>;
  2386. /**
  2387. * Gets the current physics engine
  2388. * @returns a PhysicsEngine or null if none attached
  2389. */
  2390. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2391. /**
  2392. * Enables physics to the current scene
  2393. * @param gravity defines the scene's gravity for the physics engine
  2394. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2395. * @return a boolean indicating if the physics engine was initialized
  2396. */
  2397. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2398. /**
  2399. * Disables and disposes the physics engine associated with the scene
  2400. */
  2401. disablePhysicsEngine(): void;
  2402. /**
  2403. * Gets a boolean indicating if there is an active physics engine
  2404. * @returns a boolean indicating if there is an active physics engine
  2405. */
  2406. isPhysicsEnabled(): boolean;
  2407. /**
  2408. * Deletes a physics compound impostor
  2409. * @param compound defines the compound to delete
  2410. */
  2411. deleteCompoundImpostor(compound: any): void;
  2412. /** @hidden */
  2413. _rebuildGeometries(): void;
  2414. /** @hidden */
  2415. _rebuildTextures(): void;
  2416. private _getByTags;
  2417. /**
  2418. * Get a list of meshes by tags
  2419. * @param tagsQuery defines the tags query to use
  2420. * @param forEach defines a predicate used to filter results
  2421. * @returns an array of Mesh
  2422. */
  2423. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2424. /**
  2425. * Get a list of cameras by tags
  2426. * @param tagsQuery defines the tags query to use
  2427. * @param forEach defines a predicate used to filter results
  2428. * @returns an array of Camera
  2429. */
  2430. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2431. /**
  2432. * Get a list of lights by tags
  2433. * @param tagsQuery defines the tags query to use
  2434. * @param forEach defines a predicate used to filter results
  2435. * @returns an array of Light
  2436. */
  2437. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2438. /**
  2439. * Get a list of materials by tags
  2440. * @param tagsQuery defines the tags query to use
  2441. * @param forEach defines a predicate used to filter results
  2442. * @returns an array of Material
  2443. */
  2444. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2445. /**
  2446. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2447. * This allowed control for front to back rendering or reversly depending of the special needs.
  2448. *
  2449. * @param renderingGroupId The rendering group id corresponding to its index
  2450. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2451. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2452. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2453. */
  2454. 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;
  2455. /**
  2456. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2457. *
  2458. * @param renderingGroupId The rendering group id corresponding to its index
  2459. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2460. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2461. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2462. */
  2463. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2464. /**
  2465. * Gets the current auto clear configuration for one rendering group of the rendering
  2466. * manager.
  2467. * @param index the rendering group index to get the information for
  2468. * @returns The auto clear setup for the requested rendering group
  2469. */
  2470. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2471. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2472. blockMaterialDirtyMechanism: boolean;
  2473. /**
  2474. * Will flag all materials as dirty to trigger new shader compilation
  2475. * @param flag defines the flag used to specify which material part must be marked as dirty
  2476. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2477. */
  2478. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2479. /** @hidden */
  2480. _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;
  2481. /** @hidden */
  2482. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2483. }
  2484. }
  2485. declare module BABYLON {
  2486. /**
  2487. * Groups all the scene component constants in one place to ease maintenance.
  2488. * @hidden
  2489. */
  2490. class SceneComponentConstants {
  2491. static readonly NAME_EFFECTLAYER: string;
  2492. static readonly NAME_LAYER: string;
  2493. static readonly NAME_LENSFLARESYSTEM: string;
  2494. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2495. static readonly NAME_PARTICLESYSTEM: string;
  2496. static readonly NAME_GAMEPAD: string;
  2497. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2498. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2499. static readonly NAME_DEPTHRENDERER: string;
  2500. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2501. static readonly NAME_SPRITE: string;
  2502. static readonly NAME_OUTLINERENDERER: string;
  2503. static readonly NAME_PROCEDURALTEXTURE: string;
  2504. static readonly NAME_SHADOWGENERATOR: string;
  2505. static readonly NAME_OCTREE: string;
  2506. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2507. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2508. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2509. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2510. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2511. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2512. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2513. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2514. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2515. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2516. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2517. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2518. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2519. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2520. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2521. static readonly STEP_AFTERCAMERADRAW_BOUNDINGBOXRENDERER: number;
  2522. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2523. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2524. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2525. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2526. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2527. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2528. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2529. static readonly STEP_POINTERMOVE_SPRITE: number;
  2530. static readonly STEP_POINTERDOWN_SPRITE: number;
  2531. static readonly STEP_POINTERUP_SPRITE: number;
  2532. }
  2533. /**
  2534. * This represents a scene component.
  2535. *
  2536. * This is used to decouple the dependency the scene is having on the different workloads like
  2537. * layers, post processes...
  2538. */
  2539. interface ISceneComponent {
  2540. /**
  2541. * The name of the component. Each component must have a unique name.
  2542. */
  2543. name: string;
  2544. /**
  2545. * The scene the component belongs to.
  2546. */
  2547. scene: Scene;
  2548. /**
  2549. * Register the component to one instance of a scene.
  2550. */
  2551. register(): void;
  2552. /**
  2553. * Rebuilds the elements related to this component in case of
  2554. * context lost for instance.
  2555. */
  2556. rebuild(): void;
  2557. /**
  2558. * Disposes the component and the associated ressources.
  2559. */
  2560. dispose(): void;
  2561. }
  2562. /**
  2563. * This represents a SERIALIZABLE scene component.
  2564. *
  2565. * This extends Scene Component to add Serialization methods on top.
  2566. */
  2567. interface ISceneSerializableComponent extends ISceneComponent {
  2568. /**
  2569. * Adds all the element from the container to the scene
  2570. * @param container the container holding the elements
  2571. */
  2572. addFromContainer(container: AbstractScene): void;
  2573. /**
  2574. * Removes all the elements in the container from the scene
  2575. * @param container contains the elements to remove
  2576. */
  2577. removeFromContainer(container: AbstractScene): void;
  2578. /**
  2579. * Serializes the component data to the specified json object
  2580. * @param serializationObject The object to serialize to
  2581. */
  2582. serialize(serializationObject: any): void;
  2583. }
  2584. /**
  2585. * Strong typing of a Mesh related stage step action
  2586. */
  2587. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2588. /**
  2589. * Strong typing of a Evaluate Sub Mesh related stage step action
  2590. */
  2591. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2592. /**
  2593. * Strong typing of a Active Mesh related stage step action
  2594. */
  2595. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2596. /**
  2597. * Strong typing of a Camera related stage step action
  2598. */
  2599. type CameraStageAction = (camera: Camera) => void;
  2600. /**
  2601. * Strong typing of a RenderingGroup related stage step action
  2602. */
  2603. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2604. /**
  2605. * Strong typing of a Mesh Render related stage step action
  2606. */
  2607. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2608. /**
  2609. * Strong typing of a simple stage step action
  2610. */
  2611. type SimpleStageAction = () => void;
  2612. /**
  2613. * Strong typing of a render target action.
  2614. */
  2615. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2616. /**
  2617. * Strong typing of a pointer move action.
  2618. */
  2619. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2620. /**
  2621. * Strong typing of a pointer up/down action.
  2622. */
  2623. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2624. /**
  2625. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2626. * @hidden
  2627. */
  2628. class Stage<T extends Function> extends Array<{
  2629. index: number;
  2630. component: ISceneComponent;
  2631. action: T;
  2632. }> {
  2633. /**
  2634. * Hide ctor from the rest of the world.
  2635. * @param items The items to add.
  2636. */
  2637. private constructor();
  2638. /**
  2639. * Creates a new Stage.
  2640. * @returns A new instance of a Stage
  2641. */
  2642. static Create<T extends Function>(): Stage<T>;
  2643. /**
  2644. * Registers a step in an ordered way in the targeted stage.
  2645. * @param index Defines the position to register the step in
  2646. * @param component Defines the component attached to the step
  2647. * @param action Defines the action to launch during the step
  2648. */
  2649. registerStep(index: number, component: ISceneComponent, action: T): void;
  2650. /**
  2651. * Clears all the steps from the stage.
  2652. */
  2653. clear(): void;
  2654. }
  2655. }
  2656. declare module BABYLON {
  2657. type Nullable<T> = T | null;
  2658. type float = number;
  2659. type double = number;
  2660. type int = number;
  2661. type FloatArray = number[] | Float32Array;
  2662. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2663. /**
  2664. * Alias for types that can be used by a Buffer or VertexBuffer.
  2665. */
  2666. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2667. }
  2668. declare module BABYLON {
  2669. /**
  2670. * The action to be carried out following a trigger
  2671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2672. */
  2673. class Action {
  2674. /** the trigger, with or without parameters, for the action */
  2675. triggerOptions: any;
  2676. /**
  2677. * Trigger for the action
  2678. */
  2679. trigger: number;
  2680. /**
  2681. * Internal only - manager for action
  2682. * @hidden
  2683. */
  2684. _actionManager: ActionManager;
  2685. private _nextActiveAction;
  2686. private _child;
  2687. private _condition?;
  2688. private _triggerParameter;
  2689. /**
  2690. * An event triggered prior to action being executed.
  2691. */
  2692. onBeforeExecuteObservable: Observable<Action>;
  2693. /**
  2694. * Creates a new Action
  2695. * @param triggerOptions the trigger, with or without parameters, for the action
  2696. * @param condition an optional determinant of action
  2697. */
  2698. constructor(
  2699. /** the trigger, with or without parameters, for the action */
  2700. triggerOptions: any, condition?: Condition);
  2701. /**
  2702. * Internal only
  2703. * @hidden
  2704. */
  2705. _prepare(): void;
  2706. /**
  2707. * Gets the trigger parameters
  2708. * @returns the trigger parameters
  2709. */
  2710. getTriggerParameter(): any;
  2711. /**
  2712. * Internal only - executes current action event
  2713. * @hidden
  2714. */
  2715. _executeCurrent(evt?: ActionEvent): void;
  2716. /**
  2717. * Execute placeholder for child classes
  2718. * @param evt optional action event
  2719. */
  2720. execute(evt?: ActionEvent): void;
  2721. /**
  2722. * Skips to next active action
  2723. */
  2724. skipToNextActiveAction(): void;
  2725. /**
  2726. * Adds action to chain of actions, may be a DoNothingAction
  2727. * @param action defines the next action to execute
  2728. * @returns The action passed in
  2729. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2730. */
  2731. then(action: Action): Action;
  2732. /**
  2733. * Internal only
  2734. * @hidden
  2735. */
  2736. _getProperty(propertyPath: string): string;
  2737. /**
  2738. * Internal only
  2739. * @hidden
  2740. */
  2741. _getEffectiveTarget(target: any, propertyPath: string): any;
  2742. /**
  2743. * Serialize placeholder for child classes
  2744. * @param parent of child
  2745. * @returns the serialized object
  2746. */
  2747. serialize(parent: any): any;
  2748. /**
  2749. * Internal only called by serialize
  2750. * @hidden
  2751. */
  2752. protected _serialize(serializedAction: any, parent?: any): any;
  2753. /**
  2754. * Internal only
  2755. * @hidden
  2756. */
  2757. static _SerializeValueAsString: (value: any) => string;
  2758. /**
  2759. * Internal only
  2760. * @hidden
  2761. */
  2762. static _GetTargetProperty: (target: Scene | Node) => {
  2763. name: string;
  2764. targetType: string;
  2765. value: string;
  2766. };
  2767. }
  2768. }
  2769. declare module BABYLON {
  2770. /**
  2771. * ActionEvent is the event being sent when an action is triggered.
  2772. */
  2773. class ActionEvent {
  2774. /** The mesh or sprite that triggered the action */
  2775. source: any;
  2776. /** The X mouse cursor position at the time of the event */
  2777. pointerX: number;
  2778. /** The Y mouse cursor position at the time of the event */
  2779. pointerY: number;
  2780. /** The mesh that is currently pointed at (can be null) */
  2781. meshUnderPointer: Nullable<AbstractMesh>;
  2782. /** the original (browser) event that triggered the ActionEvent */
  2783. sourceEvent?: any;
  2784. /** additional data for the event */
  2785. additionalData?: any;
  2786. /**
  2787. * Creates a new ActionEvent
  2788. * @param source The mesh or sprite that triggered the action
  2789. * @param pointerX The X mouse cursor position at the time of the event
  2790. * @param pointerY The Y mouse cursor position at the time of the event
  2791. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2792. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2793. * @param additionalData additional data for the event
  2794. */
  2795. constructor(
  2796. /** The mesh or sprite that triggered the action */
  2797. source: any,
  2798. /** The X mouse cursor position at the time of the event */
  2799. pointerX: number,
  2800. /** The Y mouse cursor position at the time of the event */
  2801. pointerY: number,
  2802. /** The mesh that is currently pointed at (can be null) */
  2803. meshUnderPointer: Nullable<AbstractMesh>,
  2804. /** the original (browser) event that triggered the ActionEvent */
  2805. sourceEvent?: any,
  2806. /** additional data for the event */
  2807. additionalData?: any);
  2808. /**
  2809. * Helper function to auto-create an ActionEvent from a source mesh.
  2810. * @param source The source mesh that triggered the event
  2811. * @param evt The original (browser) event
  2812. * @param additionalData additional data for the event
  2813. * @returns the new ActionEvent
  2814. */
  2815. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2816. /**
  2817. * Helper function to auto-create an ActionEvent from a source sprite
  2818. * @param source The source sprite that triggered the event
  2819. * @param scene Scene associated with the sprite
  2820. * @param evt The original (browser) event
  2821. * @param additionalData additional data for the event
  2822. * @returns the new ActionEvent
  2823. */
  2824. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2825. /**
  2826. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2827. * @param scene the scene where the event occurred
  2828. * @param evt The original (browser) event
  2829. * @returns the new ActionEvent
  2830. */
  2831. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2832. /**
  2833. * Helper function to auto-create an ActionEvent from a primitive
  2834. * @param prim defines the target primitive
  2835. * @param pointerPos defines the pointer position
  2836. * @param evt The original (browser) event
  2837. * @param additionalData additional data for the event
  2838. * @returns the new ActionEvent
  2839. */
  2840. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2841. }
  2842. /**
  2843. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2844. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2846. */
  2847. class ActionManager {
  2848. private static _NothingTrigger;
  2849. private static _OnPickTrigger;
  2850. private static _OnLeftPickTrigger;
  2851. private static _OnRightPickTrigger;
  2852. private static _OnCenterPickTrigger;
  2853. private static _OnPickDownTrigger;
  2854. private static _OnDoublePickTrigger;
  2855. private static _OnPickUpTrigger;
  2856. private static _OnLongPressTrigger;
  2857. private static _OnPointerOverTrigger;
  2858. private static _OnPointerOutTrigger;
  2859. private static _OnEveryFrameTrigger;
  2860. private static _OnIntersectionEnterTrigger;
  2861. private static _OnIntersectionExitTrigger;
  2862. private static _OnKeyDownTrigger;
  2863. private static _OnKeyUpTrigger;
  2864. private static _OnPickOutTrigger;
  2865. /**
  2866. * Nothing
  2867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2868. */
  2869. static readonly NothingTrigger: number;
  2870. /**
  2871. * On pick
  2872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2873. */
  2874. static readonly OnPickTrigger: number;
  2875. /**
  2876. * On left pick
  2877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2878. */
  2879. static readonly OnLeftPickTrigger: number;
  2880. /**
  2881. * On right pick
  2882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2883. */
  2884. static readonly OnRightPickTrigger: number;
  2885. /**
  2886. * On center pick
  2887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2888. */
  2889. static readonly OnCenterPickTrigger: number;
  2890. /**
  2891. * On pick down
  2892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2893. */
  2894. static readonly OnPickDownTrigger: number;
  2895. /**
  2896. * On double pick
  2897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2898. */
  2899. static readonly OnDoublePickTrigger: number;
  2900. /**
  2901. * On pick up
  2902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2903. */
  2904. static readonly OnPickUpTrigger: number;
  2905. /**
  2906. * On pick out.
  2907. * This trigger will only be raised if you also declared a OnPickDown
  2908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2909. */
  2910. static readonly OnPickOutTrigger: number;
  2911. /**
  2912. * On long press
  2913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2914. */
  2915. static readonly OnLongPressTrigger: number;
  2916. /**
  2917. * On pointer over
  2918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2919. */
  2920. static readonly OnPointerOverTrigger: number;
  2921. /**
  2922. * On pointer out
  2923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2924. */
  2925. static readonly OnPointerOutTrigger: number;
  2926. /**
  2927. * On every frame
  2928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2929. */
  2930. static readonly OnEveryFrameTrigger: number;
  2931. /**
  2932. * On intersection enter
  2933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2934. */
  2935. static readonly OnIntersectionEnterTrigger: number;
  2936. /**
  2937. * On intersection exit
  2938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2939. */
  2940. static readonly OnIntersectionExitTrigger: number;
  2941. /**
  2942. * On key down
  2943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2944. */
  2945. static readonly OnKeyDownTrigger: number;
  2946. /**
  2947. * On key up
  2948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2949. */
  2950. static readonly OnKeyUpTrigger: number;
  2951. /** Gets the list of active triggers */
  2952. static Triggers: {
  2953. [key: string]: number;
  2954. };
  2955. /** Gets the list of actions */
  2956. actions: Action[];
  2957. /** Gets the cursor to use when hovering items */
  2958. hoverCursor: string;
  2959. private _scene;
  2960. /**
  2961. * Creates a new action manager
  2962. * @param scene defines the hosting scene
  2963. */
  2964. constructor(scene: Scene);
  2965. /**
  2966. * Releases all associated resources
  2967. */
  2968. dispose(): void;
  2969. /**
  2970. * Gets hosting scene
  2971. * @returns the hosting scene
  2972. */
  2973. getScene(): Scene;
  2974. /**
  2975. * Does this action manager handles actions of any of the given triggers
  2976. * @param triggers defines the triggers to be tested
  2977. * @return a boolean indicating whether one (or more) of the triggers is handled
  2978. */
  2979. hasSpecificTriggers(triggers: number[]): boolean;
  2980. /**
  2981. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  2982. * speed.
  2983. * @param triggerA defines the trigger to be tested
  2984. * @param triggerB defines the trigger to be tested
  2985. * @return a boolean indicating whether one (or more) of the triggers is handled
  2986. */
  2987. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  2988. /**
  2989. * Does this action manager handles actions of a given trigger
  2990. * @param trigger defines the trigger to be tested
  2991. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2992. * @return whether the trigger is handled
  2993. */
  2994. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2995. /**
  2996. * Does this action manager has pointer triggers
  2997. */
  2998. readonly hasPointerTriggers: boolean;
  2999. /**
  3000. * Does this action manager has pick triggers
  3001. */
  3002. readonly hasPickTriggers: boolean;
  3003. /**
  3004. * Does exist one action manager with at least one trigger
  3005. **/
  3006. static readonly HasTriggers: boolean;
  3007. /**
  3008. * Does exist one action manager with at least one pick trigger
  3009. **/
  3010. static readonly HasPickTriggers: boolean;
  3011. /**
  3012. * Does exist one action manager that handles actions of a given trigger
  3013. * @param trigger defines the trigger to be tested
  3014. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3015. **/
  3016. static HasSpecificTrigger(trigger: number): boolean;
  3017. /**
  3018. * Registers an action to this action manager
  3019. * @param action defines the action to be registered
  3020. * @return the action amended (prepared) after registration
  3021. */
  3022. registerAction(action: Action): Nullable<Action>;
  3023. /**
  3024. * Unregisters an action to this action manager
  3025. * @param action defines the action to be unregistered
  3026. * @return a boolean indicating whether the action has been unregistered
  3027. */
  3028. unregisterAction(action: Action): Boolean;
  3029. /**
  3030. * Process a specific trigger
  3031. * @param trigger defines the trigger to process
  3032. * @param evt defines the event details to be processed
  3033. */
  3034. processTrigger(trigger: number, evt?: ActionEvent): void;
  3035. /** @hidden */
  3036. _getEffectiveTarget(target: any, propertyPath: string): any;
  3037. /** @hidden */
  3038. _getProperty(propertyPath: string): string;
  3039. /**
  3040. * Serialize this manager to a JSON object
  3041. * @param name defines the property name to store this manager
  3042. * @returns a JSON representation of this manager
  3043. */
  3044. serialize(name: string): any;
  3045. /**
  3046. * Creates a new ActionManager from a JSON data
  3047. * @param parsedActions defines the JSON data to read from
  3048. * @param object defines the hosting mesh
  3049. * @param scene defines the hosting scene
  3050. */
  3051. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3052. /**
  3053. * Get a trigger name by index
  3054. * @param trigger defines the trigger index
  3055. * @returns a trigger name
  3056. */
  3057. static GetTriggerName(trigger: number): string;
  3058. }
  3059. }
  3060. declare module BABYLON {
  3061. /**
  3062. * A Condition applied to an Action
  3063. */
  3064. class Condition {
  3065. /**
  3066. * Internal only - manager for action
  3067. * @hidden
  3068. */
  3069. _actionManager: ActionManager;
  3070. /**
  3071. * Internal only
  3072. * @hidden
  3073. */
  3074. _evaluationId: number;
  3075. /**
  3076. * Internal only
  3077. * @hidden
  3078. */
  3079. _currentResult: boolean;
  3080. /**
  3081. * Creates a new Condition
  3082. * @param actionManager the manager of the action the condition is applied to
  3083. */
  3084. constructor(actionManager: ActionManager);
  3085. /**
  3086. * Check if the current condition is valid
  3087. * @returns a boolean
  3088. */
  3089. isValid(): boolean;
  3090. /**
  3091. * Internal only
  3092. * @hidden
  3093. */
  3094. _getProperty(propertyPath: string): string;
  3095. /**
  3096. * Internal only
  3097. * @hidden
  3098. */
  3099. _getEffectiveTarget(target: any, propertyPath: string): any;
  3100. /**
  3101. * Serialize placeholder for child classes
  3102. * @returns the serialized object
  3103. */
  3104. serialize(): any;
  3105. /**
  3106. * Internal only
  3107. * @hidden
  3108. */
  3109. protected _serialize(serializedCondition: any): any;
  3110. }
  3111. /**
  3112. * Defines specific conditional operators as extensions of Condition
  3113. */
  3114. class ValueCondition extends Condition {
  3115. /** path to specify the property of the target the conditional operator uses */
  3116. propertyPath: string;
  3117. /** the value compared by the conditional operator against the current value of the property */
  3118. value: any;
  3119. /** the conditional operator, default ValueCondition.IsEqual */
  3120. operator: number;
  3121. /**
  3122. * Internal only
  3123. * @hidden
  3124. */
  3125. private static _IsEqual;
  3126. /**
  3127. * Internal only
  3128. * @hidden
  3129. */
  3130. private static _IsDifferent;
  3131. /**
  3132. * Internal only
  3133. * @hidden
  3134. */
  3135. private static _IsGreater;
  3136. /**
  3137. * Internal only
  3138. * @hidden
  3139. */
  3140. private static _IsLesser;
  3141. /**
  3142. * returns the number for IsEqual
  3143. */
  3144. static readonly IsEqual: number;
  3145. /**
  3146. * Returns the number for IsDifferent
  3147. */
  3148. static readonly IsDifferent: number;
  3149. /**
  3150. * Returns the number for IsGreater
  3151. */
  3152. static readonly IsGreater: number;
  3153. /**
  3154. * Returns the number for IsLesser
  3155. */
  3156. static readonly IsLesser: number;
  3157. /**
  3158. * Internal only The action manager for the condition
  3159. * @hidden
  3160. */
  3161. _actionManager: ActionManager;
  3162. /**
  3163. * Internal only
  3164. * @hidden
  3165. */
  3166. private _target;
  3167. /**
  3168. * Internal only
  3169. * @hidden
  3170. */
  3171. private _effectiveTarget;
  3172. /**
  3173. * Internal only
  3174. * @hidden
  3175. */
  3176. private _property;
  3177. /**
  3178. * Creates a new ValueCondition
  3179. * @param actionManager manager for the action the condition applies to
  3180. * @param target for the action
  3181. * @param propertyPath path to specify the property of the target the conditional operator uses
  3182. * @param value the value compared by the conditional operator against the current value of the property
  3183. * @param operator the conditional operator, default ValueCondition.IsEqual
  3184. */
  3185. constructor(actionManager: ActionManager, target: any,
  3186. /** path to specify the property of the target the conditional operator uses */
  3187. propertyPath: string,
  3188. /** the value compared by the conditional operator against the current value of the property */
  3189. value: any,
  3190. /** the conditional operator, default ValueCondition.IsEqual */
  3191. operator?: number);
  3192. /**
  3193. * Compares the given value with the property value for the specified conditional operator
  3194. * @returns the result of the comparison
  3195. */
  3196. isValid(): boolean;
  3197. /**
  3198. * Serialize the ValueCondition into a JSON compatible object
  3199. * @returns serialization object
  3200. */
  3201. serialize(): any;
  3202. /**
  3203. * Gets the name of the conditional operator for the ValueCondition
  3204. * @param operator the conditional operator
  3205. * @returns the name
  3206. */
  3207. static GetOperatorName(operator: number): string;
  3208. }
  3209. /**
  3210. * Defines a predicate condition as an extension of Condition
  3211. */
  3212. class PredicateCondition extends Condition {
  3213. /** defines the predicate function used to validate the condition */
  3214. predicate: () => boolean;
  3215. /**
  3216. * Internal only - manager for action
  3217. * @hidden
  3218. */
  3219. _actionManager: ActionManager;
  3220. /**
  3221. * Creates a new PredicateCondition
  3222. * @param actionManager manager for the action the condition applies to
  3223. * @param predicate defines the predicate function used to validate the condition
  3224. */
  3225. constructor(actionManager: ActionManager,
  3226. /** defines the predicate function used to validate the condition */
  3227. predicate: () => boolean);
  3228. /**
  3229. * @returns the validity of the predicate condition
  3230. */
  3231. isValid(): boolean;
  3232. }
  3233. /**
  3234. * Defines a state condition as an extension of Condition
  3235. */
  3236. class StateCondition extends Condition {
  3237. value: string;
  3238. /**
  3239. * Internal only - manager for action
  3240. * @hidden
  3241. */
  3242. _actionManager: ActionManager;
  3243. /**
  3244. * Internal only
  3245. * @hidden
  3246. */
  3247. private _target;
  3248. /**
  3249. * Creates a new StateCondition
  3250. * @param actionManager manager for the action the condition applies to
  3251. * @param target of the condition
  3252. * @param value to compare with target state
  3253. */
  3254. constructor(actionManager: ActionManager, target: any, value: string);
  3255. /**
  3256. * @returns the validity of the state
  3257. */
  3258. isValid(): boolean;
  3259. /**
  3260. * Serialize the StateCondition into a JSON compatible object
  3261. * @returns serialization object
  3262. */
  3263. serialize(): any;
  3264. }
  3265. }
  3266. declare module BABYLON {
  3267. class SwitchBooleanAction extends Action {
  3268. propertyPath: string;
  3269. private _target;
  3270. private _effectiveTarget;
  3271. private _property;
  3272. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3273. /** @hidden */
  3274. _prepare(): void;
  3275. execute(): void;
  3276. serialize(parent: any): any;
  3277. }
  3278. class SetStateAction extends Action {
  3279. value: string;
  3280. private _target;
  3281. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3282. execute(): void;
  3283. serialize(parent: any): any;
  3284. }
  3285. class SetValueAction extends Action {
  3286. propertyPath: string;
  3287. value: any;
  3288. private _target;
  3289. private _effectiveTarget;
  3290. private _property;
  3291. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3292. /** @hidden */
  3293. _prepare(): void;
  3294. execute(): void;
  3295. serialize(parent: any): any;
  3296. }
  3297. class IncrementValueAction extends Action {
  3298. propertyPath: string;
  3299. value: any;
  3300. private _target;
  3301. private _effectiveTarget;
  3302. private _property;
  3303. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3304. /** @hidden */
  3305. _prepare(): void;
  3306. execute(): void;
  3307. serialize(parent: any): any;
  3308. }
  3309. class PlayAnimationAction extends Action {
  3310. from: number;
  3311. to: number;
  3312. loop?: boolean | undefined;
  3313. private _target;
  3314. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3315. /** @hidden */
  3316. _prepare(): void;
  3317. execute(): void;
  3318. serialize(parent: any): any;
  3319. }
  3320. class StopAnimationAction extends Action {
  3321. private _target;
  3322. constructor(triggerOptions: any, target: any, condition?: Condition);
  3323. /** @hidden */
  3324. _prepare(): void;
  3325. execute(): void;
  3326. serialize(parent: any): any;
  3327. }
  3328. class DoNothingAction extends Action {
  3329. constructor(triggerOptions?: any, condition?: Condition);
  3330. execute(): void;
  3331. serialize(parent: any): any;
  3332. }
  3333. class CombineAction extends Action {
  3334. children: Action[];
  3335. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3336. /** @hidden */
  3337. _prepare(): void;
  3338. execute(evt: ActionEvent): void;
  3339. serialize(parent: any): any;
  3340. }
  3341. class ExecuteCodeAction extends Action {
  3342. func: (evt: ActionEvent) => void;
  3343. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3344. execute(evt: ActionEvent): void;
  3345. }
  3346. class SetParentAction extends Action {
  3347. private _parent;
  3348. private _target;
  3349. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3350. /** @hidden */
  3351. _prepare(): void;
  3352. execute(): void;
  3353. serialize(parent: any): any;
  3354. }
  3355. class PlaySoundAction extends Action {
  3356. private _sound;
  3357. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3358. /** @hidden */
  3359. _prepare(): void;
  3360. execute(): void;
  3361. serialize(parent: any): any;
  3362. }
  3363. class StopSoundAction extends Action {
  3364. private _sound;
  3365. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3366. /** @hidden */
  3367. _prepare(): void;
  3368. execute(): void;
  3369. serialize(parent: any): any;
  3370. }
  3371. }
  3372. declare module BABYLON {
  3373. class InterpolateValueAction extends Action {
  3374. propertyPath: string;
  3375. value: any;
  3376. duration: number;
  3377. stopOtherAnimations?: boolean | undefined;
  3378. onInterpolationDone?: (() => void) | undefined;
  3379. private _target;
  3380. private _effectiveTarget;
  3381. private _property;
  3382. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3383. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3384. /** @hidden */
  3385. _prepare(): void;
  3386. execute(): void;
  3387. serialize(parent: any): any;
  3388. }
  3389. }
  3390. declare module BABYLON {
  3391. /**
  3392. * Class used to store an actual running animation
  3393. */
  3394. class Animatable {
  3395. /** defines the target object */
  3396. target: any;
  3397. /** defines the starting frame number (default is 0) */
  3398. fromFrame: number;
  3399. /** defines the ending frame number (default is 100) */
  3400. toFrame: number;
  3401. /** defines if the animation must loop (default is false) */
  3402. loopAnimation: boolean;
  3403. /** defines a callback to call when animation ends if it is not looping */
  3404. onAnimationEnd?: (() => void) | null | undefined;
  3405. private _localDelayOffset;
  3406. private _pausedDelay;
  3407. private _runtimeAnimations;
  3408. private _paused;
  3409. private _scene;
  3410. private _speedRatio;
  3411. private _weight;
  3412. private _syncRoot;
  3413. /**
  3414. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3415. * This will only apply for non looping animation (default is true)
  3416. */
  3417. disposeOnEnd: boolean;
  3418. /**
  3419. * Gets a boolean indicating if the animation has started
  3420. */
  3421. animationStarted: boolean;
  3422. /**
  3423. * Observer raised when the animation ends
  3424. */
  3425. onAnimationEndObservable: Observable<Animatable>;
  3426. /**
  3427. * Gets the root Animatable used to synchronize and normalize animations
  3428. */
  3429. readonly syncRoot: Animatable;
  3430. /**
  3431. * Gets the current frame of the first RuntimeAnimation
  3432. * Used to synchronize Animatables
  3433. */
  3434. readonly masterFrame: number;
  3435. /**
  3436. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3437. */
  3438. weight: number;
  3439. /**
  3440. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3441. */
  3442. speedRatio: number;
  3443. /**
  3444. * Creates a new Animatable
  3445. * @param scene defines the hosting scene
  3446. * @param target defines the target object
  3447. * @param fromFrame defines the starting frame number (default is 0)
  3448. * @param toFrame defines the ending frame number (default is 100)
  3449. * @param loopAnimation defines if the animation must loop (default is false)
  3450. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3451. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3452. * @param animations defines a group of animation to add to the new Animatable
  3453. */
  3454. constructor(scene: Scene,
  3455. /** defines the target object */
  3456. target: any,
  3457. /** defines the starting frame number (default is 0) */
  3458. fromFrame?: number,
  3459. /** defines the ending frame number (default is 100) */
  3460. toFrame?: number,
  3461. /** defines if the animation must loop (default is false) */
  3462. loopAnimation?: boolean, speedRatio?: number,
  3463. /** defines a callback to call when animation ends if it is not looping */
  3464. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3465. /**
  3466. * Synchronize and normalize current Animatable with a source Animatable
  3467. * This is useful when using animation weights and when animations are not of the same length
  3468. * @param root defines the root Animatable to synchronize with
  3469. * @returns the current Animatable
  3470. */
  3471. syncWith(root: Animatable): Animatable;
  3472. /**
  3473. * Gets the list of runtime animations
  3474. * @returns an array of RuntimeAnimation
  3475. */
  3476. getAnimations(): RuntimeAnimation[];
  3477. /**
  3478. * Adds more animations to the current animatable
  3479. * @param target defines the target of the animations
  3480. * @param animations defines the new animations to add
  3481. */
  3482. appendAnimations(target: any, animations: Animation[]): void;
  3483. /**
  3484. * Gets the source animation for a specific property
  3485. * @param property defines the propertyu to look for
  3486. * @returns null or the source animation for the given property
  3487. */
  3488. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3489. /**
  3490. * Gets the runtime animation for a specific property
  3491. * @param property defines the propertyu to look for
  3492. * @returns null or the runtime animation for the given property
  3493. */
  3494. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3495. /**
  3496. * Resets the animatable to its original state
  3497. */
  3498. reset(): void;
  3499. /**
  3500. * Allows the animatable to blend with current running animations
  3501. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3502. * @param blendingSpeed defines the blending speed to use
  3503. */
  3504. enableBlending(blendingSpeed: number): void;
  3505. /**
  3506. * Disable animation blending
  3507. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3508. */
  3509. disableBlending(): void;
  3510. /**
  3511. * Jump directly to a given frame
  3512. * @param frame defines the frame to jump to
  3513. */
  3514. goToFrame(frame: number): void;
  3515. /**
  3516. * Pause the animation
  3517. */
  3518. pause(): void;
  3519. /**
  3520. * Restart the animation
  3521. */
  3522. restart(): void;
  3523. private _raiseOnAnimationEnd;
  3524. /**
  3525. * Stop and delete the current animation
  3526. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3527. * @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)
  3528. */
  3529. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3530. /**
  3531. * Wait asynchronously for the animation to end
  3532. * @returns a promise which will be fullfilled when the animation ends
  3533. */
  3534. waitAsync(): Promise<Animatable>;
  3535. /** @hidden */
  3536. _animate(delay: number): boolean;
  3537. }
  3538. }
  3539. declare module BABYLON {
  3540. /**
  3541. * Represents the range of an animation
  3542. */
  3543. class AnimationRange {
  3544. /**The name of the animation range**/
  3545. name: string;
  3546. /**The starting frame of the animation */
  3547. from: number;
  3548. /**The ending frame of the animation*/
  3549. to: number;
  3550. /**
  3551. * Initializes the range of an animation
  3552. * @param name The name of the animation range
  3553. * @param from The starting frame of the animation
  3554. * @param to The ending frame of the animation
  3555. */
  3556. constructor(
  3557. /**The name of the animation range**/
  3558. name: string,
  3559. /**The starting frame of the animation */
  3560. from: number,
  3561. /**The ending frame of the animation*/
  3562. to: number);
  3563. /**
  3564. * Makes a copy of the animation range
  3565. * @returns A copy of the animation range
  3566. */
  3567. clone(): AnimationRange;
  3568. }
  3569. /**
  3570. * Composed of a frame, and an action function
  3571. */
  3572. class AnimationEvent {
  3573. /** The frame for which the event is triggered **/
  3574. frame: number;
  3575. /** The event to perform when triggered **/
  3576. action: (currentFrame: number) => void;
  3577. /** Specifies if the event should be triggered only once**/
  3578. onlyOnce?: boolean | undefined;
  3579. /**
  3580. * Specifies if the animation event is done
  3581. */
  3582. isDone: boolean;
  3583. /**
  3584. * Initializes the animation event
  3585. * @param frame The frame for which the event is triggered
  3586. * @param action The event to perform when triggered
  3587. * @param onlyOnce Specifies if the event should be triggered only once
  3588. */
  3589. constructor(
  3590. /** The frame for which the event is triggered **/
  3591. frame: number,
  3592. /** The event to perform when triggered **/
  3593. action: (currentFrame: number) => void,
  3594. /** Specifies if the event should be triggered only once**/
  3595. onlyOnce?: boolean | undefined);
  3596. /** @hidden */
  3597. _clone(): AnimationEvent;
  3598. }
  3599. /**
  3600. * A cursor which tracks a point on a path
  3601. */
  3602. class PathCursor {
  3603. private path;
  3604. /**
  3605. * Stores path cursor callbacks for when an onchange event is triggered
  3606. */
  3607. private _onchange;
  3608. /**
  3609. * The value of the path cursor
  3610. */
  3611. value: number;
  3612. /**
  3613. * The animation array of the path cursor
  3614. */
  3615. animations: Animation[];
  3616. /**
  3617. * Initializes the path cursor
  3618. * @param path The path to track
  3619. */
  3620. constructor(path: Path2);
  3621. /**
  3622. * Gets the cursor point on the path
  3623. * @returns A point on the path cursor at the cursor location
  3624. */
  3625. getPoint(): Vector3;
  3626. /**
  3627. * Moves the cursor ahead by the step amount
  3628. * @param step The amount to move the cursor forward
  3629. * @returns This path cursor
  3630. */
  3631. moveAhead(step?: number): PathCursor;
  3632. /**
  3633. * Moves the cursor behind by the step amount
  3634. * @param step The amount to move the cursor back
  3635. * @returns This path cursor
  3636. */
  3637. moveBack(step?: number): PathCursor;
  3638. /**
  3639. * Moves the cursor by the step amount
  3640. * If the step amount is greater than one, an exception is thrown
  3641. * @param step The amount to move the cursor
  3642. * @returns This path cursor
  3643. */
  3644. move(step: number): PathCursor;
  3645. /**
  3646. * Ensures that the value is limited between zero and one
  3647. * @returns This path cursor
  3648. */
  3649. private ensureLimits;
  3650. /**
  3651. * Runs onchange callbacks on change (used by the animation engine)
  3652. * @returns This path cursor
  3653. */
  3654. private raiseOnChange;
  3655. /**
  3656. * Executes a function on change
  3657. * @param f A path cursor onchange callback
  3658. * @returns This path cursor
  3659. */
  3660. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3661. }
  3662. /**
  3663. * Defines an interface which represents an animation key frame
  3664. */
  3665. interface IAnimationKey {
  3666. /**
  3667. * Frame of the key frame
  3668. */
  3669. frame: number;
  3670. /**
  3671. * Value at the specifies key frame
  3672. */
  3673. value: any;
  3674. /**
  3675. * The input tangent for the cubic hermite spline
  3676. */
  3677. inTangent?: any;
  3678. /**
  3679. * The output tangent for the cubic hermite spline
  3680. */
  3681. outTangent?: any;
  3682. /**
  3683. * The animation interpolation type
  3684. */
  3685. interpolation?: AnimationKeyInterpolation;
  3686. }
  3687. /**
  3688. * Enum for the animation key frame interpolation type
  3689. */
  3690. enum AnimationKeyInterpolation {
  3691. /**
  3692. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3693. */
  3694. STEP = 1
  3695. }
  3696. /**
  3697. * Class used to store any kind of animation
  3698. */
  3699. class Animation {
  3700. /**Name of the animation */
  3701. name: string;
  3702. /**Property to animate */
  3703. targetProperty: string;
  3704. /**The frames per second of the animation */
  3705. framePerSecond: number;
  3706. /**The data type of the animation */
  3707. dataType: number;
  3708. /**The loop mode of the animation */
  3709. loopMode?: number | undefined;
  3710. /**Specifies if blending should be enabled */
  3711. enableBlending?: boolean | undefined;
  3712. /**
  3713. * Use matrix interpolation instead of using direct key value when animating matrices
  3714. */
  3715. static AllowMatricesInterpolation: boolean;
  3716. /**
  3717. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3718. */
  3719. static AllowMatrixDecomposeForInterpolation: boolean;
  3720. /**
  3721. * Stores the key frames of the animation
  3722. */
  3723. private _keys;
  3724. /**
  3725. * Stores the easing function of the animation
  3726. */
  3727. private _easingFunction;
  3728. /**
  3729. * @hidden Internal use only
  3730. */
  3731. _runtimeAnimations: RuntimeAnimation[];
  3732. /**
  3733. * The set of event that will be linked to this animation
  3734. */
  3735. private _events;
  3736. /**
  3737. * Stores an array of target property paths
  3738. */
  3739. targetPropertyPath: string[];
  3740. /**
  3741. * Stores the blending speed of the animation
  3742. */
  3743. blendingSpeed: number;
  3744. /**
  3745. * Stores the animation ranges for the animation
  3746. */
  3747. private _ranges;
  3748. /**
  3749. * @hidden Internal use
  3750. */
  3751. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3752. /**
  3753. * Sets up an animation
  3754. * @param property The property to animate
  3755. * @param animationType The animation type to apply
  3756. * @param framePerSecond The frames per second of the animation
  3757. * @param easingFunction The easing function used in the animation
  3758. * @returns The created animation
  3759. */
  3760. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3761. /**
  3762. * Create and start an animation on a node
  3763. * @param name defines the name of the global animation that will be run on all nodes
  3764. * @param node defines the root node where the animation will take place
  3765. * @param targetProperty defines property to animate
  3766. * @param framePerSecond defines the number of frame per second yo use
  3767. * @param totalFrame defines the number of frames in total
  3768. * @param from defines the initial value
  3769. * @param to defines the final value
  3770. * @param loopMode defines which loop mode you want to use (off by default)
  3771. * @param easingFunction defines the easing function to use (linear by default)
  3772. * @param onAnimationEnd defines the callback to call when animation end
  3773. * @returns the animatable created for this animation
  3774. */
  3775. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3776. /**
  3777. * Create and start an animation on a node and its descendants
  3778. * @param name defines the name of the global animation that will be run on all nodes
  3779. * @param node defines the root node where the animation will take place
  3780. * @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
  3781. * @param targetProperty defines property to animate
  3782. * @param framePerSecond defines the number of frame per second to use
  3783. * @param totalFrame defines the number of frames in total
  3784. * @param from defines the initial value
  3785. * @param to defines the final value
  3786. * @param loopMode defines which loop mode you want to use (off by default)
  3787. * @param easingFunction defines the easing function to use (linear by default)
  3788. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3789. * @returns the list of animatables created for all nodes
  3790. * @example https://www.babylonjs-playground.com/#MH0VLI
  3791. */
  3792. 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[]>;
  3793. /**
  3794. * Creates a new animation, merges it with the existing animations and starts it
  3795. * @param name Name of the animation
  3796. * @param node Node which contains the scene that begins the animations
  3797. * @param targetProperty Specifies which property to animate
  3798. * @param framePerSecond The frames per second of the animation
  3799. * @param totalFrame The total number of frames
  3800. * @param from The frame at the beginning of the animation
  3801. * @param to The frame at the end of the animation
  3802. * @param loopMode Specifies the loop mode of the animation
  3803. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3804. * @param onAnimationEnd Callback to run once the animation is complete
  3805. * @returns Nullable animation
  3806. */
  3807. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3808. /**
  3809. * Transition property of an host to the target Value
  3810. * @param property The property to transition
  3811. * @param targetValue The target Value of the property
  3812. * @param host The object where the property to animate belongs
  3813. * @param scene Scene used to run the animation
  3814. * @param frameRate Framerate (in frame/s) to use
  3815. * @param transition The transition type we want to use
  3816. * @param duration The duration of the animation, in milliseconds
  3817. * @param onAnimationEnd Callback trigger at the end of the animation
  3818. * @returns Nullable animation
  3819. */
  3820. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3821. /**
  3822. * Return the array of runtime animations currently using this animation
  3823. */
  3824. readonly runtimeAnimations: RuntimeAnimation[];
  3825. /**
  3826. * Specifies if any of the runtime animations are currently running
  3827. */
  3828. readonly hasRunningRuntimeAnimations: boolean;
  3829. /**
  3830. * Initializes the animation
  3831. * @param name Name of the animation
  3832. * @param targetProperty Property to animate
  3833. * @param framePerSecond The frames per second of the animation
  3834. * @param dataType The data type of the animation
  3835. * @param loopMode The loop mode of the animation
  3836. * @param enableBlendings Specifies if blending should be enabled
  3837. */
  3838. constructor(
  3839. /**Name of the animation */
  3840. name: string,
  3841. /**Property to animate */
  3842. targetProperty: string,
  3843. /**The frames per second of the animation */
  3844. framePerSecond: number,
  3845. /**The data type of the animation */
  3846. dataType: number,
  3847. /**The loop mode of the animation */
  3848. loopMode?: number | undefined,
  3849. /**Specifies if blending should be enabled */
  3850. enableBlending?: boolean | undefined);
  3851. /**
  3852. * Converts the animation to a string
  3853. * @param fullDetails support for multiple levels of logging within scene loading
  3854. * @returns String form of the animation
  3855. */
  3856. toString(fullDetails?: boolean): string;
  3857. /**
  3858. * Add an event to this animation
  3859. * @param event Event to add
  3860. */
  3861. addEvent(event: AnimationEvent): void;
  3862. /**
  3863. * Remove all events found at the given frame
  3864. * @param frame The frame to remove events from
  3865. */
  3866. removeEvents(frame: number): void;
  3867. /**
  3868. * Retrieves all the events from the animation
  3869. * @returns Events from the animation
  3870. */
  3871. getEvents(): AnimationEvent[];
  3872. /**
  3873. * Creates an animation range
  3874. * @param name Name of the animation range
  3875. * @param from Starting frame of the animation range
  3876. * @param to Ending frame of the animation
  3877. */
  3878. createRange(name: string, from: number, to: number): void;
  3879. /**
  3880. * Deletes an animation range by name
  3881. * @param name Name of the animation range to delete
  3882. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3883. */
  3884. deleteRange(name: string, deleteFrames?: boolean): void;
  3885. /**
  3886. * Gets the animation range by name, or null if not defined
  3887. * @param name Name of the animation range
  3888. * @returns Nullable animation range
  3889. */
  3890. getRange(name: string): Nullable<AnimationRange>;
  3891. /**
  3892. * Gets the key frames from the animation
  3893. * @returns The key frames of the animation
  3894. */
  3895. getKeys(): Array<IAnimationKey>;
  3896. /**
  3897. * Gets the highest frame rate of the animation
  3898. * @returns Highest frame rate of the animation
  3899. */
  3900. getHighestFrame(): number;
  3901. /**
  3902. * Gets the easing function of the animation
  3903. * @returns Easing function of the animation
  3904. */
  3905. getEasingFunction(): IEasingFunction;
  3906. /**
  3907. * Sets the easing function of the animation
  3908. * @param easingFunction A custom mathematical formula for animation
  3909. */
  3910. setEasingFunction(easingFunction: EasingFunction): void;
  3911. /**
  3912. * Interpolates a scalar linearly
  3913. * @param startValue Start value of the animation curve
  3914. * @param endValue End value of the animation curve
  3915. * @param gradient Scalar amount to interpolate
  3916. * @returns Interpolated scalar value
  3917. */
  3918. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3919. /**
  3920. * Interpolates a scalar cubically
  3921. * @param startValue Start value of the animation curve
  3922. * @param outTangent End tangent of the animation
  3923. * @param endValue End value of the animation curve
  3924. * @param inTangent Start tangent of the animation curve
  3925. * @param gradient Scalar amount to interpolate
  3926. * @returns Interpolated scalar value
  3927. */
  3928. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3929. /**
  3930. * Interpolates a quaternion using a spherical linear interpolation
  3931. * @param startValue Start value of the animation curve
  3932. * @param endValue End value of the animation curve
  3933. * @param gradient Scalar amount to interpolate
  3934. * @returns Interpolated quaternion value
  3935. */
  3936. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3937. /**
  3938. * Interpolates a quaternion cubically
  3939. * @param startValue Start value of the animation curve
  3940. * @param outTangent End tangent of the animation curve
  3941. * @param endValue End value of the animation curve
  3942. * @param inTangent Start tangent of the animation curve
  3943. * @param gradient Scalar amount to interpolate
  3944. * @returns Interpolated quaternion value
  3945. */
  3946. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3947. /**
  3948. * Interpolates a Vector3 linearl
  3949. * @param startValue Start value of the animation curve
  3950. * @param endValue End value of the animation curve
  3951. * @param gradient Scalar amount to interpolate
  3952. * @returns Interpolated scalar value
  3953. */
  3954. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3955. /**
  3956. * Interpolates a Vector3 cubically
  3957. * @param startValue Start value of the animation curve
  3958. * @param outTangent End tangent of the animation
  3959. * @param endValue End value of the animation curve
  3960. * @param inTangent Start tangent of the animation curve
  3961. * @param gradient Scalar amount to interpolate
  3962. * @returns InterpolatedVector3 value
  3963. */
  3964. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3965. /**
  3966. * Interpolates a Vector2 linearly
  3967. * @param startValue Start value of the animation curve
  3968. * @param endValue End value of the animation curve
  3969. * @param gradient Scalar amount to interpolate
  3970. * @returns Interpolated Vector2 value
  3971. */
  3972. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  3973. /**
  3974. * Interpolates a Vector2 cubically
  3975. * @param startValue Start value of the animation curve
  3976. * @param outTangent End tangent of the animation
  3977. * @param endValue End value of the animation curve
  3978. * @param inTangent Start tangent of the animation curve
  3979. * @param gradient Scalar amount to interpolate
  3980. * @returns Interpolated Vector2 value
  3981. */
  3982. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  3983. /**
  3984. * Interpolates a size linearly
  3985. * @param startValue Start value of the animation curve
  3986. * @param endValue End value of the animation curve
  3987. * @param gradient Scalar amount to interpolate
  3988. * @returns Interpolated Size value
  3989. */
  3990. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  3991. /**
  3992. * Interpolates a Color3 linearly
  3993. * @param startValue Start value of the animation curve
  3994. * @param endValue End value of the animation curve
  3995. * @param gradient Scalar amount to interpolate
  3996. * @returns Interpolated Color3 value
  3997. */
  3998. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  3999. /**
  4000. * @hidden Internal use only
  4001. */
  4002. _getKeyValue(value: any): any;
  4003. /**
  4004. * @hidden Internal use only
  4005. */
  4006. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4007. /**
  4008. * Defines the function to use to interpolate matrices
  4009. * @param startValue defines the start matrix
  4010. * @param endValue defines the end matrix
  4011. * @param gradient defines the gradient between both matrices
  4012. * @param result defines an optional target matrix where to store the interpolation
  4013. * @returns the interpolated matrix
  4014. */
  4015. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4016. /**
  4017. * Makes a copy of the animation
  4018. * @returns Cloned animation
  4019. */
  4020. clone(): Animation;
  4021. /**
  4022. * Sets the key frames of the animation
  4023. * @param values The animation key frames to set
  4024. */
  4025. setKeys(values: Array<IAnimationKey>): void;
  4026. /**
  4027. * Serializes the animation to an object
  4028. * @returns Serialized object
  4029. */
  4030. serialize(): any;
  4031. /**
  4032. * Float animation type
  4033. */
  4034. private static _ANIMATIONTYPE_FLOAT;
  4035. /**
  4036. * Vector3 animation type
  4037. */
  4038. private static _ANIMATIONTYPE_VECTOR3;
  4039. /**
  4040. * Quaternion animation type
  4041. */
  4042. private static _ANIMATIONTYPE_QUATERNION;
  4043. /**
  4044. * Matrix animation type
  4045. */
  4046. private static _ANIMATIONTYPE_MATRIX;
  4047. /**
  4048. * Color3 animation type
  4049. */
  4050. private static _ANIMATIONTYPE_COLOR3;
  4051. /**
  4052. * Vector2 animation type
  4053. */
  4054. private static _ANIMATIONTYPE_VECTOR2;
  4055. /**
  4056. * Size animation type
  4057. */
  4058. private static _ANIMATIONTYPE_SIZE;
  4059. /**
  4060. * Relative Loop Mode
  4061. */
  4062. private static _ANIMATIONLOOPMODE_RELATIVE;
  4063. /**
  4064. * Cycle Loop Mode
  4065. */
  4066. private static _ANIMATIONLOOPMODE_CYCLE;
  4067. /**
  4068. * Constant Loop Mode
  4069. */
  4070. private static _ANIMATIONLOOPMODE_CONSTANT;
  4071. /**
  4072. * Get the float animation type
  4073. */
  4074. static readonly ANIMATIONTYPE_FLOAT: number;
  4075. /**
  4076. * Get the Vector3 animation type
  4077. */
  4078. static readonly ANIMATIONTYPE_VECTOR3: number;
  4079. /**
  4080. * Get the Vector2 animation type
  4081. */
  4082. static readonly ANIMATIONTYPE_VECTOR2: number;
  4083. /**
  4084. * Get the Size animation type
  4085. */
  4086. static readonly ANIMATIONTYPE_SIZE: number;
  4087. /**
  4088. * Get the Quaternion animation type
  4089. */
  4090. static readonly ANIMATIONTYPE_QUATERNION: number;
  4091. /**
  4092. * Get the Matrix animation type
  4093. */
  4094. static readonly ANIMATIONTYPE_MATRIX: number;
  4095. /**
  4096. * Get the Color3 animation type
  4097. */
  4098. static readonly ANIMATIONTYPE_COLOR3: number;
  4099. /**
  4100. * Get the Relative Loop Mode
  4101. */
  4102. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4103. /**
  4104. * Get the Cycle Loop Mode
  4105. */
  4106. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4107. /**
  4108. * Get the Constant Loop Mode
  4109. */
  4110. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4111. /** @hidden */
  4112. static _UniversalLerp(left: any, right: any, amount: number): any;
  4113. /**
  4114. * Parses an animation object and creates an animation
  4115. * @param parsedAnimation Parsed animation object
  4116. * @returns Animation object
  4117. */
  4118. static Parse(parsedAnimation: any): Animation;
  4119. /**
  4120. * Appends the serialized animations from the source animations
  4121. * @param source Source containing the animations
  4122. * @param destination Target to store the animations
  4123. */
  4124. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4125. }
  4126. }
  4127. declare module BABYLON {
  4128. /**
  4129. * This class defines the direct association between an animation and a target
  4130. */
  4131. class TargetedAnimation {
  4132. animation: Animation;
  4133. target: any;
  4134. }
  4135. /**
  4136. * Use this class to create coordinated animations on multiple targets
  4137. */
  4138. class AnimationGroup implements IDisposable {
  4139. name: string;
  4140. private _scene;
  4141. private _targetedAnimations;
  4142. private _animatables;
  4143. private _from;
  4144. private _to;
  4145. private _isStarted;
  4146. private _speedRatio;
  4147. onAnimationEndObservable: Observable<TargetedAnimation>;
  4148. /**
  4149. * This observable will notify when all animations have ended.
  4150. */
  4151. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4152. /**
  4153. * This observable will notify when all animations have paused.
  4154. */
  4155. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4156. /**
  4157. * Gets the first frame
  4158. */
  4159. readonly from: number;
  4160. /**
  4161. * Gets the last frame
  4162. */
  4163. readonly to: number;
  4164. /**
  4165. * Define if the animations are started
  4166. */
  4167. readonly isStarted: boolean;
  4168. /**
  4169. * Gets or sets the speed ratio to use for all animations
  4170. */
  4171. /**
  4172. * Gets or sets the speed ratio to use for all animations
  4173. */
  4174. speedRatio: number;
  4175. /**
  4176. * Gets the targeted animations for this animation group
  4177. */
  4178. readonly targetedAnimations: Array<TargetedAnimation>;
  4179. /**
  4180. * returning the list of animatables controlled by this animation group.
  4181. */
  4182. readonly animatables: Array<Animatable>;
  4183. constructor(name: string, scene?: Nullable<Scene>);
  4184. /**
  4185. * Add an animation (with its target) in the group
  4186. * @param animation defines the animation we want to add
  4187. * @param target defines the target of the animation
  4188. * @returns the {BABYLON.TargetedAnimation} object
  4189. */
  4190. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4191. /**
  4192. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4193. * It can add constant keys at begin or end
  4194. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4195. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4196. */
  4197. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4198. /**
  4199. * Start all animations on given targets
  4200. * @param loop defines if animations must loop
  4201. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4202. * @param from defines the from key (optional)
  4203. * @param to defines the to key (optional)
  4204. * @returns the current animation group
  4205. */
  4206. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4207. /**
  4208. * Pause all animations
  4209. */
  4210. pause(): AnimationGroup;
  4211. /**
  4212. * Play all animations to initial state
  4213. * This function will start() the animations if they were not started or will restart() them if they were paused
  4214. * @param loop defines if animations must loop
  4215. */
  4216. play(loop?: boolean): AnimationGroup;
  4217. /**
  4218. * Reset all animations to initial state
  4219. */
  4220. reset(): AnimationGroup;
  4221. /**
  4222. * Restart animations from key 0
  4223. */
  4224. restart(): AnimationGroup;
  4225. /**
  4226. * Stop all animations
  4227. */
  4228. stop(): AnimationGroup;
  4229. /**
  4230. * Set animation weight for all animatables
  4231. * @param weight defines the weight to use
  4232. * @return the animationGroup
  4233. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4234. */
  4235. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4236. /**
  4237. * Synchronize and normalize all animatables with a source animatable
  4238. * @param root defines the root animatable to synchronize with
  4239. * @return the animationGroup
  4240. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4241. */
  4242. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4243. /**
  4244. * Goes to a specific frame in this animation group
  4245. * @param frame the frame number to go to
  4246. * @return the animationGroup
  4247. */
  4248. goToFrame(frame: number): AnimationGroup;
  4249. /**
  4250. * Dispose all associated resources
  4251. */
  4252. dispose(): void;
  4253. private _checkAnimationGroupEnded;
  4254. /**
  4255. * Returns a new AnimationGroup object parsed from the source provided.
  4256. * @param parsedAnimationGroup defines the source
  4257. * @param scene defines the scene that will receive the animationGroup
  4258. * @returns a new AnimationGroup
  4259. */
  4260. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4261. /**
  4262. * Returns the string "AnimationGroup"
  4263. * @returns "AnimationGroup"
  4264. */
  4265. getClassName(): string;
  4266. /**
  4267. * Creates a detailled string about the object
  4268. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4269. * @returns a string representing the object
  4270. */
  4271. toString(fullDetails?: boolean): string;
  4272. }
  4273. }
  4274. declare module BABYLON {
  4275. /**
  4276. * Class used to override all child animations of a given target
  4277. */
  4278. class AnimationPropertiesOverride {
  4279. /**
  4280. * Gets or sets a value indicating if animation blending must be used
  4281. */
  4282. enableBlending: boolean;
  4283. /**
  4284. * Gets or sets the blending speed to use when enableBlending is true
  4285. */
  4286. blendingSpeed: number;
  4287. /**
  4288. * Gets or sets the default loop mode to use
  4289. */
  4290. loopMode: number;
  4291. }
  4292. }
  4293. declare module BABYLON {
  4294. interface IEasingFunction {
  4295. ease(gradient: number): number;
  4296. }
  4297. class EasingFunction implements IEasingFunction {
  4298. private static _EASINGMODE_EASEIN;
  4299. private static _EASINGMODE_EASEOUT;
  4300. private static _EASINGMODE_EASEINOUT;
  4301. static readonly EASINGMODE_EASEIN: number;
  4302. static readonly EASINGMODE_EASEOUT: number;
  4303. static readonly EASINGMODE_EASEINOUT: number;
  4304. private _easingMode;
  4305. setEasingMode(easingMode: number): void;
  4306. getEasingMode(): number;
  4307. easeInCore(gradient: number): number;
  4308. ease(gradient: number): number;
  4309. }
  4310. class CircleEase extends EasingFunction implements IEasingFunction {
  4311. easeInCore(gradient: number): number;
  4312. }
  4313. class BackEase extends EasingFunction implements IEasingFunction {
  4314. amplitude: number;
  4315. constructor(amplitude?: number);
  4316. easeInCore(gradient: number): number;
  4317. }
  4318. class BounceEase extends EasingFunction implements IEasingFunction {
  4319. bounces: number;
  4320. bounciness: number;
  4321. constructor(bounces?: number, bounciness?: number);
  4322. easeInCore(gradient: number): number;
  4323. }
  4324. class CubicEase extends EasingFunction implements IEasingFunction {
  4325. easeInCore(gradient: number): number;
  4326. }
  4327. class ElasticEase extends EasingFunction implements IEasingFunction {
  4328. oscillations: number;
  4329. springiness: number;
  4330. constructor(oscillations?: number, springiness?: number);
  4331. easeInCore(gradient: number): number;
  4332. }
  4333. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4334. exponent: number;
  4335. constructor(exponent?: number);
  4336. easeInCore(gradient: number): number;
  4337. }
  4338. class PowerEase extends EasingFunction implements IEasingFunction {
  4339. power: number;
  4340. constructor(power?: number);
  4341. easeInCore(gradient: number): number;
  4342. }
  4343. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4344. easeInCore(gradient: number): number;
  4345. }
  4346. class QuarticEase extends EasingFunction implements IEasingFunction {
  4347. easeInCore(gradient: number): number;
  4348. }
  4349. class QuinticEase extends EasingFunction implements IEasingFunction {
  4350. easeInCore(gradient: number): number;
  4351. }
  4352. class SineEase extends EasingFunction implements IEasingFunction {
  4353. easeInCore(gradient: number): number;
  4354. }
  4355. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4356. x1: number;
  4357. y1: number;
  4358. x2: number;
  4359. y2: number;
  4360. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4361. easeInCore(gradient: number): number;
  4362. }
  4363. }
  4364. declare module BABYLON {
  4365. /**
  4366. * Defines a runtime animation
  4367. */
  4368. class RuntimeAnimation {
  4369. private _events;
  4370. /**
  4371. * The current frame of the runtime animation
  4372. */
  4373. private _currentFrame;
  4374. /**
  4375. * The animation used by the runtime animation
  4376. */
  4377. private _animation;
  4378. /**
  4379. * The target of the runtime animation
  4380. */
  4381. private _target;
  4382. /**
  4383. * The initiating animatable
  4384. */
  4385. private _host;
  4386. /**
  4387. * The original value of the runtime animation
  4388. */
  4389. private _originalValue;
  4390. /**
  4391. * The original blend value of the runtime animation
  4392. */
  4393. private _originalBlendValue;
  4394. /**
  4395. * The offsets cache of the runtime animation
  4396. */
  4397. private _offsetsCache;
  4398. /**
  4399. * The high limits cache of the runtime animation
  4400. */
  4401. private _highLimitsCache;
  4402. /**
  4403. * Specifies if the runtime animation has been stopped
  4404. */
  4405. private _stopped;
  4406. /**
  4407. * The blending factor of the runtime animation
  4408. */
  4409. private _blendingFactor;
  4410. /**
  4411. * The BabylonJS scene
  4412. */
  4413. private _scene;
  4414. /**
  4415. * The current value of the runtime animation
  4416. */
  4417. private _currentValue;
  4418. /** @hidden */
  4419. _workValue: any;
  4420. /**
  4421. * The active target of the runtime animation
  4422. */
  4423. private _activeTarget;
  4424. /**
  4425. * The target path of the runtime animation
  4426. */
  4427. private _targetPath;
  4428. /**
  4429. * The weight of the runtime animation
  4430. */
  4431. private _weight;
  4432. /**
  4433. * The ratio offset of the runtime animation
  4434. */
  4435. private _ratioOffset;
  4436. /**
  4437. * The previous delay of the runtime animation
  4438. */
  4439. private _previousDelay;
  4440. /**
  4441. * The previous ratio of the runtime animation
  4442. */
  4443. private _previousRatio;
  4444. /**
  4445. * Gets the current frame of the runtime animation
  4446. */
  4447. readonly currentFrame: number;
  4448. /**
  4449. * Gets the weight of the runtime animation
  4450. */
  4451. readonly weight: number;
  4452. /**
  4453. * Gets the current value of the runtime animation
  4454. */
  4455. readonly currentValue: any;
  4456. /**
  4457. * Gets the target path of the runtime animation
  4458. */
  4459. readonly targetPath: string;
  4460. /**
  4461. * Gets the actual target of the runtime animation
  4462. */
  4463. readonly target: any;
  4464. /**
  4465. * Create a new RuntimeAnimation object
  4466. * @param target defines the target of the animation
  4467. * @param animation defines the source animation object
  4468. * @param scene defines the hosting scene
  4469. * @param host defines the initiating Animatable
  4470. */
  4471. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4472. /**
  4473. * Gets the animation from the runtime animation
  4474. */
  4475. readonly animation: Animation;
  4476. /**
  4477. * Resets the runtime animation to the beginning
  4478. * @param restoreOriginal defines whether to restore the target property to the original value
  4479. */
  4480. reset(restoreOriginal?: boolean): void;
  4481. /**
  4482. * Specifies if the runtime animation is stopped
  4483. * @returns Boolean specifying if the runtime animation is stopped
  4484. */
  4485. isStopped(): boolean;
  4486. /**
  4487. * Disposes of the runtime animation
  4488. */
  4489. dispose(): void;
  4490. /**
  4491. * Interpolates the animation from the current frame
  4492. * @param currentFrame The frame to interpolate the animation to
  4493. * @param repeatCount The number of times that the animation should loop
  4494. * @param loopMode The type of looping mode to use
  4495. * @param offsetValue Animation offset value
  4496. * @param highLimitValue The high limit value
  4497. * @returns The interpolated value
  4498. */
  4499. private _interpolate;
  4500. /**
  4501. * Apply the interpolated value to the target
  4502. * @param currentValue defines the value computed by the animation
  4503. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4504. */
  4505. setValue(currentValue: any, weight?: number): void;
  4506. private _setValue;
  4507. /**
  4508. * Gets the loop pmode of the runtime animation
  4509. * @returns Loop Mode
  4510. */
  4511. private _getCorrectLoopMode;
  4512. /**
  4513. * Move the current animation to a given frame
  4514. * @param frame defines the frame to move to
  4515. */
  4516. goToFrame(frame: number): void;
  4517. /**
  4518. * @hidden Internal use only
  4519. */
  4520. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4521. /**
  4522. * Execute the current animation
  4523. * @param delay defines the delay to add to the current frame
  4524. * @param from defines the lower bound of the animation range
  4525. * @param to defines the upper bound of the animation range
  4526. * @param loop defines if the current animation must loop
  4527. * @param speedRatio defines the current speed ratio
  4528. * @param weight defines the weight of the animation (default is -1 so no weight)
  4529. * @returns a boolean indicating if the animation is running
  4530. */
  4531. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4532. }
  4533. }
  4534. declare module BABYLON {
  4535. /**
  4536. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4538. */
  4539. class Analyser {
  4540. /**
  4541. * Gets or sets the smoothing
  4542. * @ignorenaming
  4543. */
  4544. SMOOTHING: number;
  4545. /**
  4546. * Gets or sets the FFT table size
  4547. * @ignorenaming
  4548. */
  4549. FFT_SIZE: number;
  4550. /**
  4551. * Gets or sets the bar graph amplitude
  4552. * @ignorenaming
  4553. */
  4554. BARGRAPHAMPLITUDE: number;
  4555. /**
  4556. * Gets or sets the position of the debug canvas
  4557. * @ignorenaming
  4558. */
  4559. DEBUGCANVASPOS: {
  4560. x: number;
  4561. y: number;
  4562. };
  4563. /**
  4564. * Gets or sets the debug canvas size
  4565. * @ignorenaming
  4566. */
  4567. DEBUGCANVASSIZE: {
  4568. width: number;
  4569. height: number;
  4570. };
  4571. private _byteFreqs;
  4572. private _byteTime;
  4573. private _floatFreqs;
  4574. private _webAudioAnalyser;
  4575. private _debugCanvas;
  4576. private _debugCanvasContext;
  4577. private _scene;
  4578. private _registerFunc;
  4579. private _audioEngine;
  4580. /**
  4581. * Creates a new analyser
  4582. * @param scene defines hosting scene
  4583. */
  4584. constructor(scene: Scene);
  4585. /**
  4586. * Get the number of data values you will have to play with for the visualization
  4587. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4588. * @returns a number
  4589. */
  4590. getFrequencyBinCount(): number;
  4591. /**
  4592. * Gets the current frequency data as a byte array
  4593. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4594. * @returns a Uint8Array
  4595. */
  4596. getByteFrequencyData(): Uint8Array;
  4597. /**
  4598. * Gets the current waveform as a byte array
  4599. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4600. * @returns a Uint8Array
  4601. */
  4602. getByteTimeDomainData(): Uint8Array;
  4603. /**
  4604. * Gets the current frequency data as a float array
  4605. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4606. * @returns a Float32Array
  4607. */
  4608. getFloatFrequencyData(): Float32Array;
  4609. /**
  4610. * Renders the debug canvas
  4611. */
  4612. drawDebugCanvas(): void;
  4613. /**
  4614. * Stops rendering the debug canvas and removes it
  4615. */
  4616. stopDebugCanvas(): void;
  4617. /**
  4618. * Connects two audio nodes
  4619. * @param inputAudioNode defines first node to connect
  4620. * @param outputAudioNode defines second node to connect
  4621. */
  4622. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4623. /**
  4624. * Releases all associated resources
  4625. */
  4626. dispose(): void;
  4627. }
  4628. }
  4629. declare module BABYLON {
  4630. class AudioEngine {
  4631. private _audioContext;
  4632. private _audioContextInitialized;
  4633. canUseWebAudio: boolean;
  4634. masterGain: GainNode;
  4635. private _connectedAnalyser;
  4636. WarnedWebAudioUnsupported: boolean;
  4637. unlocked: boolean;
  4638. onAudioUnlocked: () => any;
  4639. isMP3supported: boolean;
  4640. isOGGsupported: boolean;
  4641. readonly audioContext: Nullable<AudioContext>;
  4642. constructor();
  4643. private _unlockiOSaudio;
  4644. private _initializeAudioContext;
  4645. dispose(): void;
  4646. getGlobalVolume(): number;
  4647. setGlobalVolume(newVolume: number): void;
  4648. connectToAnalyser(analyser: Analyser): void;
  4649. }
  4650. }
  4651. declare module BABYLON {
  4652. class Sound {
  4653. name: string;
  4654. autoplay: boolean;
  4655. loop: boolean;
  4656. useCustomAttenuation: boolean;
  4657. soundTrackId: number;
  4658. spatialSound: boolean;
  4659. refDistance: number;
  4660. rolloffFactor: number;
  4661. maxDistance: number;
  4662. distanceModel: string;
  4663. private _panningModel;
  4664. onended: () => any;
  4665. /**
  4666. * Observable event when the current playing sound finishes.
  4667. */
  4668. onEndedObservable: Observable<Sound>;
  4669. private _playbackRate;
  4670. private _streaming;
  4671. private _startTime;
  4672. private _startOffset;
  4673. private _position;
  4674. /** @hidden */
  4675. _positionInEmitterSpace: boolean;
  4676. private _localDirection;
  4677. private _volume;
  4678. private _isReadyToPlay;
  4679. isPlaying: boolean;
  4680. isPaused: boolean;
  4681. private _isDirectional;
  4682. private _readyToPlayCallback;
  4683. private _audioBuffer;
  4684. private _soundSource;
  4685. private _streamingSource;
  4686. private _soundPanner;
  4687. private _soundGain;
  4688. private _inputAudioNode;
  4689. private _outputAudioNode;
  4690. private _coneInnerAngle;
  4691. private _coneOuterAngle;
  4692. private _coneOuterGain;
  4693. private _scene;
  4694. private _connectedMesh;
  4695. private _customAttenuationFunction;
  4696. private _registerFunc;
  4697. private _isOutputConnected;
  4698. private _htmlAudioElement;
  4699. private _urlType;
  4700. /**
  4701. * Create a sound and attach it to a scene
  4702. * @param name Name of your sound
  4703. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  4704. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4705. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4706. */
  4707. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4708. dispose(): void;
  4709. isReady(): boolean;
  4710. private _soundLoaded;
  4711. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4712. updateOptions(options: any): void;
  4713. private _createSpatialParameters;
  4714. private _updateSpatialParameters;
  4715. switchPanningModelToHRTF(): void;
  4716. switchPanningModelToEqualPower(): void;
  4717. private _switchPanningModel;
  4718. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4719. /**
  4720. * Transform this sound into a directional source
  4721. * @param coneInnerAngle Size of the inner cone in degree
  4722. * @param coneOuterAngle Size of the outer cone in degree
  4723. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4724. */
  4725. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4726. /**
  4727. * Gets or sets the inner angle for the directional cone.
  4728. */
  4729. /**
  4730. * Gets or sets the inner angle for the directional cone.
  4731. */
  4732. directionalConeInnerAngle: number;
  4733. /**
  4734. * Gets or sets the outer angle for the directional cone.
  4735. */
  4736. /**
  4737. * Gets or sets the outer angle for the directional cone.
  4738. */
  4739. directionalConeOuterAngle: number;
  4740. setPosition(newPosition: Vector3): void;
  4741. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4742. private _updateDirection;
  4743. updateDistanceFromListener(): void;
  4744. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4745. /**
  4746. * Play the sound
  4747. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4748. * @param offset (optional) Start the sound setting it at a specific time
  4749. */
  4750. play(time?: number, offset?: number): void;
  4751. private _onended;
  4752. /**
  4753. * Stop the sound
  4754. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4755. */
  4756. stop(time?: number): void;
  4757. pause(): void;
  4758. setVolume(newVolume: number, time?: number): void;
  4759. setPlaybackRate(newPlaybackRate: number): void;
  4760. getVolume(): number;
  4761. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4762. detachFromMesh(): void;
  4763. private _onRegisterAfterWorldMatrixUpdate;
  4764. clone(): Nullable<Sound>;
  4765. getAudioBuffer(): AudioBuffer | null;
  4766. serialize(): any;
  4767. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4768. }
  4769. }
  4770. declare module BABYLON {
  4771. class SoundTrack {
  4772. private _outputAudioNode;
  4773. private _scene;
  4774. id: number;
  4775. soundCollection: Array<Sound>;
  4776. private _isMainTrack;
  4777. private _connectedAnalyser;
  4778. private _options;
  4779. private _isInitialized;
  4780. constructor(scene: Scene, options?: any);
  4781. private _initializeSoundTrackAudioGraph;
  4782. dispose(): void;
  4783. AddSound(sound: Sound): void;
  4784. RemoveSound(sound: Sound): void;
  4785. setVolume(newVolume: number): void;
  4786. switchPanningModelToHRTF(): void;
  4787. switchPanningModelToEqualPower(): void;
  4788. connectToAnalyser(analyser: Analyser): void;
  4789. }
  4790. }
  4791. declare module BABYLON {
  4792. /**
  4793. * Wraps one or more Sound objects and selects one with random weight for playback.
  4794. */
  4795. class WeightedSound {
  4796. /** When true a Sound will be selected and played when the current playing Sound completes. */
  4797. loop: boolean;
  4798. private _coneInnerAngle;
  4799. private _coneOuterAngle;
  4800. private _volume;
  4801. /** A Sound is currently playing. */
  4802. isPlaying: boolean;
  4803. /** A Sound is currently paused. */
  4804. isPaused: boolean;
  4805. private _sounds;
  4806. private _weights;
  4807. private _currentIndex?;
  4808. /**
  4809. * Creates a new WeightedSound from the list of sounds given.
  4810. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  4811. * @param sounds Array of Sounds that will be selected from.
  4812. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  4813. */
  4814. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  4815. /**
  4816. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  4817. */
  4818. /**
  4819. * The size of cone in degress for a directional sound in which there will be no attenuation.
  4820. */
  4821. directionalConeInnerAngle: number;
  4822. /**
  4823. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4824. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4825. */
  4826. /**
  4827. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4828. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4829. */
  4830. directionalConeOuterAngle: number;
  4831. /**
  4832. * Playback volume.
  4833. */
  4834. /**
  4835. * Playback volume.
  4836. */
  4837. volume: number;
  4838. private _onended;
  4839. /**
  4840. * Suspend playback
  4841. */
  4842. pause(): void;
  4843. /**
  4844. * Stop playback
  4845. */
  4846. stop(): void;
  4847. /**
  4848. * Start playback.
  4849. * @param startOffset Position the clip head at a specific time in seconds.
  4850. */
  4851. play(startOffset?: number): void;
  4852. }
  4853. }
  4854. declare module BABYLON {
  4855. /**
  4856. * Class used to store bone information
  4857. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4858. */
  4859. class Bone extends Node {
  4860. /**
  4861. * defines the bone name
  4862. */
  4863. name: string;
  4864. private static _tmpVecs;
  4865. private static _tmpQuat;
  4866. private static _tmpMats;
  4867. /**
  4868. * Gets the list of child bones
  4869. */
  4870. children: Bone[];
  4871. /** Gets the animations associated with this bone */
  4872. animations: Animation[];
  4873. /**
  4874. * Gets or sets bone length
  4875. */
  4876. length: number;
  4877. /**
  4878. * @hidden Internal only
  4879. * Set this value to map this bone to a different index in the transform matrices
  4880. * Set this value to -1 to exclude the bone from the transform matrices
  4881. */
  4882. _index: Nullable<number>;
  4883. private _skeleton;
  4884. private _localMatrix;
  4885. private _restPose;
  4886. private _baseMatrix;
  4887. private _absoluteTransform;
  4888. private _invertedAbsoluteTransform;
  4889. private _parent;
  4890. private _scalingDeterminant;
  4891. private _worldTransform;
  4892. private _localScaling;
  4893. private _localRotation;
  4894. private _localPosition;
  4895. private _needToDecompose;
  4896. private _needToCompose;
  4897. /** @hidden */
  4898. /** @hidden */
  4899. _matrix: Matrix;
  4900. /**
  4901. * Create a new bone
  4902. * @param name defines the bone name
  4903. * @param skeleton defines the parent skeleton
  4904. * @param parentBone defines the parent (can be null if the bone is the root)
  4905. * @param localMatrix defines the local matrix
  4906. * @param restPose defines the rest pose matrix
  4907. * @param baseMatrix defines the base matrix
  4908. * @param index defines index of the bone in the hiearchy
  4909. */
  4910. constructor(
  4911. /**
  4912. * defines the bone name
  4913. */
  4914. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4915. /**
  4916. * Gets the parent skeleton
  4917. * @returns a skeleton
  4918. */
  4919. getSkeleton(): Skeleton;
  4920. /**
  4921. * Gets parent bone
  4922. * @returns a bone or null if the bone is the root of the bone hierarchy
  4923. */
  4924. getParent(): Nullable<Bone>;
  4925. /**
  4926. * Sets the parent bone
  4927. * @param parent defines the parent (can be null if the bone is the root)
  4928. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4929. */
  4930. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4931. /**
  4932. * Gets the local matrix
  4933. * @returns a matrix
  4934. */
  4935. getLocalMatrix(): Matrix;
  4936. /**
  4937. * Gets the base matrix (initial matrix which remains unchanged)
  4938. * @returns a matrix
  4939. */
  4940. getBaseMatrix(): Matrix;
  4941. /**
  4942. * Gets the rest pose matrix
  4943. * @returns a matrix
  4944. */
  4945. getRestPose(): Matrix;
  4946. /**
  4947. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  4948. */
  4949. getWorldMatrix(): Matrix;
  4950. /**
  4951. * Sets the local matrix to rest pose matrix
  4952. */
  4953. returnToRest(): void;
  4954. /**
  4955. * Gets the inverse of the absolute transform matrix.
  4956. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  4957. * @returns a matrix
  4958. */
  4959. getInvertedAbsoluteTransform(): Matrix;
  4960. /**
  4961. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  4962. * @returns a matrix
  4963. */
  4964. getAbsoluteTransform(): Matrix;
  4965. /** Gets or sets current position (in local space) */
  4966. position: Vector3;
  4967. /** Gets or sets current rotation (in local space) */
  4968. rotation: Vector3;
  4969. /** Gets or sets current rotation quaternion (in local space) */
  4970. rotationQuaternion: Quaternion;
  4971. /** Gets or sets current scaling (in local space) */
  4972. scaling: Vector3;
  4973. /**
  4974. * Gets the animation properties override
  4975. */
  4976. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  4977. private _decompose;
  4978. private _compose;
  4979. /**
  4980. * Update the base and local matrices
  4981. * @param matrix defines the new base or local matrix
  4982. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4983. * @param updateLocalMatrix defines if the local matrix should be updated
  4984. */
  4985. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  4986. /** @hidden */
  4987. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  4988. /**
  4989. * Flag the bone as dirty (Forcing it to update everything)
  4990. */
  4991. markAsDirty(): void;
  4992. private _markAsDirtyAndCompose;
  4993. private _markAsDirtyAndDecompose;
  4994. /**
  4995. * Copy an animation range from another bone
  4996. * @param source defines the source bone
  4997. * @param rangeName defines the range name to copy
  4998. * @param frameOffset defines the frame offset
  4999. * @param rescaleAsRequired defines if rescaling must be applied if required
  5000. * @param skelDimensionsRatio defines the scaling ratio
  5001. * @returns true if operation was successful
  5002. */
  5003. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  5004. /**
  5005. * Translate the bone in local or world space
  5006. * @param vec The amount to translate the bone
  5007. * @param space The space that the translation is in
  5008. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5009. */
  5010. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5011. /**
  5012. * Set the postion of the bone in local or world space
  5013. * @param position The position to set the bone
  5014. * @param space The space that the position is in
  5015. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5016. */
  5017. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5018. /**
  5019. * Set the absolute position of the bone (world space)
  5020. * @param position The position to set the bone
  5021. * @param mesh The mesh that this bone is attached to
  5022. */
  5023. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  5024. /**
  5025. * Scale the bone on the x, y and z axes (in local space)
  5026. * @param x The amount to scale the bone on the x axis
  5027. * @param y The amount to scale the bone on the y axis
  5028. * @param z The amount to scale the bone on the z axis
  5029. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  5030. */
  5031. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  5032. /**
  5033. * Set the bone scaling in local space
  5034. * @param scale defines the scaling vector
  5035. */
  5036. setScale(scale: Vector3): void;
  5037. /**
  5038. * Gets the current scaling in local space
  5039. * @returns the current scaling vector
  5040. */
  5041. getScale(): Vector3;
  5042. /**
  5043. * Gets the current scaling in local space and stores it in a target vector
  5044. * @param result defines the target vector
  5045. */
  5046. getScaleToRef(result: Vector3): void;
  5047. /**
  5048. * Set the yaw, pitch, and roll of the bone in local or world space
  5049. * @param yaw The rotation of the bone on the y axis
  5050. * @param pitch The rotation of the bone on the x axis
  5051. * @param roll The rotation of the bone on the z axis
  5052. * @param space The space that the axes of rotation are in
  5053. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5054. */
  5055. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  5056. /**
  5057. * Add a rotation to the bone on an axis in local or world space
  5058. * @param axis The axis to rotate the bone on
  5059. * @param amount The amount to rotate the bone
  5060. * @param space The space that the axis is in
  5061. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5062. */
  5063. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  5064. /**
  5065. * Set the rotation of the bone to a particular axis angle in local or world space
  5066. * @param axis The axis to rotate the bone on
  5067. * @param angle The angle that the bone should be rotated to
  5068. * @param space The space that the axis is in
  5069. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5070. */
  5071. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  5072. /**
  5073. * Set the euler rotation of the bone in local of world space
  5074. * @param rotation The euler rotation that the bone should be set to
  5075. * @param space The space that the rotation is in
  5076. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5077. */
  5078. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5079. /**
  5080. * Set the quaternion rotation of the bone in local of world space
  5081. * @param quat The quaternion rotation that the bone should be set to
  5082. * @param space The space that the rotation is in
  5083. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5084. */
  5085. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  5086. /**
  5087. * Set the rotation matrix of the bone in local of world space
  5088. * @param rotMat The rotation matrix that the bone should be set to
  5089. * @param space The space that the rotation is in
  5090. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5091. */
  5092. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  5093. private _rotateWithMatrix;
  5094. private _getNegativeRotationToRef;
  5095. /**
  5096. * Get the position of the bone in local or world space
  5097. * @param space The space that the returned position is in
  5098. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5099. * @returns The position of the bone
  5100. */
  5101. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5102. /**
  5103. * Copy the position of the bone to a vector3 in local or world space
  5104. * @param space The space that the returned position is in
  5105. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5106. * @param result The vector3 to copy the position to
  5107. */
  5108. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  5109. /**
  5110. * Get the absolute position of the bone (world space)
  5111. * @param mesh The mesh that this bone is attached to
  5112. * @returns The absolute position of the bone
  5113. */
  5114. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  5115. /**
  5116. * Copy the absolute position of the bone (world space) to the result param
  5117. * @param mesh The mesh that this bone is attached to
  5118. * @param result The vector3 to copy the absolute position to
  5119. */
  5120. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  5121. /**
  5122. * Compute the absolute transforms of this bone and its children
  5123. */
  5124. computeAbsoluteTransforms(): void;
  5125. /**
  5126. * Get the world direction from an axis that is in the local space of the bone
  5127. * @param localAxis The local direction that is used to compute the world direction
  5128. * @param mesh The mesh that this bone is attached to
  5129. * @returns The world direction
  5130. */
  5131. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5132. /**
  5133. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  5134. * @param localAxis The local direction that is used to compute the world direction
  5135. * @param mesh The mesh that this bone is attached to
  5136. * @param result The vector3 that the world direction will be copied to
  5137. */
  5138. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5139. /**
  5140. * Get the euler rotation of the bone in local or world space
  5141. * @param space The space that the rotation should be in
  5142. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5143. * @returns The euler rotation
  5144. */
  5145. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5146. /**
  5147. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  5148. * @param space The space that the rotation should be in
  5149. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5150. * @param result The vector3 that the rotation should be copied to
  5151. */
  5152. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5153. /**
  5154. * Get the quaternion rotation of the bone in either local or world space
  5155. * @param space The space that the rotation should be in
  5156. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5157. * @returns The quaternion rotation
  5158. */
  5159. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  5160. /**
  5161. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  5162. * @param space The space that the rotation should be in
  5163. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5164. * @param result The quaternion that the rotation should be copied to
  5165. */
  5166. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  5167. /**
  5168. * Get the rotation matrix of the bone in local or world space
  5169. * @param space The space that the rotation should be in
  5170. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5171. * @returns The rotation matrix
  5172. */
  5173. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  5174. /**
  5175. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  5176. * @param space The space that the rotation should be in
  5177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5178. * @param result The quaternion that the rotation should be copied to
  5179. */
  5180. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  5181. /**
  5182. * Get the world position of a point that is in the local space of the bone
  5183. * @param position The local position
  5184. * @param mesh The mesh that this bone is attached to
  5185. * @returns The world position
  5186. */
  5187. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5188. /**
  5189. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  5190. * @param position The local position
  5191. * @param mesh The mesh that this bone is attached to
  5192. * @param result The vector3 that the world position should be copied to
  5193. */
  5194. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5195. /**
  5196. * Get the local position of a point that is in world space
  5197. * @param position The world position
  5198. * @param mesh The mesh that this bone is attached to
  5199. * @returns The local position
  5200. */
  5201. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5202. /**
  5203. * Get the local position of a point that is in world space and copy it to the result param
  5204. * @param position The world position
  5205. * @param mesh The mesh that this bone is attached to
  5206. * @param result The vector3 that the local position should be copied to
  5207. */
  5208. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5209. }
  5210. }
  5211. declare module BABYLON {
  5212. /**
  5213. * Class used to apply inverse kinematics to bones
  5214. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  5215. */
  5216. class BoneIKController {
  5217. private static _tmpVecs;
  5218. private static _tmpQuat;
  5219. private static _tmpMats;
  5220. /**
  5221. * Gets or sets the target mesh
  5222. */
  5223. targetMesh: AbstractMesh;
  5224. /** Gets or sets the mesh used as pole */
  5225. poleTargetMesh: AbstractMesh;
  5226. /**
  5227. * Gets or sets the bone used as pole
  5228. */
  5229. poleTargetBone: Nullable<Bone>;
  5230. /**
  5231. * Gets or sets the target position
  5232. */
  5233. targetPosition: Vector3;
  5234. /**
  5235. * Gets or sets the pole target position
  5236. */
  5237. poleTargetPosition: Vector3;
  5238. /**
  5239. * Gets or sets the pole target local offset
  5240. */
  5241. poleTargetLocalOffset: Vector3;
  5242. /**
  5243. * Gets or sets the pole angle
  5244. */
  5245. poleAngle: number;
  5246. /**
  5247. * Gets or sets the mesh associated with the controller
  5248. */
  5249. mesh: AbstractMesh;
  5250. /**
  5251. * 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)
  5252. */
  5253. slerpAmount: number;
  5254. private _bone1Quat;
  5255. private _bone1Mat;
  5256. private _bone2Ang;
  5257. private _bone1;
  5258. private _bone2;
  5259. private _bone1Length;
  5260. private _bone2Length;
  5261. private _maxAngle;
  5262. private _maxReach;
  5263. private _rightHandedSystem;
  5264. private _bendAxis;
  5265. private _slerping;
  5266. private _adjustRoll;
  5267. /**
  5268. * Gets or sets maximum allowed angle
  5269. */
  5270. maxAngle: number;
  5271. /**
  5272. * Creates a new BoneIKController
  5273. * @param mesh defines the mesh to control
  5274. * @param bone defines the bone to control
  5275. * @param options defines options to set up the controller
  5276. */
  5277. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5278. targetMesh?: AbstractMesh;
  5279. poleTargetMesh?: AbstractMesh;
  5280. poleTargetBone?: Bone;
  5281. poleTargetLocalOffset?: Vector3;
  5282. poleAngle?: number;
  5283. bendAxis?: Vector3;
  5284. maxAngle?: number;
  5285. slerpAmount?: number;
  5286. });
  5287. private _setMaxAngle;
  5288. /**
  5289. * Force the controller to update the bones
  5290. */
  5291. update(): void;
  5292. }
  5293. }
  5294. declare module BABYLON {
  5295. /**
  5296. * Class used to make a bone look toward a point in space
  5297. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5298. */
  5299. class BoneLookController {
  5300. private static _tmpVecs;
  5301. private static _tmpQuat;
  5302. private static _tmpMats;
  5303. /**
  5304. * The target Vector3 that the bone will look at
  5305. */
  5306. target: Vector3;
  5307. /**
  5308. * The mesh that the bone is attached to
  5309. */
  5310. mesh: AbstractMesh;
  5311. /**
  5312. * The bone that will be looking to the target
  5313. */
  5314. bone: Bone;
  5315. /**
  5316. * The up axis of the coordinate system that is used when the bone is rotated
  5317. */
  5318. upAxis: Vector3;
  5319. /**
  5320. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5321. */
  5322. upAxisSpace: Space;
  5323. /**
  5324. * Used to make an adjustment to the yaw of the bone
  5325. */
  5326. adjustYaw: number;
  5327. /**
  5328. * Used to make an adjustment to the pitch of the bone
  5329. */
  5330. adjustPitch: number;
  5331. /**
  5332. * Used to make an adjustment to the roll of the bone
  5333. */
  5334. adjustRoll: number;
  5335. /**
  5336. * 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)
  5337. */
  5338. slerpAmount: number;
  5339. private _minYaw;
  5340. private _maxYaw;
  5341. private _minPitch;
  5342. private _maxPitch;
  5343. private _minYawSin;
  5344. private _minYawCos;
  5345. private _maxYawSin;
  5346. private _maxYawCos;
  5347. private _midYawConstraint;
  5348. private _minPitchTan;
  5349. private _maxPitchTan;
  5350. private _boneQuat;
  5351. private _slerping;
  5352. private _transformYawPitch;
  5353. private _transformYawPitchInv;
  5354. private _firstFrameSkipped;
  5355. private _yawRange;
  5356. private _fowardAxis;
  5357. /**
  5358. * Gets or sets the minimum yaw angle that the bone can look to
  5359. */
  5360. minYaw: number;
  5361. /**
  5362. * Gets or sets the maximum yaw angle that the bone can look to
  5363. */
  5364. maxYaw: number;
  5365. /**
  5366. * Gets or sets the minimum pitch angle that the bone can look to
  5367. */
  5368. minPitch: number;
  5369. /**
  5370. * Gets or sets the maximum pitch angle that the bone can look to
  5371. */
  5372. maxPitch: number;
  5373. /**
  5374. * Create a BoneLookController
  5375. * @param mesh the mesh that the bone belongs to
  5376. * @param bone the bone that will be looking to the target
  5377. * @param target the target Vector3 to look at
  5378. * @param settings optional settings:
  5379. * * maxYaw: the maximum angle the bone will yaw to
  5380. * * minYaw: the minimum angle the bone will yaw to
  5381. * * maxPitch: the maximum angle the bone will pitch to
  5382. * * minPitch: the minimum angle the bone will yaw to
  5383. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5384. * * upAxis: the up axis of the coordinate system
  5385. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5386. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5387. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5388. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5389. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5390. * * adjustRoll: used to make an adjustment to the roll of the bone
  5391. **/
  5392. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5393. maxYaw?: number;
  5394. minYaw?: number;
  5395. maxPitch?: number;
  5396. minPitch?: number;
  5397. slerpAmount?: number;
  5398. upAxis?: Vector3;
  5399. upAxisSpace?: Space;
  5400. yawAxis?: Vector3;
  5401. pitchAxis?: Vector3;
  5402. adjustYaw?: number;
  5403. adjustPitch?: number;
  5404. adjustRoll?: number;
  5405. });
  5406. /**
  5407. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5408. */
  5409. update(): void;
  5410. private _getAngleDiff;
  5411. private _getAngleBetween;
  5412. private _isAngleBetween;
  5413. }
  5414. }
  5415. declare module BABYLON {
  5416. /**
  5417. * Class used to handle skinning animations
  5418. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5419. */
  5420. class Skeleton implements IAnimatable {
  5421. /** defines the skeleton name */
  5422. name: string;
  5423. /** defines the skeleton Id */
  5424. id: string;
  5425. /**
  5426. * Gets the list of child bones
  5427. */
  5428. bones: Bone[];
  5429. /**
  5430. * Gets an estimate of the dimension of the skeleton at rest
  5431. */
  5432. dimensionsAtRest: Vector3;
  5433. /**
  5434. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5435. */
  5436. needInitialSkinMatrix: boolean;
  5437. /**
  5438. * Gets the list of animations attached to this skeleton
  5439. */
  5440. animations: Array<Animation>;
  5441. private _scene;
  5442. private _isDirty;
  5443. private _transformMatrices;
  5444. private _meshesWithPoseMatrix;
  5445. private _animatables;
  5446. private _identity;
  5447. private _synchronizedWithMesh;
  5448. private _ranges;
  5449. private _lastAbsoluteTransformsUpdateId;
  5450. /**
  5451. * Specifies if the skeleton should be serialized
  5452. */
  5453. doNotSerialize: boolean;
  5454. private _animationPropertiesOverride;
  5455. /**
  5456. * Gets or sets the animation properties override
  5457. */
  5458. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5459. /**
  5460. * An observable triggered before computing the skeleton's matrices
  5461. */
  5462. onBeforeComputeObservable: Observable<Skeleton>;
  5463. /**
  5464. * Creates a new skeleton
  5465. * @param name defines the skeleton name
  5466. * @param id defines the skeleton Id
  5467. * @param scene defines the hosting scene
  5468. */
  5469. constructor(
  5470. /** defines the skeleton name */
  5471. name: string,
  5472. /** defines the skeleton Id */
  5473. id: string, scene: Scene);
  5474. /**
  5475. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5476. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5477. * @returns a Float32Array containing matrices data
  5478. */
  5479. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5480. /**
  5481. * Gets the current hosting scene
  5482. * @returns a scene object
  5483. */
  5484. getScene(): Scene;
  5485. /**
  5486. * Gets a string representing the current skeleton data
  5487. * @param fullDetails defines a boolean indicating if we want a verbose version
  5488. * @returns a string representing the current skeleton data
  5489. */
  5490. toString(fullDetails?: boolean): string;
  5491. /**
  5492. * Get bone's index searching by name
  5493. * @param name defines bone's name to search for
  5494. * @return the indice of the bone. Returns -1 if not found
  5495. */
  5496. getBoneIndexByName(name: string): number;
  5497. /**
  5498. * Creater a new animation range
  5499. * @param name defines the name of the range
  5500. * @param from defines the start key
  5501. * @param to defines the end key
  5502. */
  5503. createAnimationRange(name: string, from: number, to: number): void;
  5504. /**
  5505. * Delete a specific animation range
  5506. * @param name defines the name of the range
  5507. * @param deleteFrames defines if frames must be removed as well
  5508. */
  5509. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5510. /**
  5511. * Gets a specific animation range
  5512. * @param name defines the name of the range to look for
  5513. * @returns the requested animation range or null if not found
  5514. */
  5515. getAnimationRange(name: string): Nullable<AnimationRange>;
  5516. /**
  5517. * Gets the list of all animation ranges defined on this skeleton
  5518. * @returns an array
  5519. */
  5520. getAnimationRanges(): Nullable<AnimationRange>[];
  5521. /**
  5522. * Copy animation range from a source skeleton.
  5523. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5524. * @param source defines the source skeleton
  5525. * @param name defines the name of the range to copy
  5526. * @param rescaleAsRequired defines if rescaling must be applied if required
  5527. * @returns true if operation was successful
  5528. */
  5529. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5530. /**
  5531. * Forces the skeleton to go to rest pose
  5532. */
  5533. returnToRest(): void;
  5534. private _getHighestAnimationFrame;
  5535. /**
  5536. * Begin a specific animation range
  5537. * @param name defines the name of the range to start
  5538. * @param loop defines if looping must be turned on (false by default)
  5539. * @param speedRatio defines the speed ratio to apply (1 by default)
  5540. * @param onAnimationEnd defines a callback which will be called when animation will end
  5541. * @returns a new animatable
  5542. */
  5543. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5544. /** @hidden */
  5545. _markAsDirty(): void;
  5546. /** @hidden */
  5547. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5548. /** @hidden */
  5549. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5550. /** @hidden */
  5551. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5552. /**
  5553. * Build all resources required to render a skeleton
  5554. */
  5555. prepare(): void;
  5556. /**
  5557. * Gets the list of animatables currently running for this skeleton
  5558. * @returns an array of animatables
  5559. */
  5560. getAnimatables(): IAnimatable[];
  5561. /**
  5562. * Clone the current skeleton
  5563. * @param name defines the name of the new skeleton
  5564. * @param id defines the id of the enw skeleton
  5565. * @returns the new skeleton
  5566. */
  5567. clone(name: string, id: string): Skeleton;
  5568. /**
  5569. * Enable animation blending for this skeleton
  5570. * @param blendingSpeed defines the blending speed to apply
  5571. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5572. */
  5573. enableBlending(blendingSpeed?: number): void;
  5574. /**
  5575. * Releases all resources associated with the current skeleton
  5576. */
  5577. dispose(): void;
  5578. /**
  5579. * Serialize the skeleton in a JSON object
  5580. * @returns a JSON object
  5581. */
  5582. serialize(): any;
  5583. /**
  5584. * Creates a new skeleton from serialized data
  5585. * @param parsedSkeleton defines the serialized data
  5586. * @param scene defines the hosting scene
  5587. * @returns a new skeleton
  5588. */
  5589. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5590. /**
  5591. * Compute all node absolute transforms
  5592. * @param forceUpdate defines if computation must be done even if cache is up to date
  5593. */
  5594. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5595. /**
  5596. * Gets the root pose matrix
  5597. * @returns a matrix
  5598. */
  5599. getPoseMatrix(): Nullable<Matrix>;
  5600. /**
  5601. * Sorts bones per internal index
  5602. */
  5603. sortBones(): void;
  5604. private _sortBones;
  5605. }
  5606. }
  5607. declare module BABYLON {
  5608. /**
  5609. * Interface used to define a behavior
  5610. */
  5611. interface Behavior<T> {
  5612. /** gets or sets behavior's name */
  5613. name: string;
  5614. /**
  5615. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5616. */
  5617. init(): void;
  5618. /**
  5619. * Called when the behavior is attached to a target
  5620. * @param target defines the target where the behavior is attached to
  5621. */
  5622. attach(target: T): void;
  5623. /**
  5624. * Called when the behavior is detached from its target
  5625. */
  5626. detach(): void;
  5627. }
  5628. /**
  5629. * Interface implemented by classes supporting behaviors
  5630. */
  5631. interface IBehaviorAware<T> {
  5632. /**
  5633. * Attach a behavior
  5634. * @param behavior defines the behavior to attach
  5635. * @returns the current host
  5636. */
  5637. addBehavior(behavior: Behavior<T>): T;
  5638. /**
  5639. * Remove a behavior from the current object
  5640. * @param behavior defines the behavior to detach
  5641. * @returns the current host
  5642. */
  5643. removeBehavior(behavior: Behavior<T>): T;
  5644. /**
  5645. * Gets a behavior using its name to search
  5646. * @param name defines the name to search
  5647. * @returns the behavior or null if not found
  5648. */
  5649. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5650. }
  5651. }
  5652. declare module BABYLON {
  5653. class Collider {
  5654. /** Define if a collision was found */
  5655. collisionFound: boolean;
  5656. /**
  5657. * Define last intersection point in local space
  5658. */
  5659. intersectionPoint: Vector3;
  5660. /**
  5661. * Define last collided mesh
  5662. */
  5663. collidedMesh: Nullable<AbstractMesh>;
  5664. private _collisionPoint;
  5665. private _planeIntersectionPoint;
  5666. private _tempVector;
  5667. private _tempVector2;
  5668. private _tempVector3;
  5669. private _tempVector4;
  5670. private _edge;
  5671. private _baseToVertex;
  5672. private _destinationPoint;
  5673. private _slidePlaneNormal;
  5674. private _displacementVector;
  5675. /** @hidden */
  5676. _radius: Vector3;
  5677. /** @hidden */
  5678. _retry: number;
  5679. private _velocity;
  5680. private _basePoint;
  5681. private _epsilon;
  5682. /** @hidden */
  5683. _velocityWorldLength: number;
  5684. /** @hidden */
  5685. _basePointWorld: Vector3;
  5686. private _velocityWorld;
  5687. private _normalizedVelocity;
  5688. /** @hidden */
  5689. _initialVelocity: Vector3;
  5690. /** @hidden */
  5691. _initialPosition: Vector3;
  5692. private _nearestDistance;
  5693. private _collisionMask;
  5694. collisionMask: number;
  5695. /**
  5696. * Gets the plane normal used to compute the sliding response (in local space)
  5697. */
  5698. readonly slidePlaneNormal: Vector3;
  5699. /** @hidden */
  5700. _initialize(source: Vector3, dir: Vector3, e: number): void;
  5701. /** @hidden */
  5702. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  5703. /** @hidden */
  5704. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  5705. /** @hidden */
  5706. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  5707. /** @hidden */
  5708. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  5709. /** @hidden */
  5710. _getResponse(pos: Vector3, vel: Vector3): void;
  5711. }
  5712. }
  5713. declare module BABYLON {
  5714. var CollisionWorker: string;
  5715. interface ICollisionCoordinator {
  5716. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5717. init(scene: Scene): void;
  5718. destroy(): void;
  5719. onMeshAdded(mesh: AbstractMesh): void;
  5720. onMeshUpdated(mesh: AbstractMesh): void;
  5721. onMeshRemoved(mesh: AbstractMesh): void;
  5722. onGeometryAdded(geometry: Geometry): void;
  5723. onGeometryUpdated(geometry: Geometry): void;
  5724. onGeometryDeleted(geometry: Geometry): void;
  5725. }
  5726. interface SerializedMesh {
  5727. id: string;
  5728. name: string;
  5729. uniqueId: number;
  5730. geometryId: Nullable<string>;
  5731. sphereCenter: Array<number>;
  5732. sphereRadius: number;
  5733. boxMinimum: Array<number>;
  5734. boxMaximum: Array<number>;
  5735. worldMatrixFromCache: any;
  5736. subMeshes: Array<SerializedSubMesh>;
  5737. checkCollisions: boolean;
  5738. }
  5739. interface SerializedSubMesh {
  5740. position: number;
  5741. verticesStart: number;
  5742. verticesCount: number;
  5743. indexStart: number;
  5744. indexCount: number;
  5745. hasMaterial: boolean;
  5746. sphereCenter: Array<number>;
  5747. sphereRadius: number;
  5748. boxMinimum: Array<number>;
  5749. boxMaximum: Array<number>;
  5750. }
  5751. /**
  5752. * Interface describing the value associated with a geometry
  5753. */
  5754. interface SerializedGeometry {
  5755. /**
  5756. * Defines the unique ID of the geometry
  5757. */
  5758. id: string;
  5759. /**
  5760. * Defines the array containing the positions
  5761. */
  5762. positions: Float32Array;
  5763. /**
  5764. * Defines the array containing the indices
  5765. */
  5766. indices: Uint32Array;
  5767. /**
  5768. * Defines the array containing the normals
  5769. */
  5770. normals: Float32Array;
  5771. }
  5772. interface BabylonMessage {
  5773. taskType: WorkerTaskType;
  5774. payload: InitPayload | CollidePayload | UpdatePayload;
  5775. }
  5776. interface SerializedColliderToWorker {
  5777. position: Array<number>;
  5778. velocity: Array<number>;
  5779. radius: Array<number>;
  5780. }
  5781. /** Defines supported task for worker process */
  5782. enum WorkerTaskType {
  5783. /** Initialization */
  5784. INIT = 0,
  5785. /** Update of geometry */
  5786. UPDATE = 1,
  5787. /** Evaluate collision */
  5788. COLLIDE = 2
  5789. }
  5790. interface WorkerReply {
  5791. error: WorkerReplyType;
  5792. taskType: WorkerTaskType;
  5793. payload?: any;
  5794. }
  5795. interface CollisionReplyPayload {
  5796. newPosition: Array<number>;
  5797. collisionId: number;
  5798. collidedMeshUniqueId: number;
  5799. }
  5800. interface InitPayload {
  5801. }
  5802. interface CollidePayload {
  5803. collisionId: number;
  5804. collider: SerializedColliderToWorker;
  5805. maximumRetry: number;
  5806. excludedMeshUniqueId: Nullable<number>;
  5807. }
  5808. interface UpdatePayload {
  5809. updatedMeshes: {
  5810. [n: number]: SerializedMesh;
  5811. };
  5812. updatedGeometries: {
  5813. [s: string]: SerializedGeometry;
  5814. };
  5815. removedMeshes: Array<number>;
  5816. removedGeometries: Array<string>;
  5817. }
  5818. /** Defines kind of replies returned by worker */
  5819. enum WorkerReplyType {
  5820. /** Success */
  5821. SUCCESS = 0,
  5822. /** Unkown error */
  5823. UNKNOWN_ERROR = 1
  5824. }
  5825. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  5826. private _scene;
  5827. private _scaledPosition;
  5828. private _scaledVelocity;
  5829. private _collisionsCallbackArray;
  5830. private _init;
  5831. private _runningUpdated;
  5832. private _worker;
  5833. private _addUpdateMeshesList;
  5834. private _addUpdateGeometriesList;
  5835. private _toRemoveMeshesArray;
  5836. private _toRemoveGeometryArray;
  5837. constructor();
  5838. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  5839. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  5840. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5841. init(scene: Scene): void;
  5842. destroy(): void;
  5843. onMeshAdded(mesh: AbstractMesh): void;
  5844. onMeshUpdated: (transformNode: TransformNode) => void;
  5845. onMeshRemoved(mesh: AbstractMesh): void;
  5846. onGeometryAdded(geometry: Geometry): void;
  5847. onGeometryUpdated: (geometry: Geometry) => void;
  5848. onGeometryDeleted(geometry: Geometry): void;
  5849. private _afterRender;
  5850. private _onMessageFromWorker;
  5851. }
  5852. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  5853. private _scene;
  5854. private _scaledPosition;
  5855. private _scaledVelocity;
  5856. private _finalPosition;
  5857. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5858. init(scene: Scene): void;
  5859. destroy(): void;
  5860. onMeshAdded(mesh: AbstractMesh): void;
  5861. onMeshUpdated(mesh: AbstractMesh): void;
  5862. onMeshRemoved(mesh: AbstractMesh): void;
  5863. onGeometryAdded(geometry: Geometry): void;
  5864. onGeometryUpdated(geometry: Geometry): void;
  5865. onGeometryDeleted(geometry: Geometry): void;
  5866. private _collideWithWorld;
  5867. }
  5868. }
  5869. declare function importScripts(...urls: string[]): void;
  5870. declare const safePostMessage: any;
  5871. declare module BABYLON {
  5872. var WorkerIncluded: boolean;
  5873. class CollisionCache {
  5874. private _meshes;
  5875. private _geometries;
  5876. getMeshes(): {
  5877. [n: number]: SerializedMesh;
  5878. };
  5879. getGeometries(): {
  5880. [s: number]: SerializedGeometry;
  5881. };
  5882. getMesh(id: any): SerializedMesh;
  5883. addMesh(mesh: SerializedMesh): void;
  5884. removeMesh(uniqueId: number): void;
  5885. getGeometry(id: string): SerializedGeometry;
  5886. addGeometry(geometry: SerializedGeometry): void;
  5887. removeGeometry(id: string): void;
  5888. }
  5889. class CollideWorker {
  5890. collider: Collider;
  5891. private _collisionCache;
  5892. private finalPosition;
  5893. private collisionsScalingMatrix;
  5894. private collisionTranformationMatrix;
  5895. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  5896. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  5897. private checkCollision;
  5898. private processCollisionsForSubMeshes;
  5899. private collideForSubMesh;
  5900. private checkSubmeshCollision;
  5901. }
  5902. interface ICollisionDetector {
  5903. onInit(payload: InitPayload): void;
  5904. onUpdate(payload: UpdatePayload): void;
  5905. onCollision(payload: CollidePayload): void;
  5906. }
  5907. class CollisionDetectorTransferable implements ICollisionDetector {
  5908. private _collisionCache;
  5909. onInit(payload: InitPayload): void;
  5910. onUpdate(payload: UpdatePayload): void;
  5911. onCollision(payload: CollidePayload): void;
  5912. }
  5913. }
  5914. declare module BABYLON {
  5915. class IntersectionInfo {
  5916. bu: Nullable<number>;
  5917. bv: Nullable<number>;
  5918. distance: number;
  5919. faceId: number;
  5920. subMeshId: number;
  5921. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  5922. }
  5923. /**
  5924. * Information about the result of picking within a scene
  5925. * See https://doc.babylonjs.com/babylon101/picking_collisions
  5926. */
  5927. class PickingInfo {
  5928. /**
  5929. * If the pick collided with an object
  5930. */
  5931. hit: boolean;
  5932. /**
  5933. * Distance away where the pick collided
  5934. */
  5935. distance: number;
  5936. /**
  5937. * The location of pick collision
  5938. */
  5939. pickedPoint: Nullable<Vector3>;
  5940. /**
  5941. * The mesh corresponding the the pick collision
  5942. */
  5943. pickedMesh: Nullable<AbstractMesh>;
  5944. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  5945. bu: number;
  5946. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  5947. bv: number;
  5948. /** The id of the face on the mesh that was picked */
  5949. faceId: number;
  5950. /** Id of the the submesh that was picked */
  5951. subMeshId: number;
  5952. /** If a sprite was picked, this will be the sprite the pick collided with */
  5953. pickedSprite: Nullable<Sprite>;
  5954. /**
  5955. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  5956. */
  5957. originMesh: Nullable<AbstractMesh>;
  5958. /**
  5959. * The ray that was used to perform the picking.
  5960. */
  5961. ray: Nullable<Ray>;
  5962. /**
  5963. * Gets the normal correspodning to the face the pick collided with
  5964. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  5965. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  5966. * @returns The normal correspodning to the face the pick collided with
  5967. */
  5968. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  5969. /**
  5970. * Gets the texture coordinates of where the pick occured
  5971. * @returns the vector containing the coordnates of the texture
  5972. */
  5973. getTextureCoordinates(): Nullable<Vector2>;
  5974. }
  5975. }
  5976. declare module BABYLON {
  5977. class ArcRotateCamera extends TargetCamera {
  5978. alpha: number;
  5979. beta: number;
  5980. radius: number;
  5981. protected _target: Vector3;
  5982. protected _targetHost: Nullable<AbstractMesh>;
  5983. target: Vector3;
  5984. inertialAlphaOffset: number;
  5985. inertialBetaOffset: number;
  5986. inertialRadiusOffset: number;
  5987. lowerAlphaLimit: Nullable<number>;
  5988. upperAlphaLimit: Nullable<number>;
  5989. lowerBetaLimit: number;
  5990. upperBetaLimit: number;
  5991. lowerRadiusLimit: Nullable<number>;
  5992. upperRadiusLimit: Nullable<number>;
  5993. inertialPanningX: number;
  5994. inertialPanningY: number;
  5995. pinchToPanMaxDistance: number;
  5996. panningDistanceLimit: Nullable<number>;
  5997. panningOriginTarget: Vector3;
  5998. panningInertia: number;
  5999. angularSensibilityX: number;
  6000. angularSensibilityY: number;
  6001. pinchPrecision: number;
  6002. pinchDeltaPercentage: number;
  6003. panningSensibility: number;
  6004. keysUp: number[];
  6005. keysDown: number[];
  6006. keysLeft: number[];
  6007. keysRight: number[];
  6008. wheelPrecision: number;
  6009. wheelDeltaPercentage: number;
  6010. zoomOnFactor: number;
  6011. targetScreenOffset: Vector2;
  6012. allowUpsideDown: boolean;
  6013. /** @hidden */
  6014. _viewMatrix: Matrix;
  6015. /** @hidden */
  6016. _useCtrlForPanning: boolean;
  6017. /** @hidden */
  6018. _panningMouseButton: number;
  6019. inputs: ArcRotateCameraInputsManager;
  6020. /** @hidden */
  6021. _reset: () => void;
  6022. panningAxis: Vector3;
  6023. protected _localDirection: Vector3;
  6024. protected _transformedDirection: Vector3;
  6025. private _bouncingBehavior;
  6026. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  6027. useBouncingBehavior: boolean;
  6028. private _framingBehavior;
  6029. readonly framingBehavior: Nullable<FramingBehavior>;
  6030. useFramingBehavior: boolean;
  6031. private _autoRotationBehavior;
  6032. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  6033. useAutoRotationBehavior: boolean;
  6034. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  6035. onCollide: (collidedMesh: AbstractMesh) => void;
  6036. checkCollisions: boolean;
  6037. collisionRadius: Vector3;
  6038. protected _collider: Collider;
  6039. protected _previousPosition: Vector3;
  6040. protected _collisionVelocity: Vector3;
  6041. protected _newPosition: Vector3;
  6042. protected _previousAlpha: number;
  6043. protected _previousBeta: number;
  6044. protected _previousRadius: number;
  6045. protected _collisionTriggered: boolean;
  6046. protected _targetBoundingCenter: Nullable<Vector3>;
  6047. private _computationVector;
  6048. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6049. /** @hidden */
  6050. _initCache(): void;
  6051. /** @hidden */
  6052. _updateCache(ignoreParentClass?: boolean): void;
  6053. protected _getTargetPosition(): Vector3;
  6054. /**
  6055. * Store current camera state (fov, position, etc..)
  6056. */
  6057. private _storedAlpha;
  6058. private _storedBeta;
  6059. private _storedRadius;
  6060. private _storedTarget;
  6061. storeState(): Camera;
  6062. /**
  6063. * @hidden
  6064. * Restored camera state. You must call storeState() first
  6065. */
  6066. _restoreStateValues(): boolean;
  6067. /** @hidden */
  6068. _isSynchronizedViewMatrix(): boolean;
  6069. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  6070. detachControl(element: HTMLElement): void;
  6071. /** @hidden */
  6072. _checkInputs(): void;
  6073. protected _checkLimits(): void;
  6074. rebuildAnglesAndRadius(): void;
  6075. setPosition(position: Vector3): void;
  6076. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  6077. /** @hidden */
  6078. _getViewMatrix(): Matrix;
  6079. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  6080. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  6081. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  6082. min: Vector3;
  6083. max: Vector3;
  6084. distance: number;
  6085. }, doNotUpdateMaxZ?: boolean): void;
  6086. /**
  6087. * @override
  6088. * Override Camera.createRigCamera
  6089. */
  6090. createRigCamera(name: string, cameraIndex: number): Camera;
  6091. /**
  6092. * @hidden
  6093. * @override
  6094. * Override Camera._updateRigCameras
  6095. */
  6096. _updateRigCameras(): void;
  6097. dispose(): void;
  6098. getClassName(): string;
  6099. }
  6100. }
  6101. declare module BABYLON {
  6102. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  6103. constructor(camera: ArcRotateCamera);
  6104. addMouseWheel(): ArcRotateCameraInputsManager;
  6105. addPointers(): ArcRotateCameraInputsManager;
  6106. addKeyboard(): ArcRotateCameraInputsManager;
  6107. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  6108. }
  6109. }
  6110. declare module BABYLON {
  6111. class Camera extends Node {
  6112. inputs: CameraInputsManager<Camera>;
  6113. private static _PERSPECTIVE_CAMERA;
  6114. private static _ORTHOGRAPHIC_CAMERA;
  6115. private static _FOVMODE_VERTICAL_FIXED;
  6116. private static _FOVMODE_HORIZONTAL_FIXED;
  6117. private static _RIG_MODE_NONE;
  6118. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  6119. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  6120. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  6121. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  6122. private static _RIG_MODE_VR;
  6123. private static _RIG_MODE_WEBVR;
  6124. static readonly PERSPECTIVE_CAMERA: number;
  6125. static readonly ORTHOGRAPHIC_CAMERA: number;
  6126. /**
  6127. * This is the default FOV mode for perspective cameras.
  6128. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  6129. *
  6130. */
  6131. static readonly FOVMODE_VERTICAL_FIXED: number;
  6132. /**
  6133. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  6134. *
  6135. */
  6136. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  6137. static readonly RIG_MODE_NONE: number;
  6138. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  6139. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  6140. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  6141. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  6142. static readonly RIG_MODE_VR: number;
  6143. static readonly RIG_MODE_WEBVR: number;
  6144. static ForceAttachControlToAlwaysPreventDefault: boolean;
  6145. static UseAlternateWebVRRendering: boolean;
  6146. position: Vector3;
  6147. /**
  6148. * The vector the camera should consider as up.
  6149. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  6150. */
  6151. upVector: Vector3;
  6152. orthoLeft: Nullable<number>;
  6153. orthoRight: Nullable<number>;
  6154. orthoBottom: Nullable<number>;
  6155. orthoTop: Nullable<number>;
  6156. /**
  6157. * FOV is set in Radians. (default is 0.8)
  6158. */
  6159. fov: number;
  6160. minZ: number;
  6161. maxZ: number;
  6162. inertia: number;
  6163. mode: number;
  6164. isIntermediate: boolean;
  6165. viewport: Viewport;
  6166. /**
  6167. * Restricts the camera to viewing objects with the same layerMask.
  6168. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  6169. */
  6170. layerMask: number;
  6171. /**
  6172. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  6173. */
  6174. fovMode: number;
  6175. cameraRigMode: number;
  6176. interaxialDistance: number;
  6177. isStereoscopicSideBySide: boolean;
  6178. /** @hidden */
  6179. _cameraRigParams: any;
  6180. /** @hidden */
  6181. _rigCameras: Camera[];
  6182. /** @hidden */
  6183. _rigPostProcess: Nullable<PostProcess>;
  6184. protected _webvrViewMatrix: Matrix;
  6185. /** @hidden */
  6186. _skipRendering: boolean;
  6187. /** @hidden */
  6188. _alternateCamera: Camera;
  6189. customRenderTargets: RenderTargetTexture[];
  6190. onViewMatrixChangedObservable: Observable<Camera>;
  6191. onProjectionMatrixChangedObservable: Observable<Camera>;
  6192. onAfterCheckInputsObservable: Observable<Camera>;
  6193. onRestoreStateObservable: Observable<Camera>;
  6194. private _computedViewMatrix;
  6195. _projectionMatrix: Matrix;
  6196. private _doNotComputeProjectionMatrix;
  6197. _postProcesses: Nullable<PostProcess>[];
  6198. private _transformMatrix;
  6199. _activeMeshes: SmartArray<AbstractMesh>;
  6200. protected _globalPosition: Vector3;
  6201. private _frustumPlanes;
  6202. private _refreshFrustumPlanes;
  6203. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6204. private _storedFov;
  6205. private _stateStored;
  6206. /**
  6207. * Store current camera state (fov, position, etc..)
  6208. */
  6209. storeState(): Camera;
  6210. /**
  6211. * Restores the camera state values if it has been stored. You must call storeState() first
  6212. */
  6213. protected _restoreStateValues(): boolean;
  6214. /**
  6215. * Restored camera state. You must call storeState() first
  6216. */
  6217. restoreState(): boolean;
  6218. getClassName(): string;
  6219. /**
  6220. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  6221. */
  6222. toString(fullDetails?: boolean): string;
  6223. readonly globalPosition: Vector3;
  6224. getActiveMeshes(): SmartArray<AbstractMesh>;
  6225. isActiveMesh(mesh: Mesh): boolean;
  6226. /**
  6227. * Is this camera ready to be used/rendered
  6228. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  6229. * @return true if the camera is ready
  6230. */
  6231. isReady(completeCheck?: boolean): boolean;
  6232. /** @hidden */
  6233. _initCache(): void;
  6234. /** @hidden */
  6235. _updateCache(ignoreParentClass?: boolean): void;
  6236. /** @hidden */
  6237. _isSynchronized(): boolean;
  6238. /** @hidden */
  6239. _isSynchronizedViewMatrix(): boolean;
  6240. /** @hidden */
  6241. _isSynchronizedProjectionMatrix(): boolean;
  6242. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6243. detachControl(element: HTMLElement): void;
  6244. update(): void;
  6245. /** @hidden */
  6246. _checkInputs(): void;
  6247. readonly rigCameras: Camera[];
  6248. readonly rigPostProcess: Nullable<PostProcess>;
  6249. /**
  6250. * Internal, gets the first post proces.
  6251. * @returns the first post process to be run on this camera.
  6252. */
  6253. _getFirstPostProcess(): Nullable<PostProcess>;
  6254. private _cascadePostProcessesToRigCams;
  6255. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  6256. detachPostProcess(postProcess: PostProcess): void;
  6257. getWorldMatrix(): Matrix;
  6258. /** @hidden */
  6259. _getViewMatrix(): Matrix;
  6260. getViewMatrix(force?: boolean): Matrix;
  6261. freezeProjectionMatrix(projection?: Matrix): void;
  6262. unfreezeProjectionMatrix(): void;
  6263. getProjectionMatrix(force?: boolean): Matrix;
  6264. /**
  6265. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  6266. * @returns a Matrix
  6267. */
  6268. getTransformationMatrix(): Matrix;
  6269. private updateFrustumPlanes;
  6270. isInFrustum(target: ICullable): boolean;
  6271. isCompletelyInFrustum(target: ICullable): boolean;
  6272. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  6273. /**
  6274. * Releases resources associated with this node.
  6275. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  6276. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  6277. */
  6278. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  6279. readonly leftCamera: Nullable<FreeCamera>;
  6280. readonly rightCamera: Nullable<FreeCamera>;
  6281. getLeftTarget(): Nullable<Vector3>;
  6282. getRightTarget(): Nullable<Vector3>;
  6283. setCameraRigMode(mode: number, rigParams: any): void;
  6284. private _getVRProjectionMatrix;
  6285. protected _updateCameraRotationMatrix(): void;
  6286. protected _updateWebVRCameraRotationMatrix(): void;
  6287. /**
  6288. * This function MUST be overwritten by the different WebVR cameras available.
  6289. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6290. */
  6291. protected _getWebVRProjectionMatrix(): Matrix;
  6292. /**
  6293. * This function MUST be overwritten by the different WebVR cameras available.
  6294. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6295. */
  6296. protected _getWebVRViewMatrix(): Matrix;
  6297. setCameraRigParameter(name: string, value: any): void;
  6298. /**
  6299. * needs to be overridden by children so sub has required properties to be copied
  6300. */
  6301. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6302. /**
  6303. * May need to be overridden by children
  6304. * @hidden
  6305. */
  6306. _updateRigCameras(): void;
  6307. /** @hidden */
  6308. _setupInputs(): void;
  6309. serialize(): any;
  6310. clone(name: string): Camera;
  6311. getDirection(localAxis: Vector3): Vector3;
  6312. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  6313. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  6314. computeWorldMatrix(): Matrix;
  6315. static Parse(parsedCamera: any, scene: Scene): Camera;
  6316. }
  6317. }
  6318. declare module BABYLON {
  6319. var CameraInputTypes: {};
  6320. interface ICameraInput<TCamera extends Camera> {
  6321. camera: Nullable<TCamera>;
  6322. getClassName(): string;
  6323. getSimpleName(): string;
  6324. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  6325. detachControl: (element: Nullable<HTMLElement>) => void;
  6326. checkInputs?: () => void;
  6327. }
  6328. interface CameraInputsMap<TCamera extends Camera> {
  6329. [name: string]: ICameraInput<TCamera>;
  6330. [idx: number]: ICameraInput<TCamera>;
  6331. }
  6332. class CameraInputsManager<TCamera extends Camera> {
  6333. attached: CameraInputsMap<TCamera>;
  6334. attachedElement: Nullable<HTMLElement>;
  6335. noPreventDefault: boolean;
  6336. camera: TCamera;
  6337. checkInputs: () => void;
  6338. constructor(camera: TCamera);
  6339. /**
  6340. * Add an input method to a camera
  6341. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6342. * @param input camera input method
  6343. */
  6344. add(input: ICameraInput<TCamera>): void;
  6345. /**
  6346. * Remove a specific input method from a camera
  6347. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6348. * @param inputToRemove camera input method
  6349. */
  6350. remove(inputToRemove: ICameraInput<TCamera>): void;
  6351. removeByType(inputType: string): void;
  6352. private _addCheckInputs;
  6353. attachInput(input: ICameraInput<TCamera>): void;
  6354. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6355. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6356. rebuildInputCheck(): void;
  6357. /**
  6358. * Remove all attached input methods from a camera
  6359. */
  6360. clear(): void;
  6361. serialize(serializedCamera: any): void;
  6362. parse(parsedCamera: any): void;
  6363. }
  6364. }
  6365. declare module BABYLON {
  6366. /**
  6367. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  6368. * being tilted forward or back and left or right.
  6369. */
  6370. class DeviceOrientationCamera extends FreeCamera {
  6371. private _initialQuaternion;
  6372. private _quaternionCache;
  6373. /**
  6374. * Creates a new device orientation camera
  6375. * @param name The name of the camera
  6376. * @param position The start position camera
  6377. * @param scene The scene the camera belongs to
  6378. */
  6379. constructor(name: string, position: Vector3, scene: Scene);
  6380. /**
  6381. * Gets the current instance class name ("DeviceOrientationCamera").
  6382. * This helps avoiding instanceof at run time.
  6383. * @returns the class name
  6384. */
  6385. getClassName(): string;
  6386. /**
  6387. * @hidden
  6388. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  6389. */
  6390. _checkInputs(): void;
  6391. /**
  6392. * Reset the camera to its default orientation on the specified axis only.
  6393. * @param axis The axis to reset
  6394. */
  6395. resetToCurrentRotation(axis?: Axis): void;
  6396. }
  6397. }
  6398. declare module BABYLON {
  6399. class FollowCamera extends TargetCamera {
  6400. radius: number;
  6401. rotationOffset: number;
  6402. heightOffset: number;
  6403. cameraAcceleration: number;
  6404. maxCameraSpeed: number;
  6405. lockedTarget: Nullable<AbstractMesh>;
  6406. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  6407. private getRadians;
  6408. private follow;
  6409. /** @hidden */
  6410. _checkInputs(): void;
  6411. getClassName(): string;
  6412. }
  6413. class ArcFollowCamera extends TargetCamera {
  6414. alpha: number;
  6415. beta: number;
  6416. radius: number;
  6417. target: Nullable<AbstractMesh>;
  6418. private _cartesianCoordinates;
  6419. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  6420. private follow;
  6421. /** @hidden */
  6422. _checkInputs(): void;
  6423. getClassName(): string;
  6424. }
  6425. }
  6426. declare module BABYLON {
  6427. class FreeCamera extends TargetCamera {
  6428. ellipsoid: Vector3;
  6429. ellipsoidOffset: Vector3;
  6430. checkCollisions: boolean;
  6431. applyGravity: boolean;
  6432. inputs: FreeCameraInputsManager;
  6433. /**
  6434. * Gets the input sensibility for a mouse input. (default is 2000.0)
  6435. * Higher values reduce sensitivity.
  6436. */
  6437. /**
  6438. * Sets the input sensibility for a mouse input. (default is 2000.0)
  6439. * Higher values reduce sensitivity.
  6440. */
  6441. angularSensibility: number;
  6442. keysUp: number[];
  6443. keysDown: number[];
  6444. keysLeft: number[];
  6445. keysRight: number[];
  6446. onCollide: (collidedMesh: AbstractMesh) => void;
  6447. private _collider;
  6448. private _needMoveForGravity;
  6449. private _oldPosition;
  6450. private _diffPosition;
  6451. private _newPosition;
  6452. /** @hidden */
  6453. _localDirection: Vector3;
  6454. /** @hidden */
  6455. _transformedDirection: Vector3;
  6456. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6457. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6458. detachControl(element: HTMLElement): void;
  6459. private _collisionMask;
  6460. collisionMask: number;
  6461. /** @hidden */
  6462. _collideWithWorld(displacement: Vector3): void;
  6463. private _onCollisionPositionChange;
  6464. /** @hidden */
  6465. _checkInputs(): void;
  6466. /** @hidden */
  6467. _decideIfNeedsToMove(): boolean;
  6468. /** @hidden */
  6469. _updatePosition(): void;
  6470. dispose(): void;
  6471. getClassName(): string;
  6472. }
  6473. }
  6474. declare module BABYLON {
  6475. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  6476. constructor(camera: FreeCamera);
  6477. addKeyboard(): FreeCameraInputsManager;
  6478. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  6479. addDeviceOrientation(): FreeCameraInputsManager;
  6480. addTouch(): FreeCameraInputsManager;
  6481. addVirtualJoystick(): FreeCameraInputsManager;
  6482. }
  6483. }
  6484. declare module BABYLON {
  6485. class GamepadCamera extends UniversalCamera {
  6486. gamepadAngularSensibility: number;
  6487. gamepadMoveSensibility: number;
  6488. constructor(name: string, position: Vector3, scene: Scene);
  6489. getClassName(): string;
  6490. }
  6491. }
  6492. declare module BABYLON {
  6493. class TargetCamera extends Camera {
  6494. cameraDirection: Vector3;
  6495. cameraRotation: Vector2;
  6496. rotation: Vector3;
  6497. rotationQuaternion: Quaternion;
  6498. speed: number;
  6499. noRotationConstraint: boolean;
  6500. lockedTarget: any;
  6501. /** @hidden */
  6502. _currentTarget: Vector3;
  6503. /** @hidden */
  6504. _viewMatrix: Matrix;
  6505. /** @hidden */
  6506. _camMatrix: Matrix;
  6507. /** @hidden */
  6508. _cameraTransformMatrix: Matrix;
  6509. /** @hidden */
  6510. _cameraRotationMatrix: Matrix;
  6511. private _rigCamTransformMatrix;
  6512. /** @hidden */
  6513. _referencePoint: Vector3;
  6514. /** @hidden */
  6515. _transformedReferencePoint: Vector3;
  6516. protected _globalCurrentTarget: Vector3;
  6517. protected _globalCurrentUpVector: Vector3;
  6518. /** @hidden */
  6519. _reset: () => void;
  6520. private _defaultUp;
  6521. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6522. getFrontPosition(distance: number): Vector3;
  6523. /** @hidden */
  6524. _getLockedTargetPosition(): Nullable<Vector3>;
  6525. /**
  6526. * Store current camera state (fov, position, etc..)
  6527. */
  6528. private _storedPosition;
  6529. private _storedRotation;
  6530. private _storedRotationQuaternion;
  6531. storeState(): Camera;
  6532. /**
  6533. * Restored camera state. You must call storeState() first
  6534. * @returns whether it was successful or not
  6535. * @hidden
  6536. */
  6537. _restoreStateValues(): boolean;
  6538. /** @hidden */
  6539. _initCache(): void;
  6540. /** @hidden */
  6541. _updateCache(ignoreParentClass?: boolean): void;
  6542. /** @hidden */
  6543. _isSynchronizedViewMatrix(): boolean;
  6544. /** @hidden */
  6545. _computeLocalCameraSpeed(): number;
  6546. /** @hidden */
  6547. setTarget(target: Vector3): void;
  6548. /**
  6549. * Return the current target position of the camera. This value is expressed in local space.
  6550. */
  6551. getTarget(): Vector3;
  6552. /** @hidden */
  6553. _decideIfNeedsToMove(): boolean;
  6554. /** @hidden */
  6555. _updatePosition(): void;
  6556. /** @hidden */
  6557. _checkInputs(): void;
  6558. protected _updateCameraRotationMatrix(): void;
  6559. /**
  6560. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  6561. * @returns the current camera
  6562. */
  6563. private _rotateUpVectorWithCameraRotationMatrix;
  6564. private _cachedRotationZ;
  6565. /** @hidden */
  6566. _getViewMatrix(): Matrix;
  6567. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6568. /**
  6569. * @override
  6570. * Override Camera.createRigCamera
  6571. */
  6572. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6573. /**
  6574. * @hidden
  6575. * @override
  6576. * Override Camera._updateRigCameras
  6577. */
  6578. _updateRigCameras(): void;
  6579. private _getRigCamPosition;
  6580. getClassName(): string;
  6581. }
  6582. }
  6583. declare module BABYLON {
  6584. class TouchCamera extends FreeCamera {
  6585. touchAngularSensibility: number;
  6586. touchMoveSensibility: number;
  6587. constructor(name: string, position: Vector3, scene: Scene);
  6588. getClassName(): string;
  6589. /** @hidden */
  6590. _setupInputs(): void;
  6591. }
  6592. }
  6593. declare module BABYLON {
  6594. class UniversalCamera extends TouchCamera {
  6595. gamepadAngularSensibility: number;
  6596. gamepadMoveSensibility: number;
  6597. constructor(name: string, position: Vector3, scene: Scene);
  6598. getClassName(): string;
  6599. }
  6600. }
  6601. declare module BABYLON {
  6602. class VirtualJoysticksCamera extends FreeCamera {
  6603. constructor(name: string, position: Vector3, scene: Scene);
  6604. getClassName(): string;
  6605. }
  6606. }
  6607. interface VRDisplay extends EventTarget {
  6608. /**
  6609. * Dictionary of capabilities describing the VRDisplay.
  6610. */
  6611. readonly capabilities: VRDisplayCapabilities;
  6612. /**
  6613. * z-depth defining the far plane of the eye view frustum
  6614. * enables mapping of values in the render target depth
  6615. * attachment to scene coordinates. Initially set to 10000.0.
  6616. */
  6617. depthFar: number;
  6618. /**
  6619. * z-depth defining the near plane of the eye view frustum
  6620. * enables mapping of values in the render target depth
  6621. * attachment to scene coordinates. Initially set to 0.01.
  6622. */
  6623. depthNear: number;
  6624. /**
  6625. * An identifier for this distinct VRDisplay. Used as an
  6626. * association point in the Gamepad API.
  6627. */
  6628. readonly displayId: number;
  6629. /**
  6630. * A display name, a user-readable name identifying it.
  6631. */
  6632. readonly displayName: string;
  6633. readonly isConnected: boolean;
  6634. readonly isPresenting: boolean;
  6635. /**
  6636. * If this VRDisplay supports room-scale experiences, the optional
  6637. * stage attribute contains details on the room-scale parameters.
  6638. */
  6639. readonly stageParameters: VRStageParameters | null;
  6640. /**
  6641. * Passing the value returned by `requestAnimationFrame` to
  6642. * `cancelAnimationFrame` will unregister the callback.
  6643. */
  6644. cancelAnimationFrame(handle: number): void;
  6645. /**
  6646. * Stops presenting to the VRDisplay.
  6647. */
  6648. exitPresent(): Promise<void>;
  6649. getEyeParameters(whichEye: string): VREyeParameters;
  6650. /**
  6651. * Populates the passed VRFrameData with the information required to render
  6652. * the current frame.
  6653. */
  6654. getFrameData(frameData: VRFrameData): boolean;
  6655. /**
  6656. * Get the layers currently being presented.
  6657. */
  6658. getLayers(): VRLayer[];
  6659. /**
  6660. * Return a VRPose containing the future predicted pose of the VRDisplay
  6661. * when the current frame will be presented. The value returned will not
  6662. * change until JavaScript has returned control to the browser.
  6663. *
  6664. * The VRPose will contain the position, orientation, velocity,
  6665. * and acceleration of each of these properties.
  6666. */
  6667. getPose(): VRPose;
  6668. /**
  6669. * Return the current instantaneous pose of the VRDisplay, with no
  6670. * prediction applied.
  6671. */
  6672. getImmediatePose(): VRPose;
  6673. /**
  6674. * The callback passed to `requestAnimationFrame` will be called
  6675. * any time a new frame should be rendered. When the VRDisplay is
  6676. * presenting the callback will be called at the native refresh
  6677. * rate of the HMD. When not presenting this function acts
  6678. * identically to how window.requestAnimationFrame acts. Content should
  6679. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6680. * asynchronously from other displays and at differing refresh rates.
  6681. */
  6682. requestAnimationFrame(callback: FrameRequestCallback): number;
  6683. /**
  6684. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6685. * Repeat calls while already presenting will update the VRLayers being displayed.
  6686. */
  6687. requestPresent(layers: VRLayer[]): Promise<void>;
  6688. /**
  6689. * Reset the pose for this display, treating its current position and
  6690. * orientation as the "origin/zero" values. VRPose.position,
  6691. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6692. * updated when calling resetPose(). This should be called in only
  6693. * sitting-space experiences.
  6694. */
  6695. resetPose(): void;
  6696. /**
  6697. * The VRLayer provided to the VRDisplay will be captured and presented
  6698. * in the HMD. Calling this function has the same effect on the source
  6699. * canvas as any other operation that uses its source image, and canvases
  6700. * created without preserveDrawingBuffer set to true will be cleared.
  6701. */
  6702. submitFrame(pose?: VRPose): void;
  6703. }
  6704. declare var VRDisplay: {
  6705. prototype: VRDisplay;
  6706. new (): VRDisplay;
  6707. };
  6708. interface VRLayer {
  6709. leftBounds?: number[] | Float32Array | null;
  6710. rightBounds?: number[] | Float32Array | null;
  6711. source?: HTMLCanvasElement | null;
  6712. }
  6713. interface VRDisplayCapabilities {
  6714. readonly canPresent: boolean;
  6715. readonly hasExternalDisplay: boolean;
  6716. readonly hasOrientation: boolean;
  6717. readonly hasPosition: boolean;
  6718. readonly maxLayers: number;
  6719. }
  6720. interface VREyeParameters {
  6721. /** @deprecated */
  6722. readonly fieldOfView: VRFieldOfView;
  6723. readonly offset: Float32Array;
  6724. readonly renderHeight: number;
  6725. readonly renderWidth: number;
  6726. }
  6727. interface VRFieldOfView {
  6728. readonly downDegrees: number;
  6729. readonly leftDegrees: number;
  6730. readonly rightDegrees: number;
  6731. readonly upDegrees: number;
  6732. }
  6733. interface VRFrameData {
  6734. readonly leftProjectionMatrix: Float32Array;
  6735. readonly leftViewMatrix: Float32Array;
  6736. readonly pose: VRPose;
  6737. readonly rightProjectionMatrix: Float32Array;
  6738. readonly rightViewMatrix: Float32Array;
  6739. readonly timestamp: number;
  6740. }
  6741. interface VRPose {
  6742. readonly angularAcceleration: Float32Array | null;
  6743. readonly angularVelocity: Float32Array | null;
  6744. readonly linearAcceleration: Float32Array | null;
  6745. readonly linearVelocity: Float32Array | null;
  6746. readonly orientation: Float32Array | null;
  6747. readonly position: Float32Array | null;
  6748. readonly timestamp: number;
  6749. }
  6750. interface VRStageParameters {
  6751. sittingToStandingTransform?: Float32Array;
  6752. sizeX?: number;
  6753. sizeY?: number;
  6754. }
  6755. interface Navigator {
  6756. getVRDisplays(): Promise<VRDisplay[]>;
  6757. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6758. }
  6759. interface Window {
  6760. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6761. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6762. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6763. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6764. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6765. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6766. }
  6767. interface Gamepad {
  6768. readonly displayId: number;
  6769. }
  6770. declare module BABYLON {
  6771. class BoundingBox implements ICullable {
  6772. vectors: Vector3[];
  6773. center: Vector3;
  6774. centerWorld: Vector3;
  6775. extendSize: Vector3;
  6776. extendSizeWorld: Vector3;
  6777. directions: Vector3[];
  6778. vectorsWorld: Vector3[];
  6779. minimumWorld: Vector3;
  6780. maximumWorld: Vector3;
  6781. minimum: Vector3;
  6782. maximum: Vector3;
  6783. private _worldMatrix;
  6784. /**
  6785. * @hidden
  6786. */
  6787. _tag: number;
  6788. /**
  6789. * Creates a new bounding box
  6790. * @param min defines the minimum vector (in local space)
  6791. * @param max defines the maximum vector (in local space)
  6792. */
  6793. constructor(min: Vector3, max: Vector3);
  6794. /**
  6795. * Recreates the entire bounding box from scratch
  6796. * @param min defines the new minimum vector (in local space)
  6797. * @param max defines the new maximum vector (in local space)
  6798. */
  6799. reConstruct(min: Vector3, max: Vector3): void;
  6800. /**
  6801. * Scale the current bounding box by applying a scale factor
  6802. * @param factor defines the scale factor to apply
  6803. * @returns the current bounding box
  6804. */
  6805. scale(factor: number): BoundingBox;
  6806. getWorldMatrix(): Matrix;
  6807. setWorldMatrix(matrix: Matrix): BoundingBox;
  6808. /** @hidden */
  6809. _update(world: Matrix): void;
  6810. isInFrustum(frustumPlanes: Plane[]): boolean;
  6811. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6812. intersectsPoint(point: Vector3): boolean;
  6813. intersectsSphere(sphere: BoundingSphere): boolean;
  6814. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  6815. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  6816. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  6817. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6818. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6819. }
  6820. }
  6821. declare module BABYLON {
  6822. interface ICullable {
  6823. isInFrustum(frustumPlanes: Plane[]): boolean;
  6824. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6825. }
  6826. class BoundingInfo implements ICullable {
  6827. minimum: Vector3;
  6828. maximum: Vector3;
  6829. boundingBox: BoundingBox;
  6830. boundingSphere: BoundingSphere;
  6831. private _isLocked;
  6832. constructor(minimum: Vector3, maximum: Vector3);
  6833. isLocked: boolean;
  6834. update(world: Matrix): void;
  6835. /**
  6836. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6837. * @param center New center of the bounding info
  6838. * @param extend New extend of the bounding info
  6839. */
  6840. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  6841. /**
  6842. * Scale the current bounding info by applying a scale factor
  6843. * @param factor defines the scale factor to apply
  6844. * @returns the current bounding info
  6845. */
  6846. scale(factor: number): BoundingInfo;
  6847. /**
  6848. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6849. * @param frustumPlanes defines the frustum to test
  6850. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  6851. * @returns true if the bounding info is in the frustum planes
  6852. */
  6853. isInFrustum(frustumPlanes: Plane[], strategy?: number): boolean;
  6854. /**
  6855. * Gets the world distance between the min and max points of the bounding box
  6856. */
  6857. readonly diagonalLength: number;
  6858. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6859. /** @hidden */
  6860. _checkCollision(collider: Collider): boolean;
  6861. intersectsPoint(point: Vector3): boolean;
  6862. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  6863. }
  6864. }
  6865. declare module BABYLON {
  6866. class BoundingSphere {
  6867. center: Vector3;
  6868. radius: number;
  6869. centerWorld: Vector3;
  6870. radiusWorld: number;
  6871. minimum: Vector3;
  6872. maximum: Vector3;
  6873. /**
  6874. * Creates a new bounding sphere
  6875. * @param min defines the minimum vector (in local space)
  6876. * @param max defines the maximum vector (in local space)
  6877. */
  6878. constructor(min: Vector3, max: Vector3);
  6879. /**
  6880. * Recreates the entire bounding sphere from scratch
  6881. * @param min defines the new minimum vector (in local space)
  6882. * @param max defines the new maximum vector (in local space)
  6883. */
  6884. reConstruct(min: Vector3, max: Vector3): void;
  6885. /**
  6886. * Scale the current bounding sphere by applying a scale factor
  6887. * @param factor defines the scale factor to apply
  6888. * @returns the current bounding box
  6889. */
  6890. scale(factor: number): BoundingSphere;
  6891. /** @hidden */
  6892. _update(world: Matrix): void;
  6893. isInFrustum(frustumPlanes: Plane[]): boolean;
  6894. intersectsPoint(point: Vector3): boolean;
  6895. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  6896. }
  6897. }
  6898. declare module BABYLON {
  6899. class Ray {
  6900. origin: Vector3;
  6901. direction: Vector3;
  6902. length: number;
  6903. private _edge1;
  6904. private _edge2;
  6905. private _pvec;
  6906. private _tvec;
  6907. private _qvec;
  6908. private _tmpRay;
  6909. constructor(origin: Vector3, direction: Vector3, length?: number);
  6910. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  6911. intersectsBox(box: BoundingBox): boolean;
  6912. intersectsSphere(sphere: BoundingSphere): boolean;
  6913. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  6914. intersectsPlane(plane: Plane): Nullable<number>;
  6915. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  6916. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  6917. private _comparePickingInfo;
  6918. private static smallnum;
  6919. private static rayl;
  6920. /**
  6921. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  6922. * @param sega the first point of the segment to test the intersection against
  6923. * @param segb the second point of the segment to test the intersection against
  6924. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  6925. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  6926. */
  6927. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  6928. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6929. static Zero(): Ray;
  6930. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6931. /**
  6932. * 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
  6933. * transformed to the given world matrix.
  6934. * @param origin The origin point
  6935. * @param end The end point
  6936. * @param world a matrix to transform the ray to. Default is the identity matrix.
  6937. */
  6938. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  6939. static Transform(ray: Ray, matrix: Matrix): Ray;
  6940. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  6941. }
  6942. }
  6943. declare module BABYLON {
  6944. /**
  6945. * Interface for attribute information associated with buffer instanciation
  6946. */
  6947. class InstancingAttributeInfo {
  6948. /**
  6949. * Index/offset of the attribute in the vertex shader
  6950. */
  6951. index: number;
  6952. /**
  6953. * size of the attribute, 1, 2, 3 or 4
  6954. */
  6955. attributeSize: number;
  6956. /**
  6957. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  6958. * default is FLOAT
  6959. */
  6960. attribyteType: number;
  6961. /**
  6962. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  6963. */
  6964. normalized: boolean;
  6965. /**
  6966. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  6967. */
  6968. offset: number;
  6969. /**
  6970. * Name of the GLSL attribute, for debugging purpose only
  6971. */
  6972. attributeName: string;
  6973. }
  6974. /**
  6975. * Define options used to create a render target texture
  6976. */
  6977. class RenderTargetCreationOptions {
  6978. /**
  6979. * Specifies is mipmaps must be generated
  6980. */
  6981. generateMipMaps?: boolean;
  6982. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6983. generateDepthBuffer?: boolean;
  6984. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6985. generateStencilBuffer?: boolean;
  6986. /** Defines texture type (int by default) */
  6987. type?: number;
  6988. /** Defines sampling mode (trilinear by default) */
  6989. samplingMode?: number;
  6990. /** Defines format (RGBA by default) */
  6991. format?: number;
  6992. }
  6993. /**
  6994. * Define options used to create a depth texture
  6995. */
  6996. class DepthTextureCreationOptions {
  6997. /** Specifies whether or not a stencil should be allocated in the texture */
  6998. generateStencil?: boolean;
  6999. /** Specifies whether or not bilinear filtering is enable on the texture */
  7000. bilinearFiltering?: boolean;
  7001. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7002. comparisonFunction?: number;
  7003. /** Specifies if the created texture is a cube texture */
  7004. isCube?: boolean;
  7005. }
  7006. /**
  7007. * Class used to describe the capabilities of the engine relatively to the current browser
  7008. */
  7009. class EngineCapabilities {
  7010. /** Maximum textures units per fragment shader */
  7011. maxTexturesImageUnits: number;
  7012. /** Maximum texture units per vertex shader */
  7013. maxVertexTextureImageUnits: number;
  7014. /** Maximum textures units in the entire pipeline */
  7015. maxCombinedTexturesImageUnits: number;
  7016. /** Maximum texture size */
  7017. maxTextureSize: number;
  7018. /** Maximum cube texture size */
  7019. maxCubemapTextureSize: number;
  7020. /** Maximum render texture size */
  7021. maxRenderTextureSize: number;
  7022. /** Maximum number of vertex attributes */
  7023. maxVertexAttribs: number;
  7024. /** Maximum number of varyings */
  7025. maxVaryingVectors: number;
  7026. /** Maximum number of uniforms per vertex shader */
  7027. maxVertexUniformVectors: number;
  7028. /** Maximum number of uniforms per fragment shader */
  7029. maxFragmentUniformVectors: number;
  7030. /** Defines if standard derivates (dx/dy) are supported */
  7031. standardDerivatives: boolean;
  7032. /** Defines if s3tc texture compression is supported */
  7033. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  7034. /** Defines if pvrtc texture compression is supported */
  7035. pvrtc: any;
  7036. /** Defines if etc1 texture compression is supported */
  7037. etc1: any;
  7038. /** Defines if etc2 texture compression is supported */
  7039. etc2: any;
  7040. /** Defines if astc texture compression is supported */
  7041. astc: any;
  7042. /** Defines if float textures are supported */
  7043. textureFloat: boolean;
  7044. /** Defines if vertex array objects are supported */
  7045. vertexArrayObject: boolean;
  7046. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  7047. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  7048. /** Gets the maximum level of anisotropy supported */
  7049. maxAnisotropy: number;
  7050. /** Defines if instancing is supported */
  7051. instancedArrays: boolean;
  7052. /** Defines if 32 bits indices are supported */
  7053. uintIndices: boolean;
  7054. /** Defines if high precision shaders are supported */
  7055. highPrecisionShaderSupported: boolean;
  7056. /** Defines if depth reading in the fragment shader is supported */
  7057. fragmentDepthSupported: boolean;
  7058. /** Defines if float texture linear filtering is supported*/
  7059. textureFloatLinearFiltering: boolean;
  7060. /** Defines if rendering to float textures is supported */
  7061. textureFloatRender: boolean;
  7062. /** Defines if half float textures are supported*/
  7063. textureHalfFloat: boolean;
  7064. /** Defines if half float texture linear filtering is supported*/
  7065. textureHalfFloatLinearFiltering: boolean;
  7066. /** Defines if rendering to half float textures is supported */
  7067. textureHalfFloatRender: boolean;
  7068. /** Defines if textureLOD shader command is supported */
  7069. textureLOD: boolean;
  7070. /** Defines if draw buffers extension is supported */
  7071. drawBuffersExtension: boolean;
  7072. /** Defines if depth textures are supported */
  7073. depthTextureExtension: boolean;
  7074. /** Defines if float color buffer are supported */
  7075. colorBufferFloat: boolean;
  7076. /** Gets disjoint timer query extension (null if not supported) */
  7077. timerQuery: EXT_disjoint_timer_query;
  7078. /** Defines if timestamp can be used with timer query */
  7079. canUseTimestampForTimerQuery: boolean;
  7080. }
  7081. /** Interface defining initialization parameters for Engine class */
  7082. interface EngineOptions extends WebGLContextAttributes {
  7083. /**
  7084. * Defines if the engine should no exceed a specified device ratio
  7085. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  7086. */
  7087. limitDeviceRatio?: number;
  7088. /**
  7089. * Defines if webvr should be enabled automatically
  7090. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7091. */
  7092. autoEnableWebVR?: boolean;
  7093. /**
  7094. * Defines if webgl2 should be turned off even if supported
  7095. * @see http://doc.babylonjs.com/features/webgl2
  7096. */
  7097. disableWebGL2Support?: boolean;
  7098. /**
  7099. * Defines if webaudio should be initialized as well
  7100. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7101. */
  7102. audioEngine?: boolean;
  7103. /**
  7104. * Defines if animations should run using a deterministic lock step
  7105. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7106. */
  7107. deterministicLockstep?: boolean;
  7108. /** Defines the maximum steps to use with deterministic lock step mode */
  7109. lockstepMaxSteps?: number;
  7110. /**
  7111. * Defines that engine should ignore context lost events
  7112. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  7113. */
  7114. doNotHandleContextLost?: boolean;
  7115. }
  7116. /**
  7117. * Defines the interface used by display changed events
  7118. */
  7119. interface IDisplayChangedEventArgs {
  7120. /** Gets the vrDisplay object (if any) */
  7121. vrDisplay: Nullable<any>;
  7122. /** Gets a boolean indicating if webVR is supported */
  7123. vrSupported: boolean;
  7124. }
  7125. /**
  7126. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  7127. */
  7128. class Engine {
  7129. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  7130. static ExceptionList: ({
  7131. key: string;
  7132. capture: string;
  7133. captureConstraint: number;
  7134. targets: string[];
  7135. } | {
  7136. key: string;
  7137. capture: null;
  7138. captureConstraint: null;
  7139. targets: string[];
  7140. })[];
  7141. /** Gets the list of created engines */
  7142. static Instances: Engine[];
  7143. /**
  7144. * Gets the latest created engine
  7145. */
  7146. static readonly LastCreatedEngine: Nullable<Engine>;
  7147. /**
  7148. * Gets the latest created scene
  7149. */
  7150. static readonly LastCreatedScene: Nullable<Scene>;
  7151. /**
  7152. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  7153. * @param flag defines which part of the materials must be marked as dirty
  7154. * @param predicate defines a predicate used to filter which materials should be affected
  7155. */
  7156. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  7157. /**
  7158. * Hidden
  7159. */
  7160. static _TextureLoaders: IInternalTextureLoader[];
  7161. /** Defines that alpha blending is disabled */
  7162. static readonly ALPHA_DISABLE: number;
  7163. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  7164. static readonly ALPHA_ADD: number;
  7165. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  7166. static readonly ALPHA_COMBINE: number;
  7167. /** Defines that alpha blending to DEST - SRC * DEST */
  7168. static readonly ALPHA_SUBTRACT: number;
  7169. /** Defines that alpha blending to SRC * DEST */
  7170. static readonly ALPHA_MULTIPLY: number;
  7171. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  7172. static readonly ALPHA_MAXIMIZED: number;
  7173. /** Defines that alpha blending to SRC + DEST */
  7174. static readonly ALPHA_ONEONE: number;
  7175. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  7176. static readonly ALPHA_PREMULTIPLIED: number;
  7177. /**
  7178. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  7179. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  7180. */
  7181. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  7182. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  7183. static readonly ALPHA_INTERPOLATE: number;
  7184. /**
  7185. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  7186. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  7187. */
  7188. static readonly ALPHA_SCREENMODE: number;
  7189. /** Defines that the ressource is not delayed*/
  7190. static readonly DELAYLOADSTATE_NONE: number;
  7191. /** Defines that the ressource was successfully delay loaded */
  7192. static readonly DELAYLOADSTATE_LOADED: number;
  7193. /** Defines that the ressource is currently delay loading */
  7194. static readonly DELAYLOADSTATE_LOADING: number;
  7195. /** Defines that the ressource is delayed and has not started loading */
  7196. static readonly DELAYLOADSTATE_NOTLOADED: number;
  7197. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  7198. static readonly NEVER: number;
  7199. /** 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 */
  7200. static readonly ALWAYS: number;
  7201. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  7202. static readonly LESS: number;
  7203. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  7204. static readonly EQUAL: number;
  7205. /** 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 */
  7206. static readonly LEQUAL: number;
  7207. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  7208. static readonly GREATER: number;
  7209. /** 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 */
  7210. static readonly GEQUAL: number;
  7211. /** 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 */
  7212. static readonly NOTEQUAL: number;
  7213. /** Passed to stencilOperation to specify that stencil value must be kept */
  7214. static readonly KEEP: number;
  7215. /** Passed to stencilOperation to specify that stencil value must be replaced */
  7216. static readonly REPLACE: number;
  7217. /** Passed to stencilOperation to specify that stencil value must be incremented */
  7218. static readonly INCR: number;
  7219. /** Passed to stencilOperation to specify that stencil value must be decremented */
  7220. static readonly DECR: number;
  7221. /** Passed to stencilOperation to specify that stencil value must be inverted */
  7222. static readonly INVERT: number;
  7223. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  7224. static readonly INCR_WRAP: number;
  7225. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  7226. static readonly DECR_WRAP: number;
  7227. /** Texture is not repeating outside of 0..1 UVs */
  7228. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  7229. /** Texture is repeating outside of 0..1 UVs */
  7230. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  7231. /** Texture is repeating and mirrored */
  7232. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  7233. /** ALPHA */
  7234. static readonly TEXTUREFORMAT_ALPHA: number;
  7235. /** LUMINANCE */
  7236. static readonly TEXTUREFORMAT_LUMINANCE: number;
  7237. /** LUMINANCE_ALPHA */
  7238. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  7239. /** RGB */
  7240. static readonly TEXTUREFORMAT_RGB: number;
  7241. /** RGBA */
  7242. static readonly TEXTUREFORMAT_RGBA: number;
  7243. /** RED */
  7244. static readonly TEXTUREFORMAT_RED: number;
  7245. /** RED (2nd reference) */
  7246. static readonly TEXTUREFORMAT_R: number;
  7247. /** RG */
  7248. static readonly TEXTUREFORMAT_RG: number;
  7249. /** RED_INTEGER */
  7250. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  7251. /** RED_INTEGER (2nd reference) */
  7252. static readonly TEXTUREFORMAT_R_INTEGER: number;
  7253. /** RG_INTEGER */
  7254. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  7255. /** RGB_INTEGER */
  7256. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  7257. /** RGBA_INTEGER */
  7258. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  7259. /** UNSIGNED_BYTE */
  7260. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  7261. /** UNSIGNED_BYTE (2nd reference) */
  7262. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  7263. /** FLOAT */
  7264. static readonly TEXTURETYPE_FLOAT: number;
  7265. /** HALF_FLOAT */
  7266. static readonly TEXTURETYPE_HALF_FLOAT: number;
  7267. /** BYTE */
  7268. static readonly TEXTURETYPE_BYTE: number;
  7269. /** SHORT */
  7270. static readonly TEXTURETYPE_SHORT: number;
  7271. /** UNSIGNED_SHORT */
  7272. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  7273. /** INT */
  7274. static readonly TEXTURETYPE_INT: number;
  7275. /** UNSIGNED_INT */
  7276. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  7277. /** UNSIGNED_SHORT_4_4_4_4 */
  7278. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  7279. /** UNSIGNED_SHORT_5_5_5_1 */
  7280. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  7281. /** UNSIGNED_SHORT_5_6_5 */
  7282. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  7283. /** UNSIGNED_INT_2_10_10_10_REV */
  7284. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  7285. /** UNSIGNED_INT_24_8 */
  7286. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  7287. /** UNSIGNED_INT_10F_11F_11F_REV */
  7288. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  7289. /** UNSIGNED_INT_5_9_9_9_REV */
  7290. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  7291. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  7292. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  7293. /** nearest is mag = nearest and min = nearest and mip = linear */
  7294. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  7295. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7296. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  7297. /** Trilinear is mag = linear and min = linear and mip = linear */
  7298. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  7299. /** nearest is mag = nearest and min = nearest and mip = linear */
  7300. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  7301. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7302. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  7303. /** Trilinear is mag = linear and min = linear and mip = linear */
  7304. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  7305. /** mag = nearest and min = nearest and mip = nearest */
  7306. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  7307. /** mag = nearest and min = linear and mip = nearest */
  7308. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  7309. /** mag = nearest and min = linear and mip = linear */
  7310. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  7311. /** mag = nearest and min = linear and mip = none */
  7312. static readonly TEXTURE_NEAREST_LINEAR: number;
  7313. /** mag = nearest and min = nearest and mip = none */
  7314. static readonly TEXTURE_NEAREST_NEAREST: number;
  7315. /** mag = linear and min = nearest and mip = nearest */
  7316. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  7317. /** mag = linear and min = nearest and mip = linear */
  7318. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  7319. /** mag = linear and min = linear and mip = none */
  7320. static readonly TEXTURE_LINEAR_LINEAR: number;
  7321. /** mag = linear and min = nearest and mip = none */
  7322. static readonly TEXTURE_LINEAR_NEAREST: number;
  7323. /** Explicit coordinates mode */
  7324. static readonly TEXTURE_EXPLICIT_MODE: number;
  7325. /** Spherical coordinates mode */
  7326. static readonly TEXTURE_SPHERICAL_MODE: number;
  7327. /** Planar coordinates mode */
  7328. static readonly TEXTURE_PLANAR_MODE: number;
  7329. /** Cubic coordinates mode */
  7330. static readonly TEXTURE_CUBIC_MODE: number;
  7331. /** Projection coordinates mode */
  7332. static readonly TEXTURE_PROJECTION_MODE: number;
  7333. /** Skybox coordinates mode */
  7334. static readonly TEXTURE_SKYBOX_MODE: number;
  7335. /** Inverse Cubic coordinates mode */
  7336. static readonly TEXTURE_INVCUBIC_MODE: number;
  7337. /** Equirectangular coordinates mode */
  7338. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  7339. /** Equirectangular Fixed coordinates mode */
  7340. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  7341. /** Equirectangular Fixed Mirrored coordinates mode */
  7342. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  7343. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  7344. static readonly SCALEMODE_FLOOR: number;
  7345. /** Defines that texture rescaling will look for the nearest power of 2 size */
  7346. static readonly SCALEMODE_NEAREST: number;
  7347. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  7348. static readonly SCALEMODE_CEILING: number;
  7349. /**
  7350. * Returns the current version of the framework
  7351. */
  7352. static readonly Version: string;
  7353. /**
  7354. * Gets or sets the epsilon value used by collision engine
  7355. */
  7356. static CollisionsEpsilon: number;
  7357. /**
  7358. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  7359. */
  7360. static CodeRepository: string;
  7361. /**
  7362. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  7363. */
  7364. static ShadersRepository: string;
  7365. /**
  7366. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  7367. */
  7368. forcePOTTextures: boolean;
  7369. /**
  7370. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  7371. */
  7372. isFullscreen: boolean;
  7373. /**
  7374. * Gets a boolean indicating if the pointer is currently locked
  7375. */
  7376. isPointerLock: boolean;
  7377. /**
  7378. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  7379. */
  7380. cullBackFaces: boolean;
  7381. /**
  7382. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  7383. */
  7384. renderEvenInBackground: boolean;
  7385. /**
  7386. * Gets or sets a boolean indicating that cache can be kept between frames
  7387. */
  7388. preventCacheWipeBetweenFrames: boolean;
  7389. /**
  7390. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7391. **/
  7392. enableOfflineSupport: boolean;
  7393. /**
  7394. * 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)
  7395. **/
  7396. disableManifestCheck: boolean;
  7397. /**
  7398. * Gets the list of created scenes
  7399. */
  7400. scenes: Scene[];
  7401. /**
  7402. * Gets the list of created postprocesses
  7403. */
  7404. postProcesses: PostProcess[];
  7405. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  7406. validateShaderPrograms: boolean;
  7407. /**
  7408. * Observable event triggered each time the rendering canvas is resized
  7409. */
  7410. onResizeObservable: Observable<Engine>;
  7411. /**
  7412. * Observable event triggered each time the canvas loses focus
  7413. */
  7414. onCanvasBlurObservable: Observable<Engine>;
  7415. /**
  7416. * Observable event triggered each time the canvas gains focus
  7417. */
  7418. onCanvasFocusObservable: Observable<Engine>;
  7419. /**
  7420. * Observable event triggered each time the canvas receives pointerout event
  7421. */
  7422. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7423. /**
  7424. * Observable event triggered before each texture is initialized
  7425. */
  7426. onBeforeTextureInitObservable: Observable<Texture>;
  7427. private _vrDisplay;
  7428. private _vrSupported;
  7429. private _oldSize;
  7430. private _oldHardwareScaleFactor;
  7431. private _vrExclusivePointerMode;
  7432. private _webVRInitPromise;
  7433. /**
  7434. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7435. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7436. */
  7437. readonly isInVRExclusivePointerMode: boolean;
  7438. /**
  7439. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7440. */
  7441. disableUniformBuffers: boolean;
  7442. /** @hidden */
  7443. _uniformBuffers: UniformBuffer[];
  7444. /**
  7445. * Gets a boolean indicating that the engine supports uniform buffers
  7446. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7447. */
  7448. readonly supportsUniformBuffers: boolean;
  7449. /**
  7450. * Observable raised when the engine begins a new frame
  7451. */
  7452. onBeginFrameObservable: Observable<Engine>;
  7453. /**
  7454. * Observable raised when the engine ends the current frame
  7455. */
  7456. onEndFrameObservable: Observable<Engine>;
  7457. /**
  7458. * Observable raised when the engine is about to compile a shader
  7459. */
  7460. onBeforeShaderCompilationObservable: Observable<Engine>;
  7461. /**
  7462. * Observable raised when the engine has jsut compiled a shader
  7463. */
  7464. onAfterShaderCompilationObservable: Observable<Engine>;
  7465. /** @hidden */
  7466. _gl: WebGLRenderingContext;
  7467. private _renderingCanvas;
  7468. private _windowIsBackground;
  7469. private _webGLVersion;
  7470. /**
  7471. * Gets a boolean indicating that only power of 2 textures are supported
  7472. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7473. */
  7474. readonly needPOTTextures: boolean;
  7475. /** @hidden */
  7476. _badOS: boolean;
  7477. /** @hidden */
  7478. _badDesktopOS: boolean;
  7479. /**
  7480. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7481. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7482. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7483. */
  7484. disableTextureBindingOptimization: boolean;
  7485. /**
  7486. * Gets the audio engine
  7487. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7488. * @ignorenaming
  7489. */
  7490. static audioEngine: AudioEngine;
  7491. private _onFocus;
  7492. private _onBlur;
  7493. private _onCanvasPointerOut;
  7494. private _onCanvasBlur;
  7495. private _onCanvasFocus;
  7496. private _onFullscreenChange;
  7497. private _onPointerLockChange;
  7498. private _onVRDisplayPointerRestricted;
  7499. private _onVRDisplayPointerUnrestricted;
  7500. private _onVrDisplayConnect;
  7501. private _onVrDisplayDisconnect;
  7502. private _onVrDisplayPresentChange;
  7503. /**
  7504. * Observable signaled when VR display mode changes
  7505. */
  7506. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7507. /**
  7508. * Observable signaled when VR request present is complete
  7509. */
  7510. onVRRequestPresentComplete: Observable<boolean>;
  7511. /**
  7512. * Observable signaled when VR request present starts
  7513. */
  7514. onVRRequestPresentStart: Observable<Engine>;
  7515. private _hardwareScalingLevel;
  7516. /** @hidden */
  7517. protected _caps: EngineCapabilities;
  7518. private _pointerLockRequested;
  7519. private _isStencilEnable;
  7520. private _colorWrite;
  7521. private _loadingScreen;
  7522. /** @hidden */
  7523. _drawCalls: PerfCounter;
  7524. /** @hidden */
  7525. _textureCollisions: PerfCounter;
  7526. private _glVersion;
  7527. private _glRenderer;
  7528. private _glVendor;
  7529. private _videoTextureSupported;
  7530. private _renderingQueueLaunched;
  7531. private _activeRenderLoops;
  7532. private _deterministicLockstep;
  7533. private _lockstepMaxSteps;
  7534. /**
  7535. * Observable signaled when a context lost event is raised
  7536. */
  7537. onContextLostObservable: Observable<Engine>;
  7538. /**
  7539. * Observable signaled when a context restored event is raised
  7540. */
  7541. onContextRestoredObservable: Observable<Engine>;
  7542. private _onContextLost;
  7543. private _onContextRestored;
  7544. private _contextWasLost;
  7545. private _doNotHandleContextLost;
  7546. /**
  7547. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  7548. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  7549. */
  7550. doNotHandleContextLost: boolean;
  7551. private _performanceMonitor;
  7552. private _fps;
  7553. private _deltaTime;
  7554. /**
  7555. * Turn this value on if you want to pause FPS computation when in background
  7556. */
  7557. disablePerformanceMonitorInBackground: boolean;
  7558. /**
  7559. * Gets the performance monitor attached to this engine
  7560. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7561. */
  7562. readonly performanceMonitor: PerformanceMonitor;
  7563. /** @hidden */
  7564. protected _depthCullingState: _DepthCullingState;
  7565. /** @hidden */
  7566. protected _stencilState: _StencilState;
  7567. /** @hidden */
  7568. protected _alphaState: _AlphaState;
  7569. /** @hidden */
  7570. protected _alphaMode: number;
  7571. protected _internalTexturesCache: InternalTexture[];
  7572. /** @hidden */
  7573. protected _activeChannel: number;
  7574. private _currentTextureChannel;
  7575. /** @hidden */
  7576. protected _boundTexturesCache: {
  7577. [key: string]: Nullable<InternalTexture>;
  7578. };
  7579. /** @hidden */
  7580. protected _currentEffect: Nullable<Effect>;
  7581. /** @hidden */
  7582. protected _currentProgram: Nullable<WebGLProgram>;
  7583. private _compiledEffects;
  7584. private _vertexAttribArraysEnabled;
  7585. /** @hidden */
  7586. protected _cachedViewport: Nullable<Viewport>;
  7587. private _cachedVertexArrayObject;
  7588. /** @hidden */
  7589. protected _cachedVertexBuffers: any;
  7590. /** @hidden */
  7591. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7592. /** @hidden */
  7593. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7594. /** @hidden */
  7595. protected _currentRenderTarget: Nullable<InternalTexture>;
  7596. private _uintIndicesCurrentlySet;
  7597. private _currentBoundBuffer;
  7598. /** @hidden */
  7599. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7600. private _currentBufferPointers;
  7601. private _currentInstanceLocations;
  7602. private _currentInstanceBuffers;
  7603. private _textureUnits;
  7604. private _firstBoundInternalTextureTracker;
  7605. private _lastBoundInternalTextureTracker;
  7606. private _workingCanvas;
  7607. private _workingContext;
  7608. private _rescalePostProcess;
  7609. private _dummyFramebuffer;
  7610. private _externalData;
  7611. private _bindedRenderFunction;
  7612. private _vaoRecordInProgress;
  7613. private _mustWipeVertexAttributes;
  7614. private _emptyTexture;
  7615. private _emptyCubeTexture;
  7616. private _emptyTexture3D;
  7617. private _frameHandler;
  7618. private _nextFreeTextureSlots;
  7619. private _maxSimultaneousTextures;
  7620. private _activeRequests;
  7621. private _texturesSupported;
  7622. private _textureFormatInUse;
  7623. /**
  7624. * Gets the list of texture formats supported
  7625. */
  7626. readonly texturesSupported: Array<string>;
  7627. /**
  7628. * Gets the list of texture formats in use
  7629. */
  7630. readonly textureFormatInUse: Nullable<string>;
  7631. /**
  7632. * Gets the current viewport
  7633. */
  7634. readonly currentViewport: Nullable<Viewport>;
  7635. /**
  7636. * Gets the default empty texture
  7637. */
  7638. readonly emptyTexture: InternalTexture;
  7639. /**
  7640. * Gets the default empty 3D texture
  7641. */
  7642. readonly emptyTexture3D: InternalTexture;
  7643. /**
  7644. * Gets the default empty cube texture
  7645. */
  7646. readonly emptyCubeTexture: InternalTexture;
  7647. /**
  7648. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  7649. */
  7650. readonly premultipliedAlpha: boolean;
  7651. /**
  7652. * Creates a new engine
  7653. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  7654. * @param antialias defines enable antialiasing (default: false)
  7655. * @param options defines further options to be sent to the getContext() function
  7656. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7657. */
  7658. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7659. private _rebuildInternalTextures;
  7660. private _rebuildEffects;
  7661. private _rebuildBuffers;
  7662. private _initGLContext;
  7663. /**
  7664. * Gets version of the current webGL context
  7665. */
  7666. readonly webGLVersion: number;
  7667. /**
  7668. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7669. */
  7670. readonly isStencilEnable: boolean;
  7671. private _prepareWorkingCanvas;
  7672. /**
  7673. * Reset the texture cache to empty state
  7674. */
  7675. resetTextureCache(): void;
  7676. /**
  7677. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7678. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7679. * @returns true if engine is in deterministic lock step mode
  7680. */
  7681. isDeterministicLockStep(): boolean;
  7682. /**
  7683. * Gets the max steps when engine is running in deterministic lock step
  7684. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7685. * @returns the max steps
  7686. */
  7687. getLockstepMaxSteps(): number;
  7688. /**
  7689. * Gets an object containing information about the current webGL context
  7690. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7691. */
  7692. getGlInfo(): {
  7693. vendor: string;
  7694. renderer: string;
  7695. version: string;
  7696. };
  7697. /**
  7698. * Gets current aspect ratio
  7699. * @param camera defines the camera to use to get the aspect ratio
  7700. * @param useScreen defines if screen size must be used (or the current render target if any)
  7701. * @returns a number defining the aspect ratio
  7702. */
  7703. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7704. /**
  7705. * Gets current screen aspect ratio
  7706. * @returns a number defining the aspect ratio
  7707. */
  7708. getScreenAspectRatio(): number;
  7709. /**
  7710. * Gets the current render width
  7711. * @param useScreen defines if screen size must be used (or the current render target if any)
  7712. * @returns a number defining the current render width
  7713. */
  7714. getRenderWidth(useScreen?: boolean): number;
  7715. /**
  7716. * Gets the current render height
  7717. * @param useScreen defines if screen size must be used (or the current render target if any)
  7718. * @returns a number defining the current render height
  7719. */
  7720. getRenderHeight(useScreen?: boolean): number;
  7721. /**
  7722. * Gets the HTML canvas attached with the current webGL context
  7723. * @returns a HTML canvas
  7724. */
  7725. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7726. /**
  7727. * Gets the client rect of the HTML canvas attached with the current webGL context
  7728. * @returns a client rectanglee
  7729. */
  7730. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7731. /**
  7732. * Defines the hardware scaling level.
  7733. * By default the hardware scaling level is computed from the window device ratio.
  7734. * 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.
  7735. * @param level defines the level to use
  7736. */
  7737. setHardwareScalingLevel(level: number): void;
  7738. /**
  7739. * Gets the current hardware scaling level.
  7740. * By default the hardware scaling level is computed from the window device ratio.
  7741. * 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.
  7742. * @returns a number indicating the current hardware scaling level
  7743. */
  7744. getHardwareScalingLevel(): number;
  7745. /**
  7746. * Gets the list of loaded textures
  7747. * @returns an array containing all loaded textures
  7748. */
  7749. getLoadedTexturesCache(): InternalTexture[];
  7750. /**
  7751. * Gets the object containing all engine capabilities
  7752. * @returns the EngineCapabilities object
  7753. */
  7754. getCaps(): EngineCapabilities;
  7755. /** @hidden */
  7756. readonly drawCalls: number;
  7757. /** @hidden */
  7758. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  7759. /**
  7760. * Gets the current depth function
  7761. * @returns a number defining the depth function
  7762. */
  7763. getDepthFunction(): Nullable<number>;
  7764. /**
  7765. * Sets the current depth function
  7766. * @param depthFunc defines the function to use
  7767. */
  7768. setDepthFunction(depthFunc: number): void;
  7769. /**
  7770. * Sets the current depth function to GREATER
  7771. */
  7772. setDepthFunctionToGreater(): void;
  7773. /**
  7774. * Sets the current depth function to GEQUAL
  7775. */
  7776. setDepthFunctionToGreaterOrEqual(): void;
  7777. /**
  7778. * Sets the current depth function to LESS
  7779. */
  7780. setDepthFunctionToLess(): void;
  7781. /**
  7782. * Sets the current depth function to LEQUAL
  7783. */
  7784. setDepthFunctionToLessOrEqual(): void;
  7785. /**
  7786. * Gets a boolean indicating if stencil buffer is enabled
  7787. * @returns the current stencil buffer state
  7788. */
  7789. getStencilBuffer(): boolean;
  7790. /**
  7791. * Enable or disable the stencil buffer
  7792. * @param enable defines if the stencil buffer must be enabled or disabled
  7793. */
  7794. setStencilBuffer(enable: boolean): void;
  7795. /**
  7796. * Gets the current stencil mask
  7797. * @returns a number defining the new stencil mask to use
  7798. */
  7799. getStencilMask(): number;
  7800. /**
  7801. * Sets the current stencil mask
  7802. * @param mask defines the new stencil mask to use
  7803. */
  7804. setStencilMask(mask: number): void;
  7805. /**
  7806. * Gets the current stencil function
  7807. * @returns a number defining the stencil function to use
  7808. */
  7809. getStencilFunction(): number;
  7810. /**
  7811. * Gets the current stencil reference value
  7812. * @returns a number defining the stencil reference value to use
  7813. */
  7814. getStencilFunctionReference(): number;
  7815. /**
  7816. * Gets the current stencil mask
  7817. * @returns a number defining the stencil mask to use
  7818. */
  7819. getStencilFunctionMask(): number;
  7820. /**
  7821. * Sets the current stencil function
  7822. * @param stencilFunc defines the new stencil function to use
  7823. */
  7824. setStencilFunction(stencilFunc: number): void;
  7825. /**
  7826. * Sets the current stencil reference
  7827. * @param reference defines the new stencil reference to use
  7828. */
  7829. setStencilFunctionReference(reference: number): void;
  7830. /**
  7831. * Sets the current stencil mask
  7832. * @param mask defines the new stencil mask to use
  7833. */
  7834. setStencilFunctionMask(mask: number): void;
  7835. /**
  7836. * Gets the current stencil operation when stencil fails
  7837. * @returns a number defining stencil operation to use when stencil fails
  7838. */
  7839. getStencilOperationFail(): number;
  7840. /**
  7841. * Gets the current stencil operation when depth fails
  7842. * @returns a number defining stencil operation to use when depth fails
  7843. */
  7844. getStencilOperationDepthFail(): number;
  7845. /**
  7846. * Gets the current stencil operation when stencil passes
  7847. * @returns a number defining stencil operation to use when stencil passes
  7848. */
  7849. getStencilOperationPass(): number;
  7850. /**
  7851. * Sets the stencil operation to use when stencil fails
  7852. * @param operation defines the stencil operation to use when stencil fails
  7853. */
  7854. setStencilOperationFail(operation: number): void;
  7855. /**
  7856. * Sets the stencil operation to use when depth fails
  7857. * @param operation defines the stencil operation to use when depth fails
  7858. */
  7859. setStencilOperationDepthFail(operation: number): void;
  7860. /**
  7861. * Sets the stencil operation to use when stencil passes
  7862. * @param operation defines the stencil operation to use when stencil passes
  7863. */
  7864. setStencilOperationPass(operation: number): void;
  7865. /**
  7866. * Sets a boolean indicating if the dithering state is enabled or disabled
  7867. * @param value defines the dithering state
  7868. */
  7869. setDitheringState(value: boolean): void;
  7870. /**
  7871. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  7872. * @param value defines the rasterizer state
  7873. */
  7874. setRasterizerState(value: boolean): void;
  7875. /**
  7876. * stop executing a render loop function and remove it from the execution array
  7877. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  7878. */
  7879. stopRenderLoop(renderFunction?: () => void): void;
  7880. /** @hidden */
  7881. _renderLoop(): void;
  7882. /**
  7883. * Register and execute a render loop. The engine can have more than one render function
  7884. * @param renderFunction defines the function to continuously execute
  7885. */
  7886. runRenderLoop(renderFunction: () => void): void;
  7887. /**
  7888. * Toggle full screen mode
  7889. * @param requestPointerLock defines if a pointer lock should be requested from the user
  7890. * @param options defines an option object to be sent to the requestFullscreen function
  7891. */
  7892. switchFullscreen(requestPointerLock: boolean): void;
  7893. /**
  7894. * Clear the current render buffer or the current render target (if any is set up)
  7895. * @param color defines the color to use
  7896. * @param backBuffer defines if the back buffer must be cleared
  7897. * @param depth defines if the depth buffer must be cleared
  7898. * @param stencil defines if the stencil buffer must be cleared
  7899. */
  7900. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  7901. /**
  7902. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  7903. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  7904. * @param y defines the y-coordinate of the corner of the clear rectangle
  7905. * @param width defines the width of the clear rectangle
  7906. * @param height defines the height of the clear rectangle
  7907. * @param clearColor defines the clear color
  7908. */
  7909. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  7910. private _viewportCached;
  7911. /** @hidden */
  7912. _viewport(x: number, y: number, width: number, height: number): void;
  7913. /**
  7914. * Set the WebGL's viewport
  7915. * @param viewport defines the viewport element to be used
  7916. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  7917. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  7918. */
  7919. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  7920. /**
  7921. * Directly set the WebGL Viewport
  7922. * @param x defines the x coordinate of the viewport (in screen space)
  7923. * @param y defines the y coordinate of the viewport (in screen space)
  7924. * @param width defines the width of the viewport (in screen space)
  7925. * @param height defines the height of the viewport (in screen space)
  7926. * @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
  7927. */
  7928. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  7929. /**
  7930. * Begin a new frame
  7931. */
  7932. beginFrame(): void;
  7933. /**
  7934. * Enf the current frame
  7935. */
  7936. endFrame(): void;
  7937. /**
  7938. * Resize the view according to the canvas' size
  7939. */
  7940. resize(): void;
  7941. /**
  7942. * Force a specific size of the canvas
  7943. * @param width defines the new canvas' width
  7944. * @param height defines the new canvas' height
  7945. */
  7946. setSize(width: number, height: number): void;
  7947. /**
  7948. * Gets a boolean indicating if a webVR device was detected
  7949. * @returns true if a webVR device was detected
  7950. */
  7951. isVRDevicePresent(): boolean;
  7952. /**
  7953. * Gets the current webVR device
  7954. * @returns the current webVR device (or null)
  7955. */
  7956. getVRDevice(): any;
  7957. /**
  7958. * Initializes a webVR display and starts listening to display change events
  7959. * The onVRDisplayChangedObservable will be notified upon these changes
  7960. * @returns The onVRDisplayChangedObservable
  7961. */
  7962. initWebVR(): Observable<IDisplayChangedEventArgs>;
  7963. /**
  7964. * Initializes a webVR display and starts listening to display change events
  7965. * The onVRDisplayChangedObservable will be notified upon these changes
  7966. * @returns A promise containing a VRDisplay and if vr is supported
  7967. */
  7968. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  7969. /**
  7970. * Call this function to switch to webVR mode
  7971. * Will do nothing if webVR is not supported or if there is no webVR device
  7972. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7973. */
  7974. enableVR(): void;
  7975. /**
  7976. * Call this function to leave webVR mode
  7977. * Will do nothing if webVR is not supported or if there is no webVR device
  7978. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7979. */
  7980. disableVR(): void;
  7981. private _onVRFullScreenTriggered;
  7982. private _getVRDisplaysAsync;
  7983. /**
  7984. * Binds the frame buffer to the specified texture.
  7985. * @param texture The texture to render to or null for the default canvas
  7986. * @param faceIndex The face of the texture to render to in case of cube texture
  7987. * @param requiredWidth The width of the target to render to
  7988. * @param requiredHeight The height of the target to render to
  7989. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  7990. * @param depthStencilTexture The depth stencil texture to use to render
  7991. * @param lodLevel defines le lod level to bind to the frame buffer
  7992. */
  7993. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  7994. private bindUnboundFramebuffer;
  7995. /**
  7996. * Unbind the current render target texture from the webGL context
  7997. * @param texture defines the render target texture to unbind
  7998. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7999. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8000. */
  8001. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8002. /**
  8003. * Unbind a list of render target textures from the webGL context
  8004. * This is used only when drawBuffer extension or webGL2 are active
  8005. * @param textures defines the render target textures to unbind
  8006. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8007. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8008. */
  8009. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8010. /**
  8011. * Force the mipmap generation for the given render target texture
  8012. * @param texture defines the render target texture to use
  8013. */
  8014. generateMipMapsForCubemap(texture: InternalTexture): void;
  8015. /**
  8016. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  8017. */
  8018. flushFramebuffer(): void;
  8019. /**
  8020. * Unbind the current render target and bind the default framebuffer
  8021. */
  8022. restoreDefaultFramebuffer(): void;
  8023. /**
  8024. * Create an uniform buffer
  8025. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8026. * @param elements defines the content of the uniform buffer
  8027. * @returns the webGL uniform buffer
  8028. */
  8029. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  8030. /**
  8031. * Create a dynamic uniform buffer
  8032. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8033. * @param elements defines the content of the uniform buffer
  8034. * @returns the webGL uniform buffer
  8035. */
  8036. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  8037. /**
  8038. * Update an existing uniform buffer
  8039. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8040. * @param uniformBuffer defines the target uniform buffer
  8041. * @param elements defines the content to update
  8042. * @param offset defines the offset in the uniform buffer where update should start
  8043. * @param count defines the size of the data to update
  8044. */
  8045. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8046. private _resetVertexBufferBinding;
  8047. /**
  8048. * Creates a vertex buffer
  8049. * @param data the data for the vertex buffer
  8050. * @returns the new WebGL static buffer
  8051. */
  8052. createVertexBuffer(data: DataArray): WebGLBuffer;
  8053. /**
  8054. * Creates a dynamic vertex buffer
  8055. * @param data the data for the dynamic vertex buffer
  8056. * @returns the new WebGL dynamic buffer
  8057. */
  8058. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  8059. /**
  8060. * Update a dynamic index buffer
  8061. * @param indexBuffer defines the target index buffer
  8062. * @param indices defines the data to update
  8063. * @param offset defines the offset in the target index buffer where update should start
  8064. */
  8065. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8066. /**
  8067. * Updates a dynamic vertex buffer.
  8068. * @param vertexBuffer the vertex buffer to update
  8069. * @param data the data used to update the vertex buffer
  8070. * @param byteOffset the byte offset of the data
  8071. * @param byteLength the byte length of the data
  8072. */
  8073. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  8074. private _resetIndexBufferBinding;
  8075. /**
  8076. * Creates a new index buffer
  8077. * @param indices defines the content of the index buffer
  8078. * @param updatable defines if the index buffer must be updatable
  8079. * @returns a new webGL buffer
  8080. */
  8081. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  8082. /**
  8083. * Bind a webGL buffer to the webGL context
  8084. * @param buffer defines the buffer to bind
  8085. */
  8086. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  8087. /**
  8088. * Bind an uniform buffer to the current webGL context
  8089. * @param buffer defines the buffer to bind
  8090. */
  8091. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  8092. /**
  8093. * Bind a buffer to the current webGL context at a given location
  8094. * @param buffer defines the buffer to bind
  8095. * @param location defines the index where to bind the buffer
  8096. */
  8097. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  8098. /**
  8099. * Bind a specific block at a given index in a specific shader program
  8100. * @param shaderProgram defines the shader program
  8101. * @param blockName defines the block name
  8102. * @param index defines the index where to bind the block
  8103. */
  8104. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  8105. private bindIndexBuffer;
  8106. private bindBuffer;
  8107. /**
  8108. * update the bound buffer with the given data
  8109. * @param data defines the data to update
  8110. */
  8111. updateArrayBuffer(data: Float32Array): void;
  8112. private _vertexAttribPointer;
  8113. private _bindIndexBufferWithCache;
  8114. private _bindVertexBuffersAttributes;
  8115. /**
  8116. * Records a vertex array object
  8117. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8118. * @param vertexBuffers defines the list of vertex buffers to store
  8119. * @param indexBuffer defines the index buffer to store
  8120. * @param effect defines the effect to store
  8121. * @returns the new vertex array object
  8122. */
  8123. recordVertexArrayObject(vertexBuffers: {
  8124. [key: string]: VertexBuffer;
  8125. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  8126. /**
  8127. * Bind a specific vertex array object
  8128. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8129. * @param vertexArrayObject defines the vertex array object to bind
  8130. * @param indexBuffer defines the index buffer to bind
  8131. */
  8132. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  8133. /**
  8134. * Bind webGl buffers directly to the webGL context
  8135. * @param vertexBuffer defines the vertex buffer to bind
  8136. * @param indexBuffer defines the index buffer to bind
  8137. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  8138. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  8139. * @param effect defines the effect associated with the vertex buffer
  8140. */
  8141. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  8142. private _unbindVertexArrayObject;
  8143. /**
  8144. * Bind a list of vertex buffers to the webGL context
  8145. * @param vertexBuffers defines the list of vertex buffers to bind
  8146. * @param indexBuffer defines the index buffer to bind
  8147. * @param effect defines the effect associated with the vertex buffers
  8148. */
  8149. bindBuffers(vertexBuffers: {
  8150. [key: string]: Nullable<VertexBuffer>;
  8151. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  8152. /**
  8153. * Unbind all instance attributes
  8154. */
  8155. unbindInstanceAttributes(): void;
  8156. /**
  8157. * Release and free the memory of a vertex array object
  8158. * @param vao defines the vertex array object to delete
  8159. */
  8160. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  8161. /** @hidden */
  8162. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8163. /**
  8164. * Creates a webGL buffer to use with instanciation
  8165. * @param capacity defines the size of the buffer
  8166. * @returns the webGL buffer
  8167. */
  8168. createInstancesBuffer(capacity: number): WebGLBuffer;
  8169. /**
  8170. * Delete a webGL buffer used with instanciation
  8171. * @param buffer defines the webGL buffer to delete
  8172. */
  8173. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  8174. /**
  8175. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  8176. * @param instancesBuffer defines the webGL buffer to update and bind
  8177. * @param data defines the data to store in the buffer
  8178. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  8179. */
  8180. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  8181. /**
  8182. * Apply all cached states (depth, culling, stencil and alpha)
  8183. */
  8184. applyStates(): void;
  8185. /**
  8186. * Send a draw order
  8187. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8188. * @param indexStart defines the starting index
  8189. * @param indexCount defines the number of index to draw
  8190. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8191. */
  8192. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8193. /**
  8194. * Draw a list of points
  8195. * @param verticesStart defines the index of first vertex to draw
  8196. * @param verticesCount defines the count of vertices to draw
  8197. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8198. */
  8199. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8200. /**
  8201. * Draw a list of unindexed primitives
  8202. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8203. * @param verticesStart defines the index of first vertex to draw
  8204. * @param verticesCount defines the count of vertices to draw
  8205. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8206. */
  8207. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8208. /**
  8209. * Draw a list of indexed primitives
  8210. * @param fillMode defines the primitive to use
  8211. * @param indexStart defines the starting index
  8212. * @param indexCount defines the number of index to draw
  8213. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8214. */
  8215. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8216. /**
  8217. * Draw a list of unindexed primitives
  8218. * @param fillMode defines the primitive to use
  8219. * @param verticesStart defines the index of first vertex to draw
  8220. * @param verticesCount defines the count of vertices to draw
  8221. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8222. */
  8223. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8224. private _drawMode;
  8225. /** @hidden */
  8226. _releaseEffect(effect: Effect): void;
  8227. /** @hidden */
  8228. _deleteProgram(program: WebGLProgram): void;
  8229. /**
  8230. * Create a new effect (used to store vertex/fragment shaders)
  8231. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  8232. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  8233. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  8234. * @param samplers defines an array of string used to represent textures
  8235. * @param defines defines the string containing the defines to use to compile the shaders
  8236. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8237. * @param onCompiled defines a function to call when the effect creation is successful
  8238. * @param onError defines a function to call when the effect creation has failed
  8239. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  8240. * @returns the new Effect
  8241. */
  8242. 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;
  8243. private _compileShader;
  8244. private _compileRawShader;
  8245. /**
  8246. * Directly creates a webGL program
  8247. * @param vertexCode defines the vertex shader code to use
  8248. * @param fragmentCode defines the fragment shader code to use
  8249. * @param context defines the webGL context to use (if not set, the current one will be used)
  8250. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8251. * @returns the new webGL program
  8252. */
  8253. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8254. /**
  8255. * Creates a webGL program
  8256. * @param vertexCode defines the vertex shader code to use
  8257. * @param fragmentCode defines the fragment shader code to use
  8258. * @param defines defines the string containing the defines to use to compile the shaders
  8259. * @param context defines the webGL context to use (if not set, the current one will be used)
  8260. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8261. * @returns the new webGL program
  8262. */
  8263. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8264. private _createShaderProgram;
  8265. /**
  8266. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  8267. * @param shaderProgram defines the webGL program to use
  8268. * @param uniformsNames defines the list of uniform names
  8269. * @returns an array of webGL uniform locations
  8270. */
  8271. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  8272. /**
  8273. * Gets the lsit of active attributes for a given webGL program
  8274. * @param shaderProgram defines the webGL program to use
  8275. * @param attributesNames defines the list of attribute names to get
  8276. * @returns an array of indices indicating the offset of each attribute
  8277. */
  8278. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8279. /**
  8280. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  8281. * @param effect defines the effect to activate
  8282. */
  8283. enableEffect(effect: Nullable<Effect>): void;
  8284. /**
  8285. * Set the value of an uniform to an array of int32
  8286. * @param uniform defines the webGL uniform location where to store the value
  8287. * @param array defines the array of int32 to store
  8288. */
  8289. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8290. /**
  8291. * Set the value of an uniform to an array of int32 (stored as vec2)
  8292. * @param uniform defines the webGL uniform location where to store the value
  8293. * @param array defines the array of int32 to store
  8294. */
  8295. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8296. /**
  8297. * Set the value of an uniform to an array of int32 (stored as vec3)
  8298. * @param uniform defines the webGL uniform location where to store the value
  8299. * @param array defines the array of int32 to store
  8300. */
  8301. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8302. /**
  8303. * Set the value of an uniform to an array of int32 (stored as vec4)
  8304. * @param uniform defines the webGL uniform location where to store the value
  8305. * @param array defines the array of int32 to store
  8306. */
  8307. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8308. /**
  8309. * Set the value of an uniform to an array of float32
  8310. * @param uniform defines the webGL uniform location where to store the value
  8311. * @param array defines the array of float32 to store
  8312. */
  8313. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8314. /**
  8315. * Set the value of an uniform to an array of float32 (stored as vec2)
  8316. * @param uniform defines the webGL uniform location where to store the value
  8317. * @param array defines the array of float32 to store
  8318. */
  8319. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8320. /**
  8321. * Set the value of an uniform to an array of float32 (stored as vec3)
  8322. * @param uniform defines the webGL uniform location where to store the value
  8323. * @param array defines the array of float32 to store
  8324. */
  8325. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8326. /**
  8327. * Set the value of an uniform to an array of float32 (stored as vec4)
  8328. * @param uniform defines the webGL uniform location where to store the value
  8329. * @param array defines the array of float32 to store
  8330. */
  8331. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8332. /**
  8333. * Set the value of an uniform to an array of number
  8334. * @param uniform defines the webGL uniform location where to store the value
  8335. * @param array defines the array of number to store
  8336. */
  8337. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8338. /**
  8339. * Set the value of an uniform to an array of number (stored as vec2)
  8340. * @param uniform defines the webGL uniform location where to store the value
  8341. * @param array defines the array of number to store
  8342. */
  8343. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8344. /**
  8345. * Set the value of an uniform to an array of number (stored as vec3)
  8346. * @param uniform defines the webGL uniform location where to store the value
  8347. * @param array defines the array of number to store
  8348. */
  8349. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8350. /**
  8351. * Set the value of an uniform to an array of number (stored as vec4)
  8352. * @param uniform defines the webGL uniform location where to store the value
  8353. * @param array defines the array of number to store
  8354. */
  8355. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8356. /**
  8357. * Set the value of an uniform to an array of float32 (stored as matrices)
  8358. * @param uniform defines the webGL uniform location where to store the value
  8359. * @param matrices defines the array of float32 to store
  8360. */
  8361. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  8362. /**
  8363. * Set the value of an uniform to a matrix
  8364. * @param uniform defines the webGL uniform location where to store the value
  8365. * @param matrix defines the matrix to store
  8366. */
  8367. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  8368. /**
  8369. * Set the value of an uniform to a matrix (3x3)
  8370. * @param uniform defines the webGL uniform location where to store the value
  8371. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  8372. */
  8373. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8374. /**
  8375. * Set the value of an uniform to a matrix (2x2)
  8376. * @param uniform defines the webGL uniform location where to store the value
  8377. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  8378. */
  8379. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8380. /**
  8381. * Set the value of an uniform to a number (int)
  8382. * @param uniform defines the webGL uniform location where to store the value
  8383. * @param value defines the int number to store
  8384. */
  8385. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8386. /**
  8387. * Set the value of an uniform to a number (float)
  8388. * @param uniform defines the webGL uniform location where to store the value
  8389. * @param value defines the float number to store
  8390. */
  8391. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8392. /**
  8393. * Set the value of an uniform to a vec2
  8394. * @param uniform defines the webGL uniform location where to store the value
  8395. * @param x defines the 1st component of the value
  8396. * @param y defines the 2nd component of the value
  8397. */
  8398. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8399. /**
  8400. * Set the value of an uniform to a vec3
  8401. * @param uniform defines the webGL uniform location where to store the value
  8402. * @param x defines the 1st component of the value
  8403. * @param y defines the 2nd component of the value
  8404. * @param z defines the 3rd component of the value
  8405. */
  8406. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8407. /**
  8408. * Set the value of an uniform to a boolean
  8409. * @param uniform defines the webGL uniform location where to store the value
  8410. * @param bool defines the boolean to store
  8411. */
  8412. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8413. /**
  8414. * Set the value of an uniform to a vec4
  8415. * @param uniform defines the webGL uniform location where to store the value
  8416. * @param x defines the 1st component of the value
  8417. * @param y defines the 2nd component of the value
  8418. * @param z defines the 3rd component of the value
  8419. * @param w defines the 4th component of the value
  8420. */
  8421. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8422. /**
  8423. * Set the value of an uniform to a Color3
  8424. * @param uniform defines the webGL uniform location where to store the value
  8425. * @param color3 defines the color to store
  8426. */
  8427. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8428. /**
  8429. * Set the value of an uniform to a Color3 and an alpha value
  8430. * @param uniform defines the webGL uniform location where to store the value
  8431. * @param color3 defines the color to store
  8432. * @param alpha defines the alpha component to store
  8433. */
  8434. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8435. /**
  8436. * Sets a Color4 on a uniform variable
  8437. * @param uniform defines the uniform location
  8438. * @param color4 defines the value to be set
  8439. */
  8440. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8441. /**
  8442. * Set various states to the webGL context
  8443. * @param culling defines backface culling state
  8444. * @param zOffset defines the value to apply to zOffset (0 by default)
  8445. * @param force defines if states must be applied even if cache is up to date
  8446. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8447. */
  8448. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8449. /**
  8450. * Set the z offset to apply to current rendering
  8451. * @param value defines the offset to apply
  8452. */
  8453. setZOffset(value: number): void;
  8454. /**
  8455. * Gets the current value of the zOffset
  8456. * @returns the current zOffset state
  8457. */
  8458. getZOffset(): number;
  8459. /**
  8460. * Enable or disable depth buffering
  8461. * @param enable defines the state to set
  8462. */
  8463. setDepthBuffer(enable: boolean): void;
  8464. /**
  8465. * Gets a boolean indicating if depth writing is enabled
  8466. * @returns the current depth writing state
  8467. */
  8468. getDepthWrite(): boolean;
  8469. /**
  8470. * Enable or disable depth writing
  8471. * @param enable defines the state to set
  8472. */
  8473. setDepthWrite(enable: boolean): void;
  8474. /**
  8475. * Enable or disable color writing
  8476. * @param enable defines the state to set
  8477. */
  8478. setColorWrite(enable: boolean): void;
  8479. /**
  8480. * Gets a boolean indicating if color writing is enabled
  8481. * @returns the current color writing state
  8482. */
  8483. getColorWrite(): boolean;
  8484. /**
  8485. * Sets alpha constants used by some alpha blending modes
  8486. * @param r defines the red component
  8487. * @param g defines the green component
  8488. * @param b defines the blue component
  8489. * @param a defines the alpha component
  8490. */
  8491. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8492. /**
  8493. * Sets the current alpha mode
  8494. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8495. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8496. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8497. */
  8498. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8499. /**
  8500. * Gets the current alpha mode
  8501. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8502. * @returns the current alpha mode
  8503. */
  8504. getAlphaMode(): number;
  8505. /**
  8506. * Clears the list of texture accessible through engine.
  8507. * This can help preventing texture load conflict due to name collision.
  8508. */
  8509. clearInternalTexturesCache(): void;
  8510. /**
  8511. * Force the entire cache to be cleared
  8512. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8513. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8514. */
  8515. wipeCaches(bruteForce?: boolean): void;
  8516. /**
  8517. * Set the compressed texture format to use, based on the formats you have, and the formats
  8518. * supported by the hardware / browser.
  8519. *
  8520. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8521. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8522. * to API arguments needed to compressed textures. This puts the burden on the container
  8523. * generator to house the arcane code for determining these for current & future formats.
  8524. *
  8525. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8526. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8527. *
  8528. * Note: The result of this call is not taken into account when a texture is base64.
  8529. *
  8530. * @param formatsAvailable defines the list of those format families you have created
  8531. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8532. *
  8533. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8534. * @returns The extension selected.
  8535. */
  8536. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8537. private _getSamplingParameters;
  8538. private _partialLoadImg;
  8539. private _cascadeLoadImgs;
  8540. /** @hidden */
  8541. _createTexture(): WebGLTexture;
  8542. /**
  8543. * Usually called from BABYLON.Texture.ts.
  8544. * Passed information to create a WebGLTexture
  8545. * @param urlArg defines a value which contains one of the following:
  8546. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8547. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8548. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8549. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8550. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8551. * @param scene needed for loading to the correct scene
  8552. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8553. * @param onLoad optional callback to be called upon successful completion
  8554. * @param onError optional callback to be called upon failure
  8555. * @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
  8556. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8557. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8558. * @param forcedExtension defines the extension to use to pick the right loader
  8559. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8560. */
  8561. 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;
  8562. private _rescaleTexture;
  8563. /**
  8564. * Update a raw texture
  8565. * @param texture defines the texture to update
  8566. * @param data defines the data to store in the texture
  8567. * @param format defines the format of the data
  8568. * @param invertY defines if data must be stored with Y axis inverted
  8569. * @param compression defines the compression used (null by default)
  8570. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8571. */
  8572. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8573. /**
  8574. * Creates a raw texture
  8575. * @param data defines the data to store in the texture
  8576. * @param width defines the width of the texture
  8577. * @param height defines the height of the texture
  8578. * @param format defines the format of the data
  8579. * @param generateMipMaps defines if the engine should generate the mip levels
  8580. * @param invertY defines if data must be stored with Y axis inverted
  8581. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8582. * @param compression defines the compression used (null by default)
  8583. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8584. * @returns the raw texture inside an InternalTexture
  8585. */
  8586. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8587. private _unpackFlipYCached;
  8588. /**
  8589. * In case you are sharing the context with other applications, it might
  8590. * be interested to not cache the unpack flip y state to ensure a consistent
  8591. * value would be set.
  8592. */
  8593. enableUnpackFlipYCached: boolean;
  8594. /** @hidden */
  8595. _unpackFlipY(value: boolean): void;
  8596. /** @hidden */
  8597. _getUnpackAlignement(): number;
  8598. /**
  8599. * Creates a dynamic texture
  8600. * @param width defines the width of the texture
  8601. * @param height defines the height of the texture
  8602. * @param generateMipMaps defines if the engine should generate the mip levels
  8603. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8604. * @returns the dynamic texture inside an InternalTexture
  8605. */
  8606. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8607. /**
  8608. * Update the sampling mode of a given texture
  8609. * @param samplingMode defines the required sampling mode
  8610. * @param texture defines the texture to update
  8611. */
  8612. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8613. /**
  8614. * Update the content of a dynamic texture
  8615. * @param texture defines the texture to update
  8616. * @param canvas defines the canvas containing the source
  8617. * @param invertY defines if data must be stored with Y axis inverted
  8618. * @param premulAlpha defines if alpha is stored as premultiplied
  8619. * @param format defines the format of the data
  8620. */
  8621. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8622. /**
  8623. * Update a video texture
  8624. * @param texture defines the texture to update
  8625. * @param video defines the video element to use
  8626. * @param invertY defines if data must be stored with Y axis inverted
  8627. */
  8628. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8629. /**
  8630. * Updates a depth texture Comparison Mode and Function.
  8631. * If the comparison Function is equal to 0, the mode will be set to none.
  8632. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8633. * @param texture The texture to set the comparison function for
  8634. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8635. */
  8636. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8637. private _setupDepthStencilTexture;
  8638. /**
  8639. * Creates a depth stencil texture.
  8640. * This is only available in WebGL 2 or with the depth texture extension available.
  8641. * @param size The size of face edge in the texture.
  8642. * @param options The options defining the texture.
  8643. * @returns The texture
  8644. */
  8645. createDepthStencilTexture(size: number | {
  8646. width: number;
  8647. height: number;
  8648. }, options: DepthTextureCreationOptions): InternalTexture;
  8649. /**
  8650. * Creates a depth stencil texture.
  8651. * This is only available in WebGL 2 or with the depth texture extension available.
  8652. * @param size The size of face edge in the texture.
  8653. * @param options The options defining the texture.
  8654. * @returns The texture
  8655. */
  8656. private _createDepthStencilTexture;
  8657. /**
  8658. * Creates a depth stencil cube texture.
  8659. * This is only available in WebGL 2.
  8660. * @param size The size of face edge in the cube texture.
  8661. * @param options The options defining the cube texture.
  8662. * @returns The cube texture
  8663. */
  8664. private _createDepthStencilCubeTexture;
  8665. /**
  8666. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8667. * @param renderTarget The render target to set the frame buffer for
  8668. */
  8669. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8670. /**
  8671. * Creates a new render target texture
  8672. * @param size defines the size of the texture
  8673. * @param options defines the options used to create the texture
  8674. * @returns a new render target texture stored in an InternalTexture
  8675. */
  8676. createRenderTargetTexture(size: number | {
  8677. width: number;
  8678. height: number;
  8679. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8680. /**
  8681. * Create a multi render target texture
  8682. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8683. * @param size defines the size of the texture
  8684. * @param options defines the creation options
  8685. * @returns the cube texture as an InternalTexture
  8686. */
  8687. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8688. private _setupFramebufferDepthAttachments;
  8689. /**
  8690. * Updates the sample count of a render target texture
  8691. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8692. * @param texture defines the texture to update
  8693. * @param samples defines the sample count to set
  8694. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8695. */
  8696. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8697. /**
  8698. * Update the sample count for a given multiple render target texture
  8699. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8700. * @param textures defines the textures to update
  8701. * @param samples defines the sample count to set
  8702. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8703. */
  8704. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8705. /** @hidden */
  8706. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8707. /** @hidden */
  8708. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8709. /** @hidden */
  8710. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8711. /** @hidden */
  8712. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  8713. /**
  8714. * Creates a new render target cube texture
  8715. * @param size defines the size of the texture
  8716. * @param options defines the options used to create the texture
  8717. * @returns a new render target cube texture stored in an InternalTexture
  8718. */
  8719. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8720. /**
  8721. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8722. * @param rootUrl defines the url where the file to load is located
  8723. * @param scene defines the current scene
  8724. * @param lodScale defines scale to apply to the mip map selection
  8725. * @param lodOffset defines offset to apply to the mip map selection
  8726. * @param onLoad defines an optional callback raised when the texture is loaded
  8727. * @param onError defines an optional callback raised if there is an issue to load the texture
  8728. * @param format defines the format of the data
  8729. * @param forcedExtension defines the extension to use to pick the right loader
  8730. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  8731. * @returns the cube texture as an InternalTexture
  8732. */
  8733. 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;
  8734. /**
  8735. * Creates a cube texture
  8736. * @param rootUrl defines the url where the files to load is located
  8737. * @param scene defines the current scene
  8738. * @param files defines the list of files to load (1 per face)
  8739. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8740. * @param onLoad defines an optional callback raised when the texture is loaded
  8741. * @param onError defines an optional callback raised if there is an issue to load the texture
  8742. * @param format defines the format of the data
  8743. * @param forcedExtension defines the extension to use to pick the right loader
  8744. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8745. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8746. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8747. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8748. * @returns the cube texture as an InternalTexture
  8749. */
  8750. 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;
  8751. /**
  8752. * @hidden
  8753. */
  8754. _setCubeMapTextureParams(loadMipmap: boolean): void;
  8755. /**
  8756. * Update a raw cube texture
  8757. * @param texture defines the texture to udpdate
  8758. * @param data defines the data to store
  8759. * @param format defines the data format
  8760. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8761. * @param invertY defines if data must be stored with Y axis inverted
  8762. * @param compression defines the compression used (null by default)
  8763. * @param level defines which level of the texture to update
  8764. */
  8765. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  8766. /**
  8767. * Creates a new raw cube texture
  8768. * @param data defines the array of data to use to create each face
  8769. * @param size defines the size of the textures
  8770. * @param format defines the format of the data
  8771. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8772. * @param generateMipMaps defines if the engine should generate the mip levels
  8773. * @param invertY defines if data must be stored with Y axis inverted
  8774. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8775. * @param compression defines the compression used (null by default)
  8776. * @returns the cube texture as an InternalTexture
  8777. */
  8778. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8779. /**
  8780. * Creates a new raw cube texture from a specified url
  8781. * @param url defines the url where the data is located
  8782. * @param scene defines the current scene
  8783. * @param size defines the size of the textures
  8784. * @param format defines the format of the data
  8785. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8786. * @param noMipmap defines if the engine should avoid generating the mip levels
  8787. * @param callback defines a callback used to extract texture data from loaded data
  8788. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  8789. * @param onLoad defines a callback called when texture is loaded
  8790. * @param onError defines a callback called if there is an error
  8791. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8792. * @param invertY defines if data must be stored with Y axis inverted
  8793. * @returns the cube texture as an InternalTexture
  8794. */
  8795. 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;
  8796. /**
  8797. * Update a raw 3D texture
  8798. * @param texture defines the texture to update
  8799. * @param data defines the data to store
  8800. * @param format defines the data format
  8801. * @param invertY defines if data must be stored with Y axis inverted
  8802. * @param compression defines the used compression (can be null)
  8803. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  8804. */
  8805. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  8806. /**
  8807. * Creates a new raw 3D texture
  8808. * @param data defines the data used to create the texture
  8809. * @param width defines the width of the texture
  8810. * @param height defines the height of the texture
  8811. * @param depth defines the depth of the texture
  8812. * @param format defines the format of the texture
  8813. * @param generateMipMaps defines if the engine must generate mip levels
  8814. * @param invertY defines if data must be stored with Y axis inverted
  8815. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8816. * @param compression defines the compressed used (can be null)
  8817. * @param textureType defines the compressed used (can be null)
  8818. * @returns a new raw 3D texture (stored in an InternalTexture)
  8819. */
  8820. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  8821. private _prepareWebGLTextureContinuation;
  8822. private _prepareWebGLTexture;
  8823. private _convertRGBtoRGBATextureData;
  8824. /** @hidden */
  8825. _releaseFramebufferObjects(texture: InternalTexture): void;
  8826. /** @hidden */
  8827. _releaseTexture(texture: InternalTexture): void;
  8828. private setProgram;
  8829. private _boundUniforms;
  8830. /**
  8831. * Binds an effect to the webGL context
  8832. * @param effect defines the effect to bind
  8833. */
  8834. bindSamplers(effect: Effect): void;
  8835. private _moveBoundTextureOnTop;
  8836. private _getCorrectTextureChannel;
  8837. private _linkTrackers;
  8838. private _removeDesignatedSlot;
  8839. private _activateCurrentTexture;
  8840. /** @hidden */
  8841. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  8842. /** @hidden */
  8843. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  8844. /**
  8845. * Sets a texture to the webGL context from a postprocess
  8846. * @param channel defines the channel to use
  8847. * @param postProcess defines the source postprocess
  8848. */
  8849. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  8850. /**
  8851. * Binds the output of the passed in post process to the texture channel specified
  8852. * @param channel The channel the texture should be bound to
  8853. * @param postProcess The post process which's output should be bound
  8854. */
  8855. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  8856. /**
  8857. * Unbind all textures from the webGL context
  8858. */
  8859. unbindAllTextures(): void;
  8860. /**
  8861. * Sets a texture to the according uniform.
  8862. * @param channel The texture channel
  8863. * @param uniform The uniform to set
  8864. * @param texture The texture to apply
  8865. */
  8866. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  8867. /**
  8868. * Sets a depth stencil texture from a render target to the according uniform.
  8869. * @param channel The texture channel
  8870. * @param uniform The uniform to set
  8871. * @param texture The render target texture containing the depth stencil texture to apply
  8872. */
  8873. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  8874. private _bindSamplerUniformToChannel;
  8875. private _getTextureWrapMode;
  8876. private _setTexture;
  8877. /**
  8878. * Sets an array of texture to the webGL context
  8879. * @param channel defines the channel where the texture array must be set
  8880. * @param uniform defines the associated uniform location
  8881. * @param textures defines the array of textures to bind
  8882. */
  8883. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  8884. /** @hidden */
  8885. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  8886. private _setTextureParameterFloat;
  8887. private _setTextureParameterInteger;
  8888. /**
  8889. * Reads pixels from the current frame buffer. Please note that this function can be slow
  8890. * @param x defines the x coordinate of the rectangle where pixels must be read
  8891. * @param y defines the y coordinate of the rectangle where pixels must be read
  8892. * @param width defines the width of the rectangle where pixels must be read
  8893. * @param height defines the height of the rectangle where pixels must be read
  8894. * @returns a Uint8Array containing RGBA colors
  8895. */
  8896. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  8897. /**
  8898. * Add an externaly attached data from its key.
  8899. * This method call will fail and return false, if such key already exists.
  8900. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  8901. * @param key the unique key that identifies the data
  8902. * @param data the data object to associate to the key for this Engine instance
  8903. * @return true if no such key were already present and the data was added successfully, false otherwise
  8904. */
  8905. addExternalData<T>(key: string, data: T): boolean;
  8906. /**
  8907. * Get an externaly attached data from its key
  8908. * @param key the unique key that identifies the data
  8909. * @return the associated data, if present (can be null), or undefined if not present
  8910. */
  8911. getExternalData<T>(key: string): T;
  8912. /**
  8913. * Get an externaly attached data from its key, create it using a factory if it's not already present
  8914. * @param key the unique key that identifies the data
  8915. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  8916. * @return the associated data, can be null if the factory returned null.
  8917. */
  8918. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  8919. /**
  8920. * Remove an externaly attached data from the Engine instance
  8921. * @param key the unique key that identifies the data
  8922. * @return true if the data was successfully removed, false if it doesn't exist
  8923. */
  8924. removeExternalData(key: string): boolean;
  8925. /**
  8926. * Unbind all vertex attributes from the webGL context
  8927. */
  8928. unbindAllAttributes(): void;
  8929. /**
  8930. * 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
  8931. */
  8932. releaseEffects(): void;
  8933. /**
  8934. * Dispose and release all associated resources
  8935. */
  8936. dispose(): void;
  8937. /**
  8938. * Display the loading screen
  8939. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8940. */
  8941. displayLoadingUI(): void;
  8942. /**
  8943. * Hide the loading screen
  8944. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8945. */
  8946. hideLoadingUI(): void;
  8947. /**
  8948. * Gets the current loading screen object
  8949. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8950. */
  8951. /**
  8952. * Sets the current loading screen object
  8953. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8954. */
  8955. loadingScreen: ILoadingScreen;
  8956. /**
  8957. * Sets the current loading screen text
  8958. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8959. */
  8960. loadingUIText: string;
  8961. /**
  8962. * Sets the current loading screen background color
  8963. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8964. */
  8965. loadingUIBackgroundColor: string;
  8966. /**
  8967. * Attach a new callback raised when context lost event is fired
  8968. * @param callback defines the callback to call
  8969. */
  8970. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8971. /**
  8972. * Attach a new callback raised when context restored event is fired
  8973. * @param callback defines the callback to call
  8974. */
  8975. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8976. /**
  8977. * Gets the source code of the vertex shader associated with a specific webGL program
  8978. * @param program defines the program to use
  8979. * @returns a string containing the source code of the vertex shader associated with the program
  8980. */
  8981. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  8982. /**
  8983. * Gets the source code of the fragment shader associated with a specific webGL program
  8984. * @param program defines the program to use
  8985. * @returns a string containing the source code of the fragment shader associated with the program
  8986. */
  8987. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  8988. /**
  8989. * Get the current error code of the webGL context
  8990. * @returns the error code
  8991. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  8992. */
  8993. getError(): number;
  8994. /**
  8995. * Gets the current framerate
  8996. * @returns a number representing the framerate
  8997. */
  8998. getFps(): number;
  8999. /**
  9000. * Gets the time spent between current and previous frame
  9001. * @returns a number representing the delta time in ms
  9002. */
  9003. getDeltaTime(): number;
  9004. private _measureFps;
  9005. /** @hidden */
  9006. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number): ArrayBufferView;
  9007. private _canRenderToFloatFramebuffer;
  9008. private _canRenderToHalfFloatFramebuffer;
  9009. private _canRenderToFramebuffer;
  9010. /** @hidden */
  9011. _getWebGLTextureType(type: number): number;
  9012. private _getInternalFormat;
  9013. /** @hidden */
  9014. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  9015. /** @hidden */
  9016. _getRGBAMultiSampleBufferFormat(type: number): number;
  9017. /** @hidden */
  9018. _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;
  9019. /** @hidden */
  9020. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  9021. private _partialLoadFile;
  9022. private _cascadeLoadFiles;
  9023. /**
  9024. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  9025. * @returns true if the engine can be created
  9026. * @ignorenaming
  9027. */
  9028. static isSupported(): boolean;
  9029. }
  9030. }
  9031. declare module BABYLON {
  9032. class NullEngineOptions {
  9033. renderWidth: number;
  9034. renderHeight: number;
  9035. textureSize: number;
  9036. deterministicLockstep: boolean;
  9037. lockstepMaxSteps: number;
  9038. }
  9039. /**
  9040. * The null engine class provides support for headless version of babylon.js.
  9041. * This can be used in server side scenario or for testing purposes
  9042. */
  9043. class NullEngine extends Engine {
  9044. private _options;
  9045. isDeterministicLockStep(): boolean;
  9046. getLockstepMaxSteps(): number;
  9047. getHardwareScalingLevel(): number;
  9048. constructor(options?: NullEngineOptions);
  9049. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9050. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  9051. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  9052. getRenderWidth(useScreen?: boolean): number;
  9053. getRenderHeight(useScreen?: boolean): number;
  9054. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  9055. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  9056. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  9057. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  9058. bindSamplers(effect: Effect): void;
  9059. enableEffect(effect: Effect): void;
  9060. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  9061. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  9062. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  9063. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  9064. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  9065. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  9066. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  9067. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  9068. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  9069. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  9070. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  9071. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  9072. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  9073. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  9074. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  9075. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9076. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9077. setFloat(uniform: WebGLUniformLocation, value: number): void;
  9078. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  9079. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  9080. setBool(uniform: WebGLUniformLocation, bool: number): void;
  9081. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  9082. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  9083. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  9084. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  9085. bindBuffers(vertexBuffers: {
  9086. [key: string]: VertexBuffer;
  9087. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  9088. wipeCaches(bruteForce?: boolean): void;
  9089. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  9090. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  9091. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  9092. /** @hidden */
  9093. _createTexture(): WebGLTexture;
  9094. /** @hidden */
  9095. _releaseTexture(texture: InternalTexture): void;
  9096. 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;
  9097. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  9098. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  9099. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  9100. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  9101. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9102. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  9103. /**
  9104. * @hidden
  9105. * Get the current error code of the webGL context
  9106. * @returns the error code
  9107. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  9108. */
  9109. getError(): number;
  9110. /** @hidden */
  9111. _getUnpackAlignement(): number;
  9112. /** @hidden */
  9113. _unpackFlipY(value: boolean): void;
  9114. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  9115. /**
  9116. * Updates a dynamic vertex buffer.
  9117. * @param vertexBuffer the vertex buffer to update
  9118. * @param data the data used to update the vertex buffer
  9119. * @param byteOffset the byte offset of the data (optional)
  9120. * @param byteLength the byte length of the data (optional)
  9121. */
  9122. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  9123. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  9124. /** @hidden */
  9125. _bindTexture(channel: number, texture: InternalTexture): void;
  9126. /** @hidden */
  9127. _releaseBuffer(buffer: WebGLBuffer): boolean;
  9128. releaseEffects(): void;
  9129. displayLoadingUI(): void;
  9130. hideLoadingUI(): void;
  9131. /** @hidden */
  9132. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9133. /** @hidden */
  9134. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9135. /** @hidden */
  9136. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  9137. /** @hidden */
  9138. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  9139. }
  9140. }
  9141. interface WebGLRenderingContext {
  9142. readonly RASTERIZER_DISCARD: number;
  9143. readonly DEPTH_COMPONENT24: number;
  9144. readonly TEXTURE_3D: number;
  9145. readonly TEXTURE_2D_ARRAY: number;
  9146. readonly TEXTURE_COMPARE_FUNC: number;
  9147. readonly TEXTURE_COMPARE_MODE: number;
  9148. readonly COMPARE_REF_TO_TEXTURE: number;
  9149. readonly TEXTURE_WRAP_R: number;
  9150. readonly HALF_FLOAT: number;
  9151. readonly RGB8: number;
  9152. readonly RED_INTEGER: number;
  9153. readonly RG_INTEGER: number;
  9154. readonly RGB_INTEGER: number;
  9155. readonly RGBA_INTEGER: number;
  9156. readonly R8_SNORM: number;
  9157. readonly RG8_SNORM: number;
  9158. readonly RGB8_SNORM: number;
  9159. readonly RGBA8_SNORM: number;
  9160. readonly R8I: number;
  9161. readonly RG8I: number;
  9162. readonly RGB8I: number;
  9163. readonly RGBA8I: number;
  9164. readonly R8UI: number;
  9165. readonly RG8UI: number;
  9166. readonly RGB8UI: number;
  9167. readonly RGBA8UI: number;
  9168. readonly R16I: number;
  9169. readonly RG16I: number;
  9170. readonly RGB16I: number;
  9171. readonly RGBA16I: number;
  9172. readonly R16UI: number;
  9173. readonly RG16UI: number;
  9174. readonly RGB16UI: number;
  9175. readonly RGBA16UI: number;
  9176. readonly R32I: number;
  9177. readonly RG32I: number;
  9178. readonly RGB32I: number;
  9179. readonly RGBA32I: number;
  9180. readonly R32UI: number;
  9181. readonly RG32UI: number;
  9182. readonly RGB32UI: number;
  9183. readonly RGBA32UI: number;
  9184. readonly RGB10_A2UI: number;
  9185. readonly R11F_G11F_B10F: number;
  9186. readonly RGB9_E5: number;
  9187. readonly RGB10_A2: number;
  9188. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  9189. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  9190. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  9191. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  9192. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  9193. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  9194. 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;
  9195. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  9196. readonly TRANSFORM_FEEDBACK: number;
  9197. readonly INTERLEAVED_ATTRIBS: number;
  9198. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  9199. createTransformFeedback(): WebGLTransformFeedback;
  9200. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  9201. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  9202. beginTransformFeedback(primitiveMode: number): void;
  9203. endTransformFeedback(): void;
  9204. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  9205. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9206. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9207. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  9208. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  9209. }
  9210. interface ImageBitmap {
  9211. readonly width: number;
  9212. readonly height: number;
  9213. close(): void;
  9214. }
  9215. interface WebGLQuery extends WebGLObject {
  9216. }
  9217. declare var WebGLQuery: {
  9218. prototype: WebGLQuery;
  9219. new (): WebGLQuery;
  9220. };
  9221. interface WebGLSampler extends WebGLObject {
  9222. }
  9223. declare var WebGLSampler: {
  9224. prototype: WebGLSampler;
  9225. new (): WebGLSampler;
  9226. };
  9227. interface WebGLSync extends WebGLObject {
  9228. }
  9229. declare var WebGLSync: {
  9230. prototype: WebGLSync;
  9231. new (): WebGLSync;
  9232. };
  9233. interface WebGLTransformFeedback extends WebGLObject {
  9234. }
  9235. declare var WebGLTransformFeedback: {
  9236. prototype: WebGLTransformFeedback;
  9237. new (): WebGLTransformFeedback;
  9238. };
  9239. interface WebGLVertexArrayObject extends WebGLObject {
  9240. }
  9241. declare var WebGLVertexArrayObject: {
  9242. prototype: WebGLVertexArrayObject;
  9243. new (): WebGLVertexArrayObject;
  9244. };
  9245. /**
  9246. * Module Debug contains the (visual) components to debug a scene correctly
  9247. */
  9248. declare module BABYLON.Debug {
  9249. /**
  9250. * The Axes viewer will show 3 axes in a specific point in space
  9251. */
  9252. class AxesViewer {
  9253. private _xline;
  9254. private _yline;
  9255. private _zline;
  9256. private _xmesh;
  9257. private _ymesh;
  9258. private _zmesh;
  9259. /**
  9260. * Gets the hosting scene
  9261. */
  9262. scene: Nullable<Scene>;
  9263. /**
  9264. * Gets or sets a number used to scale line length
  9265. */
  9266. scaleLines: number;
  9267. /**
  9268. * Creates a new AxesViewer
  9269. * @param scene defines the hosting scene
  9270. * @param scaleLines defines a number used to scale line length (1 by default)
  9271. */
  9272. constructor(scene: Scene, scaleLines?: number);
  9273. /**
  9274. * Force the viewer to update
  9275. * @param position defines the position of the viewer
  9276. * @param xaxis defines the x axis of the viewer
  9277. * @param yaxis defines the y axis of the viewer
  9278. * @param zaxis defines the z axis of the viewer
  9279. */
  9280. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9281. /** Releases resources */
  9282. dispose(): void;
  9283. }
  9284. }
  9285. declare module BABYLON.Debug {
  9286. /**
  9287. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9288. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9289. */
  9290. class BoneAxesViewer extends AxesViewer {
  9291. /**
  9292. * Gets or sets the target mesh where to display the axes viewer
  9293. */
  9294. mesh: Nullable<Mesh>;
  9295. /**
  9296. * Gets or sets the target bone where to display the axes viewer
  9297. */
  9298. bone: Nullable<Bone>;
  9299. /** Gets current position */
  9300. pos: Vector3;
  9301. /** Gets direction of X axis */
  9302. xaxis: Vector3;
  9303. /** Gets direction of Y axis */
  9304. yaxis: Vector3;
  9305. /** Gets direction of Z axis */
  9306. zaxis: Vector3;
  9307. /**
  9308. * Creates a new BoneAxesViewer
  9309. * @param scene defines the hosting scene
  9310. * @param bone defines the target bone
  9311. * @param mesh defines the target mesh
  9312. * @param scaleLines defines a scaling factor for line length (1 by default)
  9313. */
  9314. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9315. /**
  9316. * Force the viewer to update
  9317. */
  9318. update(): void;
  9319. /** Releases resources */
  9320. dispose(): void;
  9321. }
  9322. }
  9323. declare module BABYLON {
  9324. interface Scene {
  9325. /**
  9326. * @hidden
  9327. * Backing field
  9328. */
  9329. _debugLayer: DebugLayer;
  9330. /**
  9331. * Gets the debug layer (aka Inspector) associated with the scene
  9332. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9333. */
  9334. debugLayer: DebugLayer;
  9335. }
  9336. class DebugLayer {
  9337. private _scene;
  9338. static InspectorURL: string;
  9339. private _inspector;
  9340. private BJSINSPECTOR;
  9341. onPropertyChangedObservable: Observable<{
  9342. object: any;
  9343. property: string;
  9344. value: any;
  9345. initialValue: any;
  9346. }>;
  9347. constructor(scene: Scene);
  9348. /** Creates the inspector window. */
  9349. private _createInspector;
  9350. isVisible(): boolean;
  9351. hide(): void;
  9352. /**
  9353. *
  9354. * Launch the debugLayer.
  9355. *
  9356. * initialTab:
  9357. * | Value | Tab Name |
  9358. * | --- | --- |
  9359. * | 0 | Scene |
  9360. * | 1 | Console |
  9361. * | 2 | Stats |
  9362. * | 3 | Textures |
  9363. * | 4 | Mesh |
  9364. * | 5 | Light |
  9365. * | 6 | Material |
  9366. * | 7 | GLTF |
  9367. * | 8 | GUI |
  9368. * | 9 | Physics |
  9369. * | 10 | Camera |
  9370. * | 11 | Audio |
  9371. *
  9372. */
  9373. show(config?: {
  9374. popup?: boolean;
  9375. initialTab?: number;
  9376. parentElement?: HTMLElement;
  9377. newColors?: {
  9378. backgroundColor?: string;
  9379. backgroundColorLighter?: string;
  9380. backgroundColorLighter2?: string;
  9381. backgroundColorLighter3?: string;
  9382. color?: string;
  9383. colorTop?: string;
  9384. colorBot?: string;
  9385. };
  9386. }): void;
  9387. /**
  9388. * Gets the active tab
  9389. * @return the index of the active tab or -1 if the inspector is hidden
  9390. */
  9391. getActiveTab(): number;
  9392. }
  9393. }
  9394. declare module BABYLON.Debug {
  9395. /**
  9396. * Used to show the physics impostor around the specific mesh
  9397. */
  9398. class PhysicsViewer {
  9399. /** @hidden */
  9400. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9401. /** @hidden */
  9402. protected _meshes: Array<Nullable<AbstractMesh>>;
  9403. /** @hidden */
  9404. protected _scene: Nullable<Scene>;
  9405. /** @hidden */
  9406. protected _numMeshes: number;
  9407. /** @hidden */
  9408. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9409. private _renderFunction;
  9410. private _debugBoxMesh;
  9411. private _debugSphereMesh;
  9412. private _debugMaterial;
  9413. /**
  9414. * Creates a new PhysicsViewer
  9415. * @param scene defines the hosting scene
  9416. */
  9417. constructor(scene: Scene);
  9418. /** @hidden */
  9419. protected _updateDebugMeshes(): void;
  9420. /**
  9421. * Renders a specified physic impostor
  9422. * @param impostor defines the impostor to render
  9423. */
  9424. showImpostor(impostor: PhysicsImpostor): void;
  9425. /**
  9426. * Hides a specified physic impostor
  9427. * @param impostor defines the impostor to hide
  9428. */
  9429. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9430. private _getDebugMaterial;
  9431. private _getDebugBoxMesh;
  9432. private _getDebugSphereMesh;
  9433. private _getDebugMesh;
  9434. /** Releases all resources */
  9435. dispose(): void;
  9436. }
  9437. }
  9438. declare module BABYLON {
  9439. class RayHelper {
  9440. ray: Nullable<Ray>;
  9441. private _renderPoints;
  9442. private _renderLine;
  9443. private _renderFunction;
  9444. private _scene;
  9445. private _updateToMeshFunction;
  9446. private _attachedToMesh;
  9447. private _meshSpaceDirection;
  9448. private _meshSpaceOrigin;
  9449. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9450. constructor(ray: Ray);
  9451. show(scene: Scene, color?: Color3): void;
  9452. hide(): void;
  9453. private _render;
  9454. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9455. detachFromMesh(): void;
  9456. private _updateToMesh;
  9457. dispose(): void;
  9458. }
  9459. }
  9460. declare module BABYLON.Debug {
  9461. /**
  9462. * Class used to render a debug view of a given skeleton
  9463. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9464. */
  9465. class SkeletonViewer {
  9466. /** defines the skeleton to render */
  9467. skeleton: Skeleton;
  9468. /** defines the mesh attached to the skeleton */
  9469. mesh: AbstractMesh;
  9470. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9471. autoUpdateBonesMatrices: boolean;
  9472. /** defines the rendering group id to use with the viewer */
  9473. renderingGroupId: number;
  9474. /** Gets or sets the color used to render the skeleton */
  9475. color: Color3;
  9476. private _scene;
  9477. private _debugLines;
  9478. private _debugMesh;
  9479. private _isEnabled;
  9480. private _renderFunction;
  9481. /**
  9482. * Creates a new SkeletonViewer
  9483. * @param skeleton defines the skeleton to render
  9484. * @param mesh defines the mesh attached to the skeleton
  9485. * @param scene defines the hosting scene
  9486. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9487. * @param renderingGroupId defines the rendering group id to use with the viewer
  9488. */
  9489. constructor(
  9490. /** defines the skeleton to render */
  9491. skeleton: Skeleton,
  9492. /** defines the mesh attached to the skeleton */
  9493. mesh: AbstractMesh, scene: Scene,
  9494. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9495. autoUpdateBonesMatrices?: boolean,
  9496. /** defines the rendering group id to use with the viewer */
  9497. renderingGroupId?: number);
  9498. /** Gets or sets a boolean indicating if the viewer is enabled */
  9499. isEnabled: boolean;
  9500. private _getBonePosition;
  9501. private _getLinesForBonesWithLength;
  9502. private _getLinesForBonesNoLength;
  9503. /** Update the viewer to sync with current skeleton state */
  9504. update(): void;
  9505. /** Release associated resources */
  9506. dispose(): void;
  9507. }
  9508. }
  9509. declare module BABYLON {
  9510. class KeyboardEventTypes {
  9511. static _KEYDOWN: number;
  9512. static _KEYUP: number;
  9513. static readonly KEYDOWN: number;
  9514. static readonly KEYUP: number;
  9515. }
  9516. class KeyboardInfo {
  9517. type: number;
  9518. event: KeyboardEvent;
  9519. constructor(type: number, event: KeyboardEvent);
  9520. }
  9521. /**
  9522. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9523. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9524. */
  9525. class KeyboardInfoPre extends KeyboardInfo {
  9526. constructor(type: number, event: KeyboardEvent);
  9527. skipOnPointerObservable: boolean;
  9528. }
  9529. }
  9530. declare module BABYLON {
  9531. class PointerEventTypes {
  9532. static _POINTERDOWN: number;
  9533. static _POINTERUP: number;
  9534. static _POINTERMOVE: number;
  9535. static _POINTERWHEEL: number;
  9536. static _POINTERPICK: number;
  9537. static _POINTERTAP: number;
  9538. static _POINTERDOUBLETAP: number;
  9539. static readonly POINTERDOWN: number;
  9540. static readonly POINTERUP: number;
  9541. static readonly POINTERMOVE: number;
  9542. static readonly POINTERWHEEL: number;
  9543. static readonly POINTERPICK: number;
  9544. static readonly POINTERTAP: number;
  9545. static readonly POINTERDOUBLETAP: number;
  9546. }
  9547. class PointerInfoBase {
  9548. type: number;
  9549. event: PointerEvent | MouseWheelEvent;
  9550. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  9551. }
  9552. /**
  9553. * This class is used to store pointer related info for the onPrePointerObservable event.
  9554. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  9555. */
  9556. class PointerInfoPre extends PointerInfoBase {
  9557. /**
  9558. * Ray from a pointer if availible (eg. 6dof controller)
  9559. */
  9560. ray: Nullable<Ray>;
  9561. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  9562. localPosition: Vector2;
  9563. skipOnPointerObservable: boolean;
  9564. }
  9565. /**
  9566. * This type contains all the data related to a pointer event in Babylon.js.
  9567. * 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.
  9568. */
  9569. class PointerInfo extends PointerInfoBase {
  9570. pickInfo: Nullable<PickingInfo>;
  9571. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  9572. }
  9573. }
  9574. declare module BABYLON {
  9575. class StickValues {
  9576. x: number;
  9577. y: number;
  9578. constructor(x: number, y: number);
  9579. }
  9580. interface GamepadButtonChanges {
  9581. changed: boolean;
  9582. pressChanged: boolean;
  9583. touchChanged: boolean;
  9584. valueChanged: boolean;
  9585. }
  9586. class Gamepad {
  9587. id: string;
  9588. index: number;
  9589. browserGamepad: any;
  9590. type: number;
  9591. private _leftStick;
  9592. private _rightStick;
  9593. /** @hidden */
  9594. _isConnected: boolean;
  9595. private _leftStickAxisX;
  9596. private _leftStickAxisY;
  9597. private _rightStickAxisX;
  9598. private _rightStickAxisY;
  9599. private _onleftstickchanged;
  9600. private _onrightstickchanged;
  9601. static GAMEPAD: number;
  9602. static GENERIC: number;
  9603. static XBOX: number;
  9604. static POSE_ENABLED: number;
  9605. protected _invertLeftStickY: boolean;
  9606. readonly isConnected: boolean;
  9607. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9608. onleftstickchanged(callback: (values: StickValues) => void): void;
  9609. onrightstickchanged(callback: (values: StickValues) => void): void;
  9610. leftStick: StickValues;
  9611. rightStick: StickValues;
  9612. update(): void;
  9613. dispose(): void;
  9614. }
  9615. class GenericPad extends Gamepad {
  9616. private _buttons;
  9617. private _onbuttondown;
  9618. private _onbuttonup;
  9619. onButtonDownObservable: Observable<number>;
  9620. onButtonUpObservable: Observable<number>;
  9621. onbuttondown(callback: (buttonPressed: number) => void): void;
  9622. onbuttonup(callback: (buttonReleased: number) => void): void;
  9623. constructor(id: string, index: number, browserGamepad: any);
  9624. private _setButtonValue;
  9625. update(): void;
  9626. dispose(): void;
  9627. }
  9628. }
  9629. declare module BABYLON {
  9630. class GamepadManager {
  9631. private _scene?;
  9632. private _babylonGamepads;
  9633. private _oneGamepadConnected;
  9634. /** @hidden */
  9635. _isMonitoring: boolean;
  9636. private _gamepadEventSupported;
  9637. private _gamepadSupport;
  9638. onGamepadConnectedObservable: Observable<Gamepad>;
  9639. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9640. private _onGamepadConnectedEvent;
  9641. private _onGamepadDisconnectedEvent;
  9642. constructor(_scene?: Scene | undefined);
  9643. readonly gamepads: Gamepad[];
  9644. getGamepadByType(type?: number): Nullable<Gamepad>;
  9645. dispose(): void;
  9646. private _addNewGamepad;
  9647. private _startMonitoringGamepads;
  9648. private _stopMonitoringGamepads;
  9649. /** @hidden */
  9650. _checkGamepadsStatus(): void;
  9651. private _updateGamepadObjects;
  9652. }
  9653. }
  9654. declare module BABYLON {
  9655. interface Scene {
  9656. /** @hidden */
  9657. _gamepadManager: Nullable<GamepadManager>;
  9658. /**
  9659. * Gets the gamepad manager associated with the scene
  9660. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  9661. */
  9662. gamepadManager: GamepadManager;
  9663. }
  9664. interface FreeCameraInputsManager {
  9665. addGamepad(): FreeCameraInputsManager;
  9666. }
  9667. interface ArcRotateCameraInputsManager {
  9668. addGamepad(): ArcRotateCameraInputsManager;
  9669. }
  9670. /**
  9671. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  9672. */
  9673. class GamepadSystemSceneComponent implements ISceneComponent {
  9674. /**
  9675. * The component name helpfull to identify the component in the list of scene components.
  9676. */
  9677. readonly name: string;
  9678. /**
  9679. * The scene the component belongs to.
  9680. */
  9681. scene: Scene;
  9682. /**
  9683. * Creates a new instance of the component for the given scene
  9684. * @param scene Defines the scene to register the component in
  9685. */
  9686. constructor(scene: Scene);
  9687. /**
  9688. * Registers the component in a given scene
  9689. */
  9690. register(): void;
  9691. /**
  9692. * Rebuilds the elements related to this component in case of
  9693. * context lost for instance.
  9694. */
  9695. rebuild(): void;
  9696. /**
  9697. * Disposes the component and the associated ressources
  9698. */
  9699. dispose(): void;
  9700. private _beforeCameraUpdate;
  9701. }
  9702. }
  9703. declare module BABYLON {
  9704. /**
  9705. * Defines supported buttons for XBox360 compatible gamepads
  9706. */
  9707. enum Xbox360Button {
  9708. /** A */
  9709. A = 0,
  9710. /** B */
  9711. B = 1,
  9712. /** X */
  9713. X = 2,
  9714. /** Y */
  9715. Y = 3,
  9716. /** Start */
  9717. Start = 4,
  9718. /** Back */
  9719. Back = 5,
  9720. /** Left button */
  9721. LB = 6,
  9722. /** Right button */
  9723. RB = 7,
  9724. /** Left stick */
  9725. LeftStick = 8,
  9726. /** Right stick */
  9727. RightStick = 9
  9728. }
  9729. /** Defines values for XBox360 DPad */
  9730. enum Xbox360Dpad {
  9731. /** Up */
  9732. Up = 0,
  9733. /** Down */
  9734. Down = 1,
  9735. /** Left */
  9736. Left = 2,
  9737. /** Right */
  9738. Right = 3
  9739. }
  9740. /**
  9741. * Defines a XBox360 gamepad
  9742. */
  9743. class Xbox360Pad extends Gamepad {
  9744. private _leftTrigger;
  9745. private _rightTrigger;
  9746. private _onlefttriggerchanged;
  9747. private _onrighttriggerchanged;
  9748. private _onbuttondown;
  9749. private _onbuttonup;
  9750. private _ondpaddown;
  9751. private _ondpadup;
  9752. /** Observable raised when a button is pressed */
  9753. onButtonDownObservable: Observable<Xbox360Button>;
  9754. /** Observable raised when a button is released */
  9755. onButtonUpObservable: Observable<Xbox360Button>;
  9756. /** Observable raised when a pad is pressed */
  9757. onPadDownObservable: Observable<Xbox360Dpad>;
  9758. /** Observable raised when a pad is released */
  9759. onPadUpObservable: Observable<Xbox360Dpad>;
  9760. private _buttonA;
  9761. private _buttonB;
  9762. private _buttonX;
  9763. private _buttonY;
  9764. private _buttonBack;
  9765. private _buttonStart;
  9766. private _buttonLB;
  9767. private _buttonRB;
  9768. private _buttonLeftStick;
  9769. private _buttonRightStick;
  9770. private _dPadUp;
  9771. private _dPadDown;
  9772. private _dPadLeft;
  9773. private _dPadRight;
  9774. private _isXboxOnePad;
  9775. /**
  9776. * Creates a new XBox360 gamepad object
  9777. * @param id defines the id of this gamepad
  9778. * @param index defines its index
  9779. * @param gamepad defines the internal HTML gamepad object
  9780. * @param xboxOne defines if it is a XBox One gamepad
  9781. */
  9782. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9783. /**
  9784. * Defines the callback to call when left trigger is pressed
  9785. * @param callback defines the callback to use
  9786. */
  9787. onlefttriggerchanged(callback: (value: number) => void): void;
  9788. /**
  9789. * Defines the callback to call when right trigger is pressed
  9790. * @param callback defines the callback to use
  9791. */
  9792. onrighttriggerchanged(callback: (value: number) => void): void;
  9793. /**
  9794. * Gets or sets left trigger value
  9795. */
  9796. leftTrigger: number;
  9797. /**
  9798. * Gets or sets right trigger value
  9799. */
  9800. rightTrigger: number;
  9801. /**
  9802. * Defines the callback to call when a button is pressed
  9803. * @param callback defines the callback to use
  9804. */
  9805. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9806. /**
  9807. * Defines the callback to call when a button is released
  9808. * @param callback defines the callback to use
  9809. */
  9810. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9811. /**
  9812. * Defines the callback to call when a pad is pressed
  9813. * @param callback defines the callback to use
  9814. */
  9815. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9816. /**
  9817. * Defines the callback to call when a pad is released
  9818. * @param callback defines the callback to use
  9819. */
  9820. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9821. private _setButtonValue;
  9822. private _setDPadValue;
  9823. /** Gets or sets value of A button */
  9824. buttonA: number;
  9825. /** Gets or sets value of B button */
  9826. buttonB: number;
  9827. /** Gets or sets value of X button */
  9828. buttonX: number;
  9829. /** Gets or sets value of Y button */
  9830. buttonY: number;
  9831. /** Gets or sets value of Start button */
  9832. buttonStart: number;
  9833. /** Gets or sets value of Back button */
  9834. buttonBack: number;
  9835. /** Gets or sets value of Left button */
  9836. buttonLB: number;
  9837. /** Gets or sets value of Right button */
  9838. buttonRB: number;
  9839. /** Gets or sets value of left stick */
  9840. buttonLeftStick: number;
  9841. /** Gets or sets value of right stick */
  9842. buttonRightStick: number;
  9843. /** Gets or sets value of DPad up */
  9844. dPadUp: number;
  9845. /** Gets or sets value of DPad down */
  9846. dPadDown: number;
  9847. /** Gets or sets value of DPad left */
  9848. dPadLeft: number;
  9849. /** Gets or sets value of DPad right */
  9850. dPadRight: number;
  9851. /**
  9852. * Force the gamepad to synchronize with device values
  9853. */
  9854. update(): void;
  9855. dispose(): void;
  9856. }
  9857. }
  9858. declare module BABYLON {
  9859. /**
  9860. * Single axis drag gizmo
  9861. */
  9862. class AxisDragGizmo extends Gizmo {
  9863. /**
  9864. * Drag behavior responsible for the gizmos dragging interactions
  9865. */
  9866. dragBehavior: PointerDragBehavior;
  9867. private _pointerObserver;
  9868. /**
  9869. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9870. */
  9871. snapDistance: number;
  9872. /**
  9873. * Event that fires each time the gizmo snaps to a new location.
  9874. * * snapDistance is the the change in distance
  9875. */
  9876. onSnapObservable: Observable<{
  9877. snapDistance: number;
  9878. }>;
  9879. /**
  9880. * Creates an AxisDragGizmo
  9881. * @param gizmoLayer The utility layer the gizmo will be added to
  9882. * @param dragAxis The axis which the gizmo will be able to drag on
  9883. * @param color The color of the gizmo
  9884. */
  9885. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9886. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9887. /**
  9888. * Disposes of the gizmo
  9889. */
  9890. dispose(): void;
  9891. }
  9892. }
  9893. declare module BABYLON {
  9894. /**
  9895. * Single axis scale gizmo
  9896. */
  9897. class AxisScaleGizmo extends Gizmo {
  9898. private _coloredMaterial;
  9899. /**
  9900. * Drag behavior responsible for the gizmos dragging interactions
  9901. */
  9902. dragBehavior: PointerDragBehavior;
  9903. private _pointerObserver;
  9904. /**
  9905. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9906. */
  9907. snapDistance: number;
  9908. /**
  9909. * Event that fires each time the gizmo snaps to a new location.
  9910. * * snapDistance is the the change in distance
  9911. */
  9912. onSnapObservable: Observable<{
  9913. snapDistance: number;
  9914. }>;
  9915. /**
  9916. * If the scaling operation should be done on all axis (default: false)
  9917. */
  9918. uniformScaling: boolean;
  9919. /**
  9920. * Creates an AxisScaleGizmo
  9921. * @param gizmoLayer The utility layer the gizmo will be added to
  9922. * @param dragAxis The axis which the gizmo will be able to scale on
  9923. * @param color The color of the gizmo
  9924. */
  9925. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9926. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9927. /**
  9928. * Disposes of the gizmo
  9929. */
  9930. dispose(): void;
  9931. /**
  9932. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  9933. * @param mesh The mesh to replace the default mesh of the gizmo
  9934. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  9935. */
  9936. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  9937. }
  9938. }
  9939. declare module BABYLON {
  9940. /**
  9941. * Bounding box gizmo
  9942. */
  9943. class BoundingBoxGizmo extends Gizmo {
  9944. private _lineBoundingBox;
  9945. private _rotateSpheresParent;
  9946. private _scaleBoxesParent;
  9947. private _boundingDimensions;
  9948. private _renderObserver;
  9949. private _pointerObserver;
  9950. private _scaleDragSpeed;
  9951. private _tmpQuaternion;
  9952. private _tmpVector;
  9953. private _tmpRotationMatrix;
  9954. /**
  9955. * 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)
  9956. */
  9957. ignoreChildren: boolean;
  9958. /**
  9959. * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored. (Default: null)
  9960. */
  9961. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  9962. /**
  9963. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  9964. */
  9965. rotationSphereSize: number;
  9966. /**
  9967. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  9968. */
  9969. scaleBoxSize: number;
  9970. /**
  9971. * 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)
  9972. */
  9973. fixedDragMeshScreenSize: boolean;
  9974. /**
  9975. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  9976. */
  9977. fixedDragMeshScreenSizeDistanceFactor: number;
  9978. /**
  9979. * Fired when a rotation sphere or scale box is dragged
  9980. */
  9981. onDragStartObservable: Observable<{}>;
  9982. /**
  9983. * Fired when a scale box is dragged
  9984. */
  9985. onScaleBoxDragObservable: Observable<{}>;
  9986. /**
  9987. * Fired when a scale box drag is ended
  9988. */
  9989. onScaleBoxDragEndObservable: Observable<{}>;
  9990. /**
  9991. * Fired when a rotation sphere is dragged
  9992. */
  9993. onRotationSphereDragObservable: Observable<{}>;
  9994. /**
  9995. * Fired when a rotation sphere drag is ended
  9996. */
  9997. onRotationSphereDragEndObservable: Observable<{}>;
  9998. /**
  9999. * Relative bounding box pivot used when scaling the attached mesh. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  10000. */
  10001. scalePivot: Nullable<Vector3>;
  10002. private _anchorMesh;
  10003. private _existingMeshScale;
  10004. private static _PivotCached;
  10005. private static _OldPivotPoint;
  10006. private static _PivotTranslation;
  10007. private static _PivotTmpVector;
  10008. /** @hidden */
  10009. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  10010. /** @hidden */
  10011. static _RestorePivotPoint(mesh: AbstractMesh): void;
  10012. /**
  10013. * Creates an BoundingBoxGizmo
  10014. * @param gizmoLayer The utility layer the gizmo will be added to
  10015. * @param color The color of the gizmo
  10016. */
  10017. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  10018. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10019. private _selectNode;
  10020. /**
  10021. * Updates the bounding box information for the Gizmo
  10022. */
  10023. updateBoundingBox(): void;
  10024. /**
  10025. * Enables rotation on the specified axis and disables rotation on the others
  10026. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  10027. */
  10028. setEnabledRotationAxis(axis: string): void;
  10029. /**
  10030. * Disposes of the gizmo
  10031. */
  10032. dispose(): void;
  10033. /**
  10034. * 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)
  10035. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  10036. * @returns the bounding box mesh with the passed in mesh as a child
  10037. */
  10038. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  10039. /**
  10040. * CustomMeshes are not supported by this gizmo
  10041. * @param mesh The mesh to replace the default mesh of the gizmo
  10042. */
  10043. setCustomMesh(mesh: Mesh): void;
  10044. }
  10045. }
  10046. declare module BABYLON {
  10047. /**
  10048. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  10049. */
  10050. class Gizmo implements IDisposable {
  10051. /** The utility layer the gizmo will be added to */
  10052. gizmoLayer: UtilityLayerRenderer;
  10053. /**
  10054. * The root mesh of the gizmo
  10055. */
  10056. protected _rootMesh: Mesh;
  10057. private _attachedMesh;
  10058. /**
  10059. * Ratio for the scale of the gizmo (Default: 1)
  10060. */
  10061. scaleRatio: number;
  10062. private _tmpMatrix;
  10063. /**
  10064. * If a custom mesh has been set (Default: false)
  10065. */
  10066. protected _customMeshSet: boolean;
  10067. /**
  10068. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  10069. * * When set, interactions will be enabled
  10070. */
  10071. attachedMesh: Nullable<AbstractMesh>;
  10072. /**
  10073. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  10074. * @param mesh The mesh to replace the default mesh of the gizmo
  10075. */
  10076. setCustomMesh(mesh: Mesh): void;
  10077. /**
  10078. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  10079. */
  10080. updateGizmoRotationToMatchAttachedMesh: boolean;
  10081. /**
  10082. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  10083. */
  10084. updateGizmoPositionToMatchAttachedMesh: boolean;
  10085. /**
  10086. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  10087. */
  10088. protected _updateScale: boolean;
  10089. protected _interactionsEnabled: boolean;
  10090. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10091. private _beforeRenderObserver;
  10092. /**
  10093. * Creates a gizmo
  10094. * @param gizmoLayer The utility layer the gizmo will be added to
  10095. */
  10096. constructor(
  10097. /** The utility layer the gizmo will be added to */
  10098. gizmoLayer?: UtilityLayerRenderer);
  10099. private _tempVector;
  10100. /**
  10101. * @hidden
  10102. * Updates the gizmo to match the attached mesh's position/rotation
  10103. */
  10104. protected _update(): void;
  10105. /**
  10106. * Disposes of the gizmo
  10107. */
  10108. dispose(): void;
  10109. }
  10110. }
  10111. declare module BABYLON {
  10112. /**
  10113. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  10114. */
  10115. class GizmoManager implements IDisposable {
  10116. private scene;
  10117. /**
  10118. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  10119. */
  10120. gizmos: {
  10121. positionGizmo: Nullable<PositionGizmo>;
  10122. rotationGizmo: Nullable<RotationGizmo>;
  10123. scaleGizmo: Nullable<ScaleGizmo>;
  10124. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  10125. };
  10126. private _gizmosEnabled;
  10127. private _pointerObserver;
  10128. private _attachedMesh;
  10129. private _boundingBoxColor;
  10130. private _dragBehavior;
  10131. /**
  10132. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  10133. */
  10134. attachableMeshes: Nullable<Array<AbstractMesh>>;
  10135. /**
  10136. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  10137. */
  10138. usePointerToAttachGizmos: boolean;
  10139. /**
  10140. * Instatiates a gizmo manager
  10141. * @param scene the scene to overlay the gizmos on top of
  10142. */
  10143. constructor(scene: Scene);
  10144. /**
  10145. * Attaches a set of gizmos to the specified mesh
  10146. * @param mesh The mesh the gizmo's should be attached to
  10147. */
  10148. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  10149. /**
  10150. * If the position gizmo is enabled
  10151. */
  10152. positionGizmoEnabled: boolean;
  10153. /**
  10154. * If the rotation gizmo is enabled
  10155. */
  10156. rotationGizmoEnabled: boolean;
  10157. /**
  10158. * If the scale gizmo is enabled
  10159. */
  10160. scaleGizmoEnabled: boolean;
  10161. /**
  10162. * If the boundingBox gizmo is enabled
  10163. */
  10164. boundingBoxGizmoEnabled: boolean;
  10165. /**
  10166. * Disposes of the gizmo manager
  10167. */
  10168. dispose(): void;
  10169. }
  10170. }
  10171. declare module BABYLON {
  10172. /**
  10173. * Single plane rotation gizmo
  10174. */
  10175. class PlaneRotationGizmo extends Gizmo {
  10176. /**
  10177. * Drag behavior responsible for the gizmos dragging interactions
  10178. */
  10179. dragBehavior: PointerDragBehavior;
  10180. private _pointerObserver;
  10181. /**
  10182. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  10183. */
  10184. snapDistance: number;
  10185. /**
  10186. * Event that fires each time the gizmo snaps to a new location.
  10187. * * snapDistance is the the change in distance
  10188. */
  10189. onSnapObservable: Observable<{
  10190. snapDistance: number;
  10191. }>;
  10192. /**
  10193. * Creates a PlaneRotationGizmo
  10194. * @param gizmoLayer The utility layer the gizmo will be added to
  10195. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  10196. * @param color The color of the gizmo
  10197. */
  10198. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  10199. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  10200. /**
  10201. * Disposes of the gizmo
  10202. */
  10203. dispose(): void;
  10204. }
  10205. }
  10206. declare module BABYLON {
  10207. /**
  10208. * Gizmo that enables dragging a mesh along 3 axis
  10209. */
  10210. class PositionGizmo extends Gizmo {
  10211. /**
  10212. * Internal gizmo used for interactions on the x axis
  10213. */
  10214. xGizmo: AxisDragGizmo;
  10215. /**
  10216. * Internal gizmo used for interactions on the y axis
  10217. */
  10218. yGizmo: AxisDragGizmo;
  10219. /**
  10220. * Internal gizmo used for interactions on the z axis
  10221. */
  10222. zGizmo: AxisDragGizmo;
  10223. attachedMesh: Nullable<AbstractMesh>;
  10224. /**
  10225. * Creates a PositionGizmo
  10226. * @param gizmoLayer The utility layer the gizmo will be added to
  10227. */
  10228. constructor(gizmoLayer?: UtilityLayerRenderer);
  10229. updateGizmoRotationToMatchAttachedMesh: boolean;
  10230. /**
  10231. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10232. */
  10233. snapDistance: number;
  10234. /**
  10235. * Ratio for the scale of the gizmo (Default: 1)
  10236. */
  10237. scaleRatio: number;
  10238. /**
  10239. * Disposes of the gizmo
  10240. */
  10241. dispose(): void;
  10242. /**
  10243. * CustomMeshes are not supported by this gizmo
  10244. * @param mesh The mesh to replace the default mesh of the gizmo
  10245. */
  10246. setCustomMesh(mesh: Mesh): void;
  10247. }
  10248. }
  10249. declare module BABYLON {
  10250. /**
  10251. * Gizmo that enables rotating a mesh along 3 axis
  10252. */
  10253. class RotationGizmo extends Gizmo {
  10254. /**
  10255. * Internal gizmo used for interactions on the x axis
  10256. */
  10257. xGizmo: PlaneRotationGizmo;
  10258. /**
  10259. * Internal gizmo used for interactions on the y axis
  10260. */
  10261. yGizmo: PlaneRotationGizmo;
  10262. /**
  10263. * Internal gizmo used for interactions on the z axis
  10264. */
  10265. zGizmo: PlaneRotationGizmo;
  10266. attachedMesh: Nullable<AbstractMesh>;
  10267. /**
  10268. * Creates a RotationGizmo
  10269. * @param gizmoLayer The utility layer the gizmo will be added to
  10270. */
  10271. constructor(gizmoLayer?: UtilityLayerRenderer);
  10272. updateGizmoRotationToMatchAttachedMesh: boolean;
  10273. /**
  10274. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10275. */
  10276. snapDistance: number;
  10277. /**
  10278. * Ratio for the scale of the gizmo (Default: 1)
  10279. */
  10280. scaleRatio: number;
  10281. /**
  10282. * Disposes of the gizmo
  10283. */
  10284. dispose(): void;
  10285. /**
  10286. * CustomMeshes are not supported by this gizmo
  10287. * @param mesh The mesh to replace the default mesh of the gizmo
  10288. */
  10289. setCustomMesh(mesh: Mesh): void;
  10290. }
  10291. }
  10292. declare module BABYLON {
  10293. /**
  10294. * Gizmo that enables scaling a mesh along 3 axis
  10295. */
  10296. class ScaleGizmo extends Gizmo {
  10297. /**
  10298. * Internal gizmo used for interactions on the x axis
  10299. */
  10300. xGizmo: AxisScaleGizmo;
  10301. /**
  10302. * Internal gizmo used for interactions on the y axis
  10303. */
  10304. yGizmo: AxisScaleGizmo;
  10305. /**
  10306. * Internal gizmo used for interactions on the z axis
  10307. */
  10308. zGizmo: AxisScaleGizmo;
  10309. /**
  10310. * @hidden
  10311. * Internal gizmo used to scale all axis equally
  10312. */
  10313. private _uniformGizmo;
  10314. attachedMesh: Nullable<AbstractMesh>;
  10315. /**
  10316. * Creates a ScaleGizmo
  10317. * @param gizmoLayer The utility layer the gizmo will be added to
  10318. */
  10319. constructor(gizmoLayer?: UtilityLayerRenderer);
  10320. updateGizmoRotationToMatchAttachedMesh: boolean;
  10321. /**
  10322. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  10323. */
  10324. snapDistance: number;
  10325. /**
  10326. * Ratio for the scale of the gizmo (Default: 1)
  10327. */
  10328. scaleRatio: number;
  10329. /**
  10330. * Disposes of the gizmo
  10331. */
  10332. dispose(): void;
  10333. }
  10334. }
  10335. declare module BABYLON {
  10336. /**
  10337. * Represents the different options available during the creation of
  10338. * a Environment helper.
  10339. *
  10340. * This can control the default ground, skybox and image processing setup of your scene.
  10341. */
  10342. interface IEnvironmentHelperOptions {
  10343. /**
  10344. * Specifies wether or not to create a ground.
  10345. * True by default.
  10346. */
  10347. createGround: boolean;
  10348. /**
  10349. * Specifies the ground size.
  10350. * 15 by default.
  10351. */
  10352. groundSize: number;
  10353. /**
  10354. * The texture used on the ground for the main color.
  10355. * Comes from the BabylonJS CDN by default.
  10356. *
  10357. * Remarks: Can be either a texture or a url.
  10358. */
  10359. groundTexture: string | BaseTexture;
  10360. /**
  10361. * The color mixed in the ground texture by default.
  10362. * BabylonJS clearColor by default.
  10363. */
  10364. groundColor: Color3;
  10365. /**
  10366. * Specifies the ground opacity.
  10367. * 1 by default.
  10368. */
  10369. groundOpacity: number;
  10370. /**
  10371. * Enables the ground to receive shadows.
  10372. * True by default.
  10373. */
  10374. enableGroundShadow: boolean;
  10375. /**
  10376. * Helps preventing the shadow to be fully black on the ground.
  10377. * 0.5 by default.
  10378. */
  10379. groundShadowLevel: number;
  10380. /**
  10381. * Creates a mirror texture attach to the ground.
  10382. * false by default.
  10383. */
  10384. enableGroundMirror: boolean;
  10385. /**
  10386. * Specifies the ground mirror size ratio.
  10387. * 0.3 by default as the default kernel is 64.
  10388. */
  10389. groundMirrorSizeRatio: number;
  10390. /**
  10391. * Specifies the ground mirror blur kernel size.
  10392. * 64 by default.
  10393. */
  10394. groundMirrorBlurKernel: number;
  10395. /**
  10396. * Specifies the ground mirror visibility amount.
  10397. * 1 by default
  10398. */
  10399. groundMirrorAmount: number;
  10400. /**
  10401. * Specifies the ground mirror reflectance weight.
  10402. * This uses the standard weight of the background material to setup the fresnel effect
  10403. * of the mirror.
  10404. * 1 by default.
  10405. */
  10406. groundMirrorFresnelWeight: number;
  10407. /**
  10408. * Specifies the ground mirror Falloff distance.
  10409. * This can helps reducing the size of the reflection.
  10410. * 0 by Default.
  10411. */
  10412. groundMirrorFallOffDistance: number;
  10413. /**
  10414. * Specifies the ground mirror texture type.
  10415. * Unsigned Int by Default.
  10416. */
  10417. groundMirrorTextureType: number;
  10418. /**
  10419. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  10420. * the shown objects.
  10421. */
  10422. groundYBias: number;
  10423. /**
  10424. * Specifies wether or not to create a skybox.
  10425. * True by default.
  10426. */
  10427. createSkybox: boolean;
  10428. /**
  10429. * Specifies the skybox size.
  10430. * 20 by default.
  10431. */
  10432. skyboxSize: number;
  10433. /**
  10434. * The texture used on the skybox for the main color.
  10435. * Comes from the BabylonJS CDN by default.
  10436. *
  10437. * Remarks: Can be either a texture or a url.
  10438. */
  10439. skyboxTexture: string | BaseTexture;
  10440. /**
  10441. * The color mixed in the skybox texture by default.
  10442. * BabylonJS clearColor by default.
  10443. */
  10444. skyboxColor: Color3;
  10445. /**
  10446. * The background rotation around the Y axis of the scene.
  10447. * This helps aligning the key lights of your scene with the background.
  10448. * 0 by default.
  10449. */
  10450. backgroundYRotation: number;
  10451. /**
  10452. * Compute automatically the size of the elements to best fit with the scene.
  10453. */
  10454. sizeAuto: boolean;
  10455. /**
  10456. * Default position of the rootMesh if autoSize is not true.
  10457. */
  10458. rootPosition: Vector3;
  10459. /**
  10460. * Sets up the image processing in the scene.
  10461. * true by default.
  10462. */
  10463. setupImageProcessing: boolean;
  10464. /**
  10465. * The texture used as your environment texture in the scene.
  10466. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  10467. *
  10468. * Remarks: Can be either a texture or a url.
  10469. */
  10470. environmentTexture: string | BaseTexture;
  10471. /**
  10472. * The value of the exposure to apply to the scene.
  10473. * 0.6 by default if setupImageProcessing is true.
  10474. */
  10475. cameraExposure: number;
  10476. /**
  10477. * The value of the contrast to apply to the scene.
  10478. * 1.6 by default if setupImageProcessing is true.
  10479. */
  10480. cameraContrast: number;
  10481. /**
  10482. * Specifies wether or not tonemapping should be enabled in the scene.
  10483. * true by default if setupImageProcessing is true.
  10484. */
  10485. toneMappingEnabled: boolean;
  10486. }
  10487. /**
  10488. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  10489. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  10490. * It also helps with the default setup of your imageProcessing configuration.
  10491. */
  10492. class EnvironmentHelper {
  10493. /**
  10494. * Default ground texture URL.
  10495. */
  10496. private static _groundTextureCDNUrl;
  10497. /**
  10498. * Default skybox texture URL.
  10499. */
  10500. private static _skyboxTextureCDNUrl;
  10501. /**
  10502. * Default environment texture URL.
  10503. */
  10504. private static _environmentTextureCDNUrl;
  10505. /**
  10506. * Creates the default options for the helper.
  10507. */
  10508. private static _getDefaultOptions;
  10509. private _rootMesh;
  10510. /**
  10511. * Gets the root mesh created by the helper.
  10512. */
  10513. readonly rootMesh: Mesh;
  10514. private _skybox;
  10515. /**
  10516. * Gets the skybox created by the helper.
  10517. */
  10518. readonly skybox: Nullable<Mesh>;
  10519. private _skyboxTexture;
  10520. /**
  10521. * Gets the skybox texture created by the helper.
  10522. */
  10523. readonly skyboxTexture: Nullable<BaseTexture>;
  10524. private _skyboxMaterial;
  10525. /**
  10526. * Gets the skybox material created by the helper.
  10527. */
  10528. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  10529. private _ground;
  10530. /**
  10531. * Gets the ground mesh created by the helper.
  10532. */
  10533. readonly ground: Nullable<Mesh>;
  10534. private _groundTexture;
  10535. /**
  10536. * Gets the ground texture created by the helper.
  10537. */
  10538. readonly groundTexture: Nullable<BaseTexture>;
  10539. private _groundMirror;
  10540. /**
  10541. * Gets the ground mirror created by the helper.
  10542. */
  10543. readonly groundMirror: Nullable<MirrorTexture>;
  10544. /**
  10545. * Gets the ground mirror render list to helps pushing the meshes
  10546. * you wish in the ground reflection.
  10547. */
  10548. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  10549. private _groundMaterial;
  10550. /**
  10551. * Gets the ground material created by the helper.
  10552. */
  10553. readonly groundMaterial: Nullable<BackgroundMaterial>;
  10554. /**
  10555. * Stores the creation options.
  10556. */
  10557. private readonly _scene;
  10558. private _options;
  10559. /**
  10560. * This observable will be notified with any error during the creation of the environment,
  10561. * mainly texture creation errors.
  10562. */
  10563. onErrorObservable: Observable<{
  10564. message?: string;
  10565. exception?: any;
  10566. }>;
  10567. /**
  10568. * constructor
  10569. * @param options
  10570. * @param scene The scene to add the material to
  10571. */
  10572. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  10573. /**
  10574. * Updates the background according to the new options
  10575. * @param options
  10576. */
  10577. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  10578. /**
  10579. * Sets the primary color of all the available elements.
  10580. * @param color the main color to affect to the ground and the background
  10581. */
  10582. setMainColor(color: Color3): void;
  10583. /**
  10584. * Setup the image processing according to the specified options.
  10585. */
  10586. private _setupImageProcessing;
  10587. /**
  10588. * Setup the environment texture according to the specified options.
  10589. */
  10590. private _setupEnvironmentTexture;
  10591. /**
  10592. * Setup the background according to the specified options.
  10593. */
  10594. private _setupBackground;
  10595. /**
  10596. * Get the scene sizes according to the setup.
  10597. */
  10598. private _getSceneSize;
  10599. /**
  10600. * Setup the ground according to the specified options.
  10601. */
  10602. private _setupGround;
  10603. /**
  10604. * Setup the ground material according to the specified options.
  10605. */
  10606. private _setupGroundMaterial;
  10607. /**
  10608. * Setup the ground diffuse texture according to the specified options.
  10609. */
  10610. private _setupGroundDiffuseTexture;
  10611. /**
  10612. * Setup the ground mirror texture according to the specified options.
  10613. */
  10614. private _setupGroundMirrorTexture;
  10615. /**
  10616. * Setup the ground to receive the mirror texture.
  10617. */
  10618. private _setupMirrorInGroundMaterial;
  10619. /**
  10620. * Setup the skybox according to the specified options.
  10621. */
  10622. private _setupSkybox;
  10623. /**
  10624. * Setup the skybox material according to the specified options.
  10625. */
  10626. private _setupSkyboxMaterial;
  10627. /**
  10628. * Setup the skybox reflection texture according to the specified options.
  10629. */
  10630. private _setupSkyboxReflectionTexture;
  10631. private _errorHandler;
  10632. /**
  10633. * Dispose all the elements created by the Helper.
  10634. */
  10635. dispose(): void;
  10636. }
  10637. }
  10638. declare module BABYLON {
  10639. /**
  10640. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  10641. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  10642. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  10643. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10644. */
  10645. class PhotoDome extends TransformNode {
  10646. private _useDirectMapping;
  10647. /**
  10648. * The texture being displayed on the sphere
  10649. */
  10650. protected _photoTexture: Texture;
  10651. /**
  10652. * Gets or sets the texture being displayed on the sphere
  10653. */
  10654. photoTexture: Texture;
  10655. /**
  10656. * Observable raised when an error occured while loading the 360 image
  10657. */
  10658. onLoadErrorObservable: Observable<string>;
  10659. /**
  10660. * The skybox material
  10661. */
  10662. protected _material: BackgroundMaterial;
  10663. /**
  10664. * The surface used for the skybox
  10665. */
  10666. protected _mesh: Mesh;
  10667. /**
  10668. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10669. * Also see the options.resolution property.
  10670. */
  10671. fovMultiplier: number;
  10672. /**
  10673. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  10674. * @param name Element's name, child elements will append suffixes for their own names.
  10675. * @param urlsOfPhoto defines the url of the photo to display
  10676. * @param options defines an object containing optional or exposed sub element properties
  10677. * @param onError defines a callback called when an error occured while loading the texture
  10678. */
  10679. constructor(name: string, urlOfPhoto: string, options: {
  10680. resolution?: number;
  10681. size?: number;
  10682. useDirectMapping?: boolean;
  10683. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  10684. /**
  10685. * Releases resources associated with this node.
  10686. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10687. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10688. */
  10689. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10690. }
  10691. }
  10692. declare module BABYLON {
  10693. interface Scene {
  10694. /**
  10695. * Creates a default light for the scene.
  10696. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  10697. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  10698. */
  10699. createDefaultLight(replace?: boolean): void;
  10700. /**
  10701. * Creates a default camera for the scene.
  10702. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  10703. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  10704. * @param replace has default false, when true replaces the active camera in the scene
  10705. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  10706. */
  10707. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  10708. /**
  10709. * Creates a default camera and a default light.
  10710. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  10711. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  10712. * @param replace has the default false, when true replaces the active camera/light in the scene
  10713. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  10714. */
  10715. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  10716. /**
  10717. * Creates a new sky box
  10718. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  10719. * @param environmentTexture defines the texture to use as environment texture
  10720. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  10721. * @param scale defines the overall scale of the skybox
  10722. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  10723. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  10724. * @returns a new mesh holding the sky box
  10725. */
  10726. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  10727. /**
  10728. * Creates a new environment
  10729. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  10730. * @param options defines the options you can use to configure the environment
  10731. * @returns the new EnvironmentHelper
  10732. */
  10733. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  10734. /**
  10735. * Creates a new VREXperienceHelper
  10736. * @see http://doc.babylonjs.com/how_to/webvr_helper
  10737. * @param webVROptions defines the options used to create the new VREXperienceHelper
  10738. * @returns a new VREXperienceHelper
  10739. */
  10740. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  10741. }
  10742. }
  10743. declare module BABYLON {
  10744. /**
  10745. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  10746. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  10747. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  10748. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10749. */
  10750. class VideoDome extends TransformNode {
  10751. private _useDirectMapping;
  10752. /**
  10753. * The video texture being displayed on the sphere
  10754. */
  10755. protected _videoTexture: VideoTexture;
  10756. /**
  10757. * Gets the video texture being displayed on the sphere
  10758. */
  10759. readonly videoTexture: VideoTexture;
  10760. /**
  10761. * The skybox material
  10762. */
  10763. protected _material: BackgroundMaterial;
  10764. /**
  10765. * The surface used for the skybox
  10766. */
  10767. protected _mesh: Mesh;
  10768. /**
  10769. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10770. * Also see the options.resolution property.
  10771. */
  10772. fovMultiplier: number;
  10773. /**
  10774. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  10775. * @param name Element's name, child elements will append suffixes for their own names.
  10776. * @param urlsOrVideo defines the url(s) or the video element to use
  10777. * @param options An object containing optional or exposed sub element properties
  10778. */
  10779. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  10780. resolution?: number;
  10781. clickToPlay?: boolean;
  10782. autoPlay?: boolean;
  10783. loop?: boolean;
  10784. size?: number;
  10785. poster?: string;
  10786. useDirectMapping?: boolean;
  10787. }, scene: Scene);
  10788. /**
  10789. * Releases resources associated with this node.
  10790. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10791. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10792. */
  10793. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10794. }
  10795. }
  10796. declare module BABYLON {
  10797. /**
  10798. * This class can be used to get instrumentation data from a Babylon engine
  10799. */
  10800. class EngineInstrumentation implements IDisposable {
  10801. engine: Engine;
  10802. private _captureGPUFrameTime;
  10803. private _gpuFrameTimeToken;
  10804. private _gpuFrameTime;
  10805. private _captureShaderCompilationTime;
  10806. private _shaderCompilationTime;
  10807. private _onBeginFrameObserver;
  10808. private _onEndFrameObserver;
  10809. private _onBeforeShaderCompilationObserver;
  10810. private _onAfterShaderCompilationObserver;
  10811. /**
  10812. * Gets the perf counter used for GPU frame time
  10813. */
  10814. readonly gpuFrameTimeCounter: PerfCounter;
  10815. /**
  10816. * Gets the GPU frame time capture status
  10817. */
  10818. /**
  10819. * Enable or disable the GPU frame time capture
  10820. */
  10821. captureGPUFrameTime: boolean;
  10822. /**
  10823. * Gets the perf counter used for shader compilation time
  10824. */
  10825. readonly shaderCompilationTimeCounter: PerfCounter;
  10826. /**
  10827. * Gets the shader compilation time capture status
  10828. */
  10829. /**
  10830. * Enable or disable the shader compilation time capture
  10831. */
  10832. captureShaderCompilationTime: boolean;
  10833. constructor(engine: Engine);
  10834. dispose(): void;
  10835. }
  10836. }
  10837. declare module BABYLON {
  10838. /**
  10839. * This class can be used to get instrumentation data from a Babylon engine
  10840. */
  10841. class SceneInstrumentation implements IDisposable {
  10842. scene: Scene;
  10843. private _captureActiveMeshesEvaluationTime;
  10844. private _activeMeshesEvaluationTime;
  10845. private _captureRenderTargetsRenderTime;
  10846. private _renderTargetsRenderTime;
  10847. private _captureFrameTime;
  10848. private _frameTime;
  10849. private _captureRenderTime;
  10850. private _renderTime;
  10851. private _captureInterFrameTime;
  10852. private _interFrameTime;
  10853. private _captureParticlesRenderTime;
  10854. private _particlesRenderTime;
  10855. private _captureSpritesRenderTime;
  10856. private _spritesRenderTime;
  10857. private _capturePhysicsTime;
  10858. private _physicsTime;
  10859. private _captureAnimationsTime;
  10860. private _animationsTime;
  10861. private _captureCameraRenderTime;
  10862. private _cameraRenderTime;
  10863. private _onBeforeActiveMeshesEvaluationObserver;
  10864. private _onAfterActiveMeshesEvaluationObserver;
  10865. private _onBeforeRenderTargetsRenderObserver;
  10866. private _onAfterRenderTargetsRenderObserver;
  10867. private _onAfterRenderObserver;
  10868. private _onBeforeDrawPhaseObserver;
  10869. private _onAfterDrawPhaseObserver;
  10870. private _onBeforeAnimationsObserver;
  10871. private _onBeforeParticlesRenderingObserver;
  10872. private _onAfterParticlesRenderingObserver;
  10873. private _onBeforeSpritesRenderingObserver;
  10874. private _onAfterSpritesRenderingObserver;
  10875. private _onBeforePhysicsObserver;
  10876. private _onAfterPhysicsObserver;
  10877. private _onAfterAnimationsObserver;
  10878. private _onBeforeCameraRenderObserver;
  10879. private _onAfterCameraRenderObserver;
  10880. /**
  10881. * Gets the perf counter used for active meshes evaluation time
  10882. */
  10883. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  10884. /**
  10885. * Gets the active meshes evaluation time capture status
  10886. */
  10887. /**
  10888. * Enable or disable the active meshes evaluation time capture
  10889. */
  10890. captureActiveMeshesEvaluationTime: boolean;
  10891. /**
  10892. * Gets the perf counter used for render targets render time
  10893. */
  10894. readonly renderTargetsRenderTimeCounter: PerfCounter;
  10895. /**
  10896. * Gets the render targets render time capture status
  10897. */
  10898. /**
  10899. * Enable or disable the render targets render time capture
  10900. */
  10901. captureRenderTargetsRenderTime: boolean;
  10902. /**
  10903. * Gets the perf counter used for particles render time
  10904. */
  10905. readonly particlesRenderTimeCounter: PerfCounter;
  10906. /**
  10907. * Gets the particles render time capture status
  10908. */
  10909. /**
  10910. * Enable or disable the particles render time capture
  10911. */
  10912. captureParticlesRenderTime: boolean;
  10913. /**
  10914. * Gets the perf counter used for sprites render time
  10915. */
  10916. readonly spritesRenderTimeCounter: PerfCounter;
  10917. /**
  10918. * Gets the sprites render time capture status
  10919. */
  10920. /**
  10921. * Enable or disable the sprites render time capture
  10922. */
  10923. captureSpritesRenderTime: boolean;
  10924. /**
  10925. * Gets the perf counter used for physics time
  10926. */
  10927. readonly physicsTimeCounter: PerfCounter;
  10928. /**
  10929. * Gets the physics time capture status
  10930. */
  10931. /**
  10932. * Enable or disable the physics time capture
  10933. */
  10934. capturePhysicsTime: boolean;
  10935. /**
  10936. * Gets the perf counter used for animations time
  10937. */
  10938. readonly animationsTimeCounter: PerfCounter;
  10939. /**
  10940. * Gets the animations time capture status
  10941. */
  10942. /**
  10943. * Enable or disable the animations time capture
  10944. */
  10945. captureAnimationsTime: boolean;
  10946. /**
  10947. * Gets the perf counter used for frame time capture
  10948. */
  10949. readonly frameTimeCounter: PerfCounter;
  10950. /**
  10951. * Gets the frame time capture status
  10952. */
  10953. /**
  10954. * Enable or disable the frame time capture
  10955. */
  10956. captureFrameTime: boolean;
  10957. /**
  10958. * Gets the perf counter used for inter-frames time capture
  10959. */
  10960. readonly interFrameTimeCounter: PerfCounter;
  10961. /**
  10962. * Gets the inter-frames time capture status
  10963. */
  10964. /**
  10965. * Enable or disable the inter-frames time capture
  10966. */
  10967. captureInterFrameTime: boolean;
  10968. /**
  10969. * Gets the perf counter used for render time capture
  10970. */
  10971. readonly renderTimeCounter: PerfCounter;
  10972. /**
  10973. * Gets the render time capture status
  10974. */
  10975. /**
  10976. * Enable or disable the render time capture
  10977. */
  10978. captureRenderTime: boolean;
  10979. /**
  10980. * Gets the perf counter used for camera render time capture
  10981. */
  10982. readonly cameraRenderTimeCounter: PerfCounter;
  10983. /**
  10984. * Gets the camera render time capture status
  10985. */
  10986. /**
  10987. * Enable or disable the camera render time capture
  10988. */
  10989. captureCameraRenderTime: boolean;
  10990. /**
  10991. * Gets the perf counter used for draw calls
  10992. */
  10993. readonly drawCallsCounter: PerfCounter;
  10994. /**
  10995. * Gets the perf counter used for texture collisions
  10996. */
  10997. readonly textureCollisionsCounter: PerfCounter;
  10998. constructor(scene: Scene);
  10999. dispose(): void;
  11000. }
  11001. }
  11002. declare module BABYLON {
  11003. /**
  11004. * @hidden
  11005. **/
  11006. class _TimeToken {
  11007. _startTimeQuery: Nullable<WebGLQuery>;
  11008. _endTimeQuery: Nullable<WebGLQuery>;
  11009. _timeElapsedQuery: Nullable<WebGLQuery>;
  11010. _timeElapsedQueryEnded: boolean;
  11011. }
  11012. }
  11013. declare module BABYLON {
  11014. /**
  11015. * Effect layer options. This helps customizing the behaviour
  11016. * of the effect layer.
  11017. */
  11018. interface IEffectLayerOptions {
  11019. /**
  11020. * Multiplication factor apply to the canvas size to compute the render target size
  11021. * used to generated the objects (the smaller the faster).
  11022. */
  11023. mainTextureRatio: number;
  11024. /**
  11025. * Enforces a fixed size texture to ensure effect stability across devices.
  11026. */
  11027. mainTextureFixedSize?: number;
  11028. /**
  11029. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  11030. */
  11031. alphaBlendingMode: number;
  11032. /**
  11033. * The camera attached to the layer.
  11034. */
  11035. camera: Nullable<Camera>;
  11036. /**
  11037. * The rendering group to draw the layer in.
  11038. */
  11039. renderingGroupId: number;
  11040. }
  11041. /**
  11042. * The effect layer Helps adding post process effect blended with the main pass.
  11043. *
  11044. * This can be for instance use to generate glow or higlight effects on the scene.
  11045. *
  11046. * The effect layer class can not be used directly and is intented to inherited from to be
  11047. * customized per effects.
  11048. */
  11049. abstract class EffectLayer {
  11050. private _vertexBuffers;
  11051. private _indexBuffer;
  11052. private _cachedDefines;
  11053. private _effectLayerMapGenerationEffect;
  11054. private _effectLayerOptions;
  11055. private _mergeEffect;
  11056. protected _scene: Scene;
  11057. protected _engine: Engine;
  11058. protected _maxSize: number;
  11059. protected _mainTextureDesiredSize: ISize;
  11060. protected _mainTexture: RenderTargetTexture;
  11061. protected _shouldRender: boolean;
  11062. protected _postProcesses: PostProcess[];
  11063. protected _textures: BaseTexture[];
  11064. protected _emissiveTextureAndColor: {
  11065. texture: Nullable<BaseTexture>;
  11066. color: Color4;
  11067. };
  11068. /**
  11069. * The name of the layer
  11070. */
  11071. name: string;
  11072. /**
  11073. * The clear color of the texture used to generate the glow map.
  11074. */
  11075. neutralColor: Color4;
  11076. /**
  11077. * Specifies wether the highlight layer is enabled or not.
  11078. */
  11079. isEnabled: boolean;
  11080. /**
  11081. * Gets the camera attached to the layer.
  11082. */
  11083. readonly camera: Nullable<Camera>;
  11084. /**
  11085. * Gets the rendering group id the layer should render in.
  11086. */
  11087. readonly renderingGroupId: number;
  11088. /**
  11089. * An event triggered when the effect layer has been disposed.
  11090. */
  11091. onDisposeObservable: Observable<EffectLayer>;
  11092. /**
  11093. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  11094. */
  11095. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  11096. /**
  11097. * An event triggered when the generated texture is being merged in the scene.
  11098. */
  11099. onBeforeComposeObservable: Observable<EffectLayer>;
  11100. /**
  11101. * An event triggered when the generated texture has been merged in the scene.
  11102. */
  11103. onAfterComposeObservable: Observable<EffectLayer>;
  11104. /**
  11105. * An event triggered when the efffect layer changes its size.
  11106. */
  11107. onSizeChangedObservable: Observable<EffectLayer>;
  11108. /**
  11109. * Instantiates a new effect Layer and references it in the scene.
  11110. * @param name The name of the layer
  11111. * @param scene The scene to use the layer in
  11112. */
  11113. constructor(
  11114. /** The Friendly of the effect in the scene */
  11115. name: string, scene: Scene);
  11116. /**
  11117. * Get the effect name of the layer.
  11118. * @return The effect name
  11119. */
  11120. abstract getEffectName(): string;
  11121. /**
  11122. * Checks for the readiness of the element composing the layer.
  11123. * @param subMesh the mesh to check for
  11124. * @param useInstances specify wether or not to use instances to render the mesh
  11125. * @return true if ready otherwise, false
  11126. */
  11127. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11128. /**
  11129. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11130. * @returns true if the effect requires stencil during the main canvas render pass.
  11131. */
  11132. abstract needStencil(): boolean;
  11133. /**
  11134. * Create the merge effect. This is the shader use to blit the information back
  11135. * to the main canvas at the end of the scene rendering.
  11136. * @returns The effect containing the shader used to merge the effect on the main canvas
  11137. */
  11138. protected abstract _createMergeEffect(): Effect;
  11139. /**
  11140. * Creates the render target textures and post processes used in the effect layer.
  11141. */
  11142. protected abstract _createTextureAndPostProcesses(): void;
  11143. /**
  11144. * Implementation specific of rendering the generating effect on the main canvas.
  11145. * @param effect The effect used to render through
  11146. */
  11147. protected abstract _internalRender(effect: Effect): void;
  11148. /**
  11149. * Sets the required values for both the emissive texture and and the main color.
  11150. */
  11151. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11152. /**
  11153. * Free any resources and references associated to a mesh.
  11154. * Internal use
  11155. * @param mesh The mesh to free.
  11156. */
  11157. abstract _disposeMesh(mesh: Mesh): void;
  11158. /**
  11159. * Serializes this layer (Glow or Highlight for example)
  11160. * @returns a serialized layer object
  11161. */
  11162. abstract serialize?(): any;
  11163. /**
  11164. * Initializes the effect layer with the required options.
  11165. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  11166. */
  11167. protected _init(options: Partial<IEffectLayerOptions>): void;
  11168. /**
  11169. * Generates the index buffer of the full screen quad blending to the main canvas.
  11170. */
  11171. private _generateIndexBuffer;
  11172. /**
  11173. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  11174. */
  11175. private _genrateVertexBuffer;
  11176. /**
  11177. * Sets the main texture desired size which is the closest power of two
  11178. * of the engine canvas size.
  11179. */
  11180. private _setMainTextureSize;
  11181. /**
  11182. * Creates the main texture for the effect layer.
  11183. */
  11184. protected _createMainTexture(): void;
  11185. /**
  11186. * Checks for the readiness of the element composing the layer.
  11187. * @param subMesh the mesh to check for
  11188. * @param useInstances specify wether or not to use instances to render the mesh
  11189. * @param emissiveTexture the associated emissive texture used to generate the glow
  11190. * @return true if ready otherwise, false
  11191. */
  11192. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  11193. /**
  11194. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  11195. */
  11196. render(): void;
  11197. /**
  11198. * Determine if a given mesh will be used in the current effect.
  11199. * @param mesh mesh to test
  11200. * @returns true if the mesh will be used
  11201. */
  11202. hasMesh(mesh: AbstractMesh): boolean;
  11203. /**
  11204. * Returns true if the layer contains information to display, otherwise false.
  11205. * @returns true if the glow layer should be rendered
  11206. */
  11207. shouldRender(): boolean;
  11208. /**
  11209. * Returns true if the mesh should render, otherwise false.
  11210. * @param mesh The mesh to render
  11211. * @returns true if it should render otherwise false
  11212. */
  11213. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11214. /**
  11215. * Returns true if the mesh should render, otherwise false.
  11216. * @param mesh The mesh to render
  11217. * @returns true if it should render otherwise false
  11218. */
  11219. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  11220. /**
  11221. * Renders the submesh passed in parameter to the generation map.
  11222. */
  11223. protected _renderSubMesh(subMesh: SubMesh): void;
  11224. /**
  11225. * Rebuild the required buffers.
  11226. * @hidden Internal use only.
  11227. */
  11228. _rebuild(): void;
  11229. /**
  11230. * Dispose only the render target textures and post process.
  11231. */
  11232. private _disposeTextureAndPostProcesses;
  11233. /**
  11234. * Dispose the highlight layer and free resources.
  11235. */
  11236. dispose(): void;
  11237. /**
  11238. * Gets the class name of the effect layer
  11239. * @returns the string with the class name of the effect layer
  11240. */
  11241. getClassName(): string;
  11242. /**
  11243. * Creates an effect layer from parsed effect layer data
  11244. * @param parsedEffectLayer defines effect layer data
  11245. * @param scene defines the current scene
  11246. * @param rootUrl defines the root URL containing the effect layer information
  11247. * @returns a parsed effect Layer
  11248. */
  11249. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  11250. }
  11251. }
  11252. declare module BABYLON {
  11253. interface AbstractScene {
  11254. /**
  11255. * The list of effect layers (highlights/glow) added to the scene
  11256. * @see http://doc.babylonjs.com/how_to/highlight_layer
  11257. * @see http://doc.babylonjs.com/how_to/glow_layer
  11258. */
  11259. effectLayers: Array<EffectLayer>;
  11260. /**
  11261. * Removes the given effect layer from this scene.
  11262. * @param toRemove defines the effect layer to remove
  11263. * @returns the index of the removed effect layer
  11264. */
  11265. removeEffectLayer(toRemove: EffectLayer): number;
  11266. /**
  11267. * Adds the given effect layer to this scene
  11268. * @param newEffectLayer defines the effect layer to add
  11269. */
  11270. addEffectLayer(newEffectLayer: EffectLayer): void;
  11271. }
  11272. /**
  11273. * Defines the layer scene component responsible to manage any effect layers
  11274. * in a given scene.
  11275. */
  11276. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  11277. /**
  11278. * The component name helpfull to identify the component in the list of scene components.
  11279. */
  11280. readonly name: string;
  11281. /**
  11282. * The scene the component belongs to.
  11283. */
  11284. scene: Scene;
  11285. private _engine;
  11286. private _renderEffects;
  11287. private _needStencil;
  11288. private _previousStencilState;
  11289. /**
  11290. * Creates a new instance of the component for the given scene
  11291. * @param scene Defines the scene to register the component in
  11292. */
  11293. constructor(scene: Scene);
  11294. /**
  11295. * Registers the component in a given scene
  11296. */
  11297. register(): void;
  11298. /**
  11299. * Rebuilds the elements related to this component in case of
  11300. * context lost for instance.
  11301. */
  11302. rebuild(): void;
  11303. /**
  11304. * Serializes the component data to the specified json object
  11305. * @param serializationObject The object to serialize to
  11306. */
  11307. serialize(serializationObject: any): void;
  11308. /**
  11309. * Adds all the element from the container to the scene
  11310. * @param container the container holding the elements
  11311. */
  11312. addFromContainer(container: AbstractScene): void;
  11313. /**
  11314. * Removes all the elements in the container from the scene
  11315. * @param container contains the elements to remove
  11316. */
  11317. removeFromContainer(container: AbstractScene): void;
  11318. /**
  11319. * Disposes the component and the associated ressources.
  11320. */
  11321. dispose(): void;
  11322. private _isReadyForMesh;
  11323. private _renderMainTexture;
  11324. private _setStencil;
  11325. private _setStencilBack;
  11326. private _draw;
  11327. private _drawCamera;
  11328. private _drawRenderingGroup;
  11329. }
  11330. }
  11331. declare module BABYLON {
  11332. interface AbstractScene {
  11333. /**
  11334. * Return a the first highlight layer of the scene with a given name.
  11335. * @param name The name of the highlight layer to look for.
  11336. * @return The highlight layer if found otherwise null.
  11337. */
  11338. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  11339. }
  11340. /**
  11341. * Glow layer options. This helps customizing the behaviour
  11342. * of the glow layer.
  11343. */
  11344. interface IGlowLayerOptions {
  11345. /**
  11346. * Multiplication factor apply to the canvas size to compute the render target size
  11347. * used to generated the glowing objects (the smaller the faster).
  11348. */
  11349. mainTextureRatio: number;
  11350. /**
  11351. * Enforces a fixed size texture to ensure resize independant blur.
  11352. */
  11353. mainTextureFixedSize?: number;
  11354. /**
  11355. * How big is the kernel of the blur texture.
  11356. */
  11357. blurKernelSize: number;
  11358. /**
  11359. * The camera attached to the layer.
  11360. */
  11361. camera: Nullable<Camera>;
  11362. /**
  11363. * Enable MSAA by chosing the number of samples.
  11364. */
  11365. mainTextureSamples?: number;
  11366. /**
  11367. * The rendering group to draw the layer in.
  11368. */
  11369. renderingGroupId: number;
  11370. }
  11371. /**
  11372. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  11373. *
  11374. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11375. * glowy meshes to your scene.
  11376. *
  11377. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  11378. */
  11379. class GlowLayer extends EffectLayer {
  11380. /**
  11381. * Effect Name of the layer.
  11382. */
  11383. static readonly EffectName: string;
  11384. /**
  11385. * The default blur kernel size used for the glow.
  11386. */
  11387. static DefaultBlurKernelSize: number;
  11388. /**
  11389. * The default texture size ratio used for the glow.
  11390. */
  11391. static DefaultTextureRatio: number;
  11392. /**
  11393. * Sets the kernel size of the blur.
  11394. */
  11395. /**
  11396. * Gets the kernel size of the blur.
  11397. */
  11398. blurKernelSize: number;
  11399. /**
  11400. * Sets the glow intensity.
  11401. */
  11402. /**
  11403. * Gets the glow intensity.
  11404. */
  11405. intensity: number;
  11406. private _options;
  11407. private _intensity;
  11408. private _horizontalBlurPostprocess1;
  11409. private _verticalBlurPostprocess1;
  11410. private _horizontalBlurPostprocess2;
  11411. private _verticalBlurPostprocess2;
  11412. private _blurTexture1;
  11413. private _blurTexture2;
  11414. private _postProcesses1;
  11415. private _postProcesses2;
  11416. private _includedOnlyMeshes;
  11417. private _excludedMeshes;
  11418. /**
  11419. * Callback used to let the user override the color selection on a per mesh basis
  11420. */
  11421. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  11422. /**
  11423. * Callback used to let the user override the texture selection on a per mesh basis
  11424. */
  11425. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  11426. /**
  11427. * Instantiates a new glow Layer and references it to the scene.
  11428. * @param name The name of the layer
  11429. * @param scene The scene to use the layer in
  11430. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  11431. */
  11432. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  11433. /**
  11434. * Get the effect name of the layer.
  11435. * @return The effect name
  11436. */
  11437. getEffectName(): string;
  11438. /**
  11439. * Create the merge effect. This is the shader use to blit the information back
  11440. * to the main canvas at the end of the scene rendering.
  11441. */
  11442. protected _createMergeEffect(): Effect;
  11443. /**
  11444. * Creates the render target textures and post processes used in the glow layer.
  11445. */
  11446. protected _createTextureAndPostProcesses(): void;
  11447. /**
  11448. * Checks for the readiness of the element composing the layer.
  11449. * @param subMesh the mesh to check for
  11450. * @param useInstances specify wether or not to use instances to render the mesh
  11451. * @param emissiveTexture the associated emissive texture used to generate the glow
  11452. * @return true if ready otherwise, false
  11453. */
  11454. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11455. /**
  11456. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11457. */
  11458. needStencil(): boolean;
  11459. /**
  11460. * Implementation specific of rendering the generating effect on the main canvas.
  11461. * @param effect The effect used to render through
  11462. */
  11463. protected _internalRender(effect: Effect): void;
  11464. /**
  11465. * Sets the required values for both the emissive texture and and the main color.
  11466. */
  11467. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11468. /**
  11469. * Returns true if the mesh should render, otherwise false.
  11470. * @param mesh The mesh to render
  11471. * @returns true if it should render otherwise false
  11472. */
  11473. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11474. /**
  11475. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  11476. * @param mesh The mesh to exclude from the glow layer
  11477. */
  11478. addExcludedMesh(mesh: Mesh): void;
  11479. /**
  11480. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  11481. * @param mesh The mesh to remove
  11482. */
  11483. removeExcludedMesh(mesh: Mesh): void;
  11484. /**
  11485. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  11486. * @param mesh The mesh to include in the glow layer
  11487. */
  11488. addIncludedOnlyMesh(mesh: Mesh): void;
  11489. /**
  11490. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  11491. * @param mesh The mesh to remove
  11492. */
  11493. removeIncludedOnlyMesh(mesh: Mesh): void;
  11494. /**
  11495. * Determine if a given mesh will be used in the glow layer
  11496. * @param mesh The mesh to test
  11497. * @returns true if the mesh will be highlighted by the current glow layer
  11498. */
  11499. hasMesh(mesh: AbstractMesh): boolean;
  11500. /**
  11501. * Free any resources and references associated to a mesh.
  11502. * Internal use
  11503. * @param mesh The mesh to free.
  11504. * @hidden
  11505. */
  11506. _disposeMesh(mesh: Mesh): void;
  11507. /**
  11508. * Gets the class name of the effect layer
  11509. * @returns the string with the class name of the effect layer
  11510. */
  11511. getClassName(): string;
  11512. /**
  11513. * Serializes this glow layer
  11514. * @returns a serialized glow layer object
  11515. */
  11516. serialize(): any;
  11517. /**
  11518. * Creates a Glow Layer from parsed glow layer data
  11519. * @param parsedGlowLayer defines glow layer data
  11520. * @param scene defines the current scene
  11521. * @param rootUrl defines the root URL containing the glow layer information
  11522. * @returns a parsed Glow Layer
  11523. */
  11524. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  11525. }
  11526. }
  11527. declare module BABYLON {
  11528. interface AbstractScene {
  11529. /**
  11530. * Return a the first highlight layer of the scene with a given name.
  11531. * @param name The name of the highlight layer to look for.
  11532. * @return The highlight layer if found otherwise null.
  11533. */
  11534. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  11535. }
  11536. /**
  11537. * Highlight layer options. This helps customizing the behaviour
  11538. * of the highlight layer.
  11539. */
  11540. interface IHighlightLayerOptions {
  11541. /**
  11542. * Multiplication factor apply to the canvas size to compute the render target size
  11543. * used to generated the glowing objects (the smaller the faster).
  11544. */
  11545. mainTextureRatio: number;
  11546. /**
  11547. * Enforces a fixed size texture to ensure resize independant blur.
  11548. */
  11549. mainTextureFixedSize?: number;
  11550. /**
  11551. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  11552. * of the picture to blur (the smaller the faster).
  11553. */
  11554. blurTextureSizeRatio: number;
  11555. /**
  11556. * How big in texel of the blur texture is the vertical blur.
  11557. */
  11558. blurVerticalSize: number;
  11559. /**
  11560. * How big in texel of the blur texture is the horizontal blur.
  11561. */
  11562. blurHorizontalSize: number;
  11563. /**
  11564. * Alpha blending mode used to apply the blur. Default is combine.
  11565. */
  11566. alphaBlendingMode: number;
  11567. /**
  11568. * The camera attached to the layer.
  11569. */
  11570. camera: Nullable<Camera>;
  11571. /**
  11572. * Should we display highlight as a solid stroke?
  11573. */
  11574. isStroke?: boolean;
  11575. /**
  11576. * The rendering group to draw the layer in.
  11577. */
  11578. renderingGroupId: number;
  11579. }
  11580. /**
  11581. * The highlight layer Helps adding a glow effect around a mesh.
  11582. *
  11583. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11584. * glowy meshes to your scene.
  11585. *
  11586. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  11587. */
  11588. class HighlightLayer extends EffectLayer {
  11589. name: string;
  11590. /**
  11591. * Effect Name of the highlight layer.
  11592. */
  11593. static readonly EffectName: string;
  11594. /**
  11595. * The neutral color used during the preparation of the glow effect.
  11596. * This is black by default as the blend operation is a blend operation.
  11597. */
  11598. static NeutralColor: Color4;
  11599. /**
  11600. * Stencil value used for glowing meshes.
  11601. */
  11602. static GlowingMeshStencilReference: number;
  11603. /**
  11604. * Stencil value used for the other meshes in the scene.
  11605. */
  11606. static NormalMeshStencilReference: number;
  11607. /**
  11608. * Specifies whether or not the inner glow is ACTIVE in the layer.
  11609. */
  11610. innerGlow: boolean;
  11611. /**
  11612. * Specifies whether or not the outer glow is ACTIVE in the layer.
  11613. */
  11614. outerGlow: boolean;
  11615. /**
  11616. * Specifies the horizontal size of the blur.
  11617. */
  11618. /**
  11619. * Gets the horizontal size of the blur.
  11620. */
  11621. blurHorizontalSize: number;
  11622. /**
  11623. * Specifies the vertical size of the blur.
  11624. */
  11625. /**
  11626. * Gets the vertical size of the blur.
  11627. */
  11628. blurVerticalSize: number;
  11629. /**
  11630. * An event triggered when the highlight layer is being blurred.
  11631. */
  11632. onBeforeBlurObservable: Observable<HighlightLayer>;
  11633. /**
  11634. * An event triggered when the highlight layer has been blurred.
  11635. */
  11636. onAfterBlurObservable: Observable<HighlightLayer>;
  11637. private _instanceGlowingMeshStencilReference;
  11638. private _options;
  11639. private _downSamplePostprocess;
  11640. private _horizontalBlurPostprocess;
  11641. private _verticalBlurPostprocess;
  11642. private _blurTexture;
  11643. private _meshes;
  11644. private _excludedMeshes;
  11645. /**
  11646. * Instantiates a new highlight Layer and references it to the scene..
  11647. * @param name The name of the layer
  11648. * @param scene The scene to use the layer in
  11649. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  11650. */
  11651. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  11652. /**
  11653. * Get the effect name of the layer.
  11654. * @return The effect name
  11655. */
  11656. getEffectName(): string;
  11657. /**
  11658. * Create the merge effect. This is the shader use to blit the information back
  11659. * to the main canvas at the end of the scene rendering.
  11660. */
  11661. protected _createMergeEffect(): Effect;
  11662. /**
  11663. * Creates the render target textures and post processes used in the highlight layer.
  11664. */
  11665. protected _createTextureAndPostProcesses(): void;
  11666. /**
  11667. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11668. */
  11669. needStencil(): boolean;
  11670. /**
  11671. * Checks for the readiness of the element composing the layer.
  11672. * @param subMesh the mesh to check for
  11673. * @param useInstances specify wether or not to use instances to render the mesh
  11674. * @param emissiveTexture the associated emissive texture used to generate the glow
  11675. * @return true if ready otherwise, false
  11676. */
  11677. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11678. /**
  11679. * Implementation specific of rendering the generating effect on the main canvas.
  11680. * @param effect The effect used to render through
  11681. */
  11682. protected _internalRender(effect: Effect): void;
  11683. /**
  11684. * Returns true if the layer contains information to display, otherwise false.
  11685. */
  11686. shouldRender(): boolean;
  11687. /**
  11688. * Returns true if the mesh should render, otherwise false.
  11689. * @param mesh The mesh to render
  11690. * @returns true if it should render otherwise false
  11691. */
  11692. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11693. /**
  11694. * Sets the required values for both the emissive texture and and the main color.
  11695. */
  11696. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11697. /**
  11698. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  11699. * @param mesh The mesh to exclude from the highlight layer
  11700. */
  11701. addExcludedMesh(mesh: Mesh): void;
  11702. /**
  11703. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  11704. * @param mesh The mesh to highlight
  11705. */
  11706. removeExcludedMesh(mesh: Mesh): void;
  11707. /**
  11708. * Determine if a given mesh will be highlighted by the current HighlightLayer
  11709. * @param mesh mesh to test
  11710. * @returns true if the mesh will be highlighted by the current HighlightLayer
  11711. */
  11712. hasMesh(mesh: AbstractMesh): boolean;
  11713. /**
  11714. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  11715. * @param mesh The mesh to highlight
  11716. * @param color The color of the highlight
  11717. * @param glowEmissiveOnly Extract the glow from the emissive texture
  11718. */
  11719. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  11720. /**
  11721. * Remove a mesh from the highlight layer in order to make it stop glowing.
  11722. * @param mesh The mesh to highlight
  11723. */
  11724. removeMesh(mesh: Mesh): void;
  11725. /**
  11726. * Force the stencil to the normal expected value for none glowing parts
  11727. */
  11728. private _defaultStencilReference;
  11729. /**
  11730. * Free any resources and references associated to a mesh.
  11731. * Internal use
  11732. * @param mesh The mesh to free.
  11733. * @hidden
  11734. */
  11735. _disposeMesh(mesh: Mesh): void;
  11736. /**
  11737. * Dispose the highlight layer and free resources.
  11738. */
  11739. dispose(): void;
  11740. /**
  11741. * Gets the class name of the effect layer
  11742. * @returns the string with the class name of the effect layer
  11743. */
  11744. getClassName(): string;
  11745. /**
  11746. * Serializes this Highlight layer
  11747. * @returns a serialized Highlight layer object
  11748. */
  11749. serialize(): any;
  11750. /**
  11751. * Creates a Highlight layer from parsed Highlight layer data
  11752. * @param parsedHightlightLayer defines the Highlight layer data
  11753. * @param scene defines the current scene
  11754. * @param rootUrl defines the root URL containing the Highlight layer information
  11755. * @returns a parsed Highlight layer
  11756. */
  11757. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  11758. }
  11759. }
  11760. declare module BABYLON {
  11761. class Layer {
  11762. name: string;
  11763. texture: Nullable<Texture>;
  11764. isBackground: boolean;
  11765. color: Color4;
  11766. scale: Vector2;
  11767. offset: Vector2;
  11768. alphaBlendingMode: number;
  11769. alphaTest: boolean;
  11770. layerMask: number;
  11771. private _scene;
  11772. private _vertexBuffers;
  11773. private _indexBuffer;
  11774. private _effect;
  11775. private _alphaTestEffect;
  11776. /**
  11777. * An event triggered when the layer is disposed.
  11778. */
  11779. onDisposeObservable: Observable<Layer>;
  11780. private _onDisposeObserver;
  11781. onDispose: () => void;
  11782. /**
  11783. * An event triggered before rendering the scene
  11784. */
  11785. onBeforeRenderObservable: Observable<Layer>;
  11786. private _onBeforeRenderObserver;
  11787. onBeforeRender: () => void;
  11788. /**
  11789. * An event triggered after rendering the scene
  11790. */
  11791. onAfterRenderObservable: Observable<Layer>;
  11792. private _onAfterRenderObserver;
  11793. onAfterRender: () => void;
  11794. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  11795. private _createIndexBuffer;
  11796. /** @hidden */
  11797. _rebuild(): void;
  11798. render(): void;
  11799. dispose(): void;
  11800. }
  11801. }
  11802. declare module BABYLON {
  11803. interface AbstractScene {
  11804. /**
  11805. * The list of layers (background and foreground) of the scene
  11806. */
  11807. layers: Array<Layer>;
  11808. }
  11809. /**
  11810. * Defines the layer scene component responsible to manage any layers
  11811. * in a given scene.
  11812. */
  11813. class LayerSceneComponent implements ISceneComponent {
  11814. /**
  11815. * The component name helpfull to identify the component in the list of scene components.
  11816. */
  11817. readonly name: string;
  11818. /**
  11819. * The scene the component belongs to.
  11820. */
  11821. scene: Scene;
  11822. private _engine;
  11823. /**
  11824. * Creates a new instance of the component for the given scene
  11825. * @param scene Defines the scene to register the component in
  11826. */
  11827. constructor(scene: Scene);
  11828. /**
  11829. * Registers the component in a given scene
  11830. */
  11831. register(): void;
  11832. /**
  11833. * Rebuilds the elements related to this component in case of
  11834. * context lost for instance.
  11835. */
  11836. rebuild(): void;
  11837. /**
  11838. * Disposes the component and the associated ressources.
  11839. */
  11840. dispose(): void;
  11841. private _draw;
  11842. private _drawBackground;
  11843. private _drawForeground;
  11844. }
  11845. }
  11846. declare module BABYLON {
  11847. class LensFlare {
  11848. size: number;
  11849. position: number;
  11850. color: Color3;
  11851. texture: Nullable<Texture>;
  11852. alphaMode: number;
  11853. private _system;
  11854. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  11855. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  11856. dispose(): void;
  11857. }
  11858. }
  11859. declare module BABYLON {
  11860. class LensFlareSystem {
  11861. name: string;
  11862. lensFlares: LensFlare[];
  11863. borderLimit: number;
  11864. viewportBorder: number;
  11865. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  11866. layerMask: number;
  11867. id: string;
  11868. private _scene;
  11869. private _emitter;
  11870. private _vertexBuffers;
  11871. private _indexBuffer;
  11872. private _effect;
  11873. private _positionX;
  11874. private _positionY;
  11875. private _isEnabled;
  11876. constructor(name: string, emitter: any, scene: Scene);
  11877. isEnabled: boolean;
  11878. getScene(): Scene;
  11879. getEmitter(): any;
  11880. setEmitter(newEmitter: any): void;
  11881. getEmitterPosition(): Vector3;
  11882. computeEffectivePosition(globalViewport: Viewport): boolean;
  11883. /** @hidden */
  11884. _isVisible(): boolean;
  11885. render(): boolean;
  11886. dispose(): void;
  11887. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  11888. serialize(): any;
  11889. }
  11890. }
  11891. declare module BABYLON {
  11892. interface AbstractScene {
  11893. /**
  11894. * The list of lens flare system added to the scene
  11895. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  11896. */
  11897. lensFlareSystems: Array<LensFlareSystem>;
  11898. /**
  11899. * Removes the given lens flare system from this scene.
  11900. * @param toRemove The lens flare system to remove
  11901. * @returns The index of the removed lens flare system
  11902. */
  11903. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  11904. /**
  11905. * Adds the given lens flare system to this scene
  11906. * @param newLensFlareSystem The lens flare system to add
  11907. */
  11908. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  11909. /**
  11910. * Gets a lens flare system using its name
  11911. * @param name defines the name to look for
  11912. * @returns the lens flare system or null if not found
  11913. */
  11914. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  11915. /**
  11916. * Gets a lens flare system using its id
  11917. * @param id defines the id to look for
  11918. * @returns the lens flare system or null if not found
  11919. */
  11920. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  11921. }
  11922. /**
  11923. * Defines the lens flare scene component responsible to manage any lens flares
  11924. * in a given scene.
  11925. */
  11926. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  11927. /**
  11928. * The component name helpfull to identify the component in the list of scene components.
  11929. */
  11930. readonly name: string;
  11931. /**
  11932. * The scene the component belongs to.
  11933. */
  11934. scene: Scene;
  11935. /**
  11936. * Creates a new instance of the component for the given scene
  11937. * @param scene Defines the scene to register the component in
  11938. */
  11939. constructor(scene: Scene);
  11940. /**
  11941. * Registers the component in a given scene
  11942. */
  11943. register(): void;
  11944. /**
  11945. * Rebuilds the elements related to this component in case of
  11946. * context lost for instance.
  11947. */
  11948. rebuild(): void;
  11949. /**
  11950. * Adds all the element from the container to the scene
  11951. * @param container the container holding the elements
  11952. */
  11953. addFromContainer(container: AbstractScene): void;
  11954. /**
  11955. * Removes all the elements in the container from the scene
  11956. * @param container contains the elements to remove
  11957. */
  11958. removeFromContainer(container: AbstractScene): void;
  11959. /**
  11960. * Serializes the component data to the specified json object
  11961. * @param serializationObject The object to serialize to
  11962. */
  11963. serialize(serializationObject: any): void;
  11964. /**
  11965. * Disposes the component and the associated ressources.
  11966. */
  11967. dispose(): void;
  11968. private _draw;
  11969. }
  11970. }
  11971. declare module BABYLON {
  11972. /**
  11973. * A directional light is defined by a direction (what a surprise!).
  11974. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  11975. * 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.
  11976. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11977. */
  11978. class DirectionalLight extends ShadowLight {
  11979. private _shadowFrustumSize;
  11980. /**
  11981. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  11982. */
  11983. /**
  11984. * Specifies a fix frustum size for the shadow generation.
  11985. */
  11986. shadowFrustumSize: number;
  11987. private _shadowOrthoScale;
  11988. /**
  11989. * Gets the shadow projection scale against the optimal computed one.
  11990. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11991. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11992. */
  11993. /**
  11994. * Sets the shadow projection scale against the optimal computed one.
  11995. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11996. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11997. */
  11998. shadowOrthoScale: number;
  11999. /**
  12000. * Automatically compute the projection matrix to best fit (including all the casters)
  12001. * on each frame.
  12002. */
  12003. autoUpdateExtends: boolean;
  12004. private _orthoLeft;
  12005. private _orthoRight;
  12006. private _orthoTop;
  12007. private _orthoBottom;
  12008. /**
  12009. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  12010. * The directional light is emitted from everywhere in the given direction.
  12011. * It can cast shawdows.
  12012. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12013. * @param name The friendly name of the light
  12014. * @param direction The direction of the light
  12015. * @param scene The scene the light belongs to
  12016. */
  12017. constructor(name: string, direction: Vector3, scene: Scene);
  12018. /**
  12019. * Returns the string "DirectionalLight".
  12020. * @return The class name
  12021. */
  12022. getClassName(): string;
  12023. /**
  12024. * Returns the integer 1.
  12025. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12026. */
  12027. getTypeID(): number;
  12028. /**
  12029. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  12030. * Returns the DirectionalLight Shadow projection matrix.
  12031. */
  12032. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12033. /**
  12034. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  12035. * Returns the DirectionalLight Shadow projection matrix.
  12036. */
  12037. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  12038. /**
  12039. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  12040. * Returns the DirectionalLight Shadow projection matrix.
  12041. */
  12042. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12043. protected _buildUniformLayout(): void;
  12044. /**
  12045. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  12046. * @param effect The effect to update
  12047. * @param lightIndex The index of the light in the effect to update
  12048. * @returns The directional light
  12049. */
  12050. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  12051. /**
  12052. * Gets the minZ used for shadow according to both the scene and the light.
  12053. *
  12054. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  12055. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  12056. * @param activeCamera The camera we are returning the min for
  12057. * @returns the depth min z
  12058. */
  12059. getDepthMinZ(activeCamera: Camera): number;
  12060. /**
  12061. * Gets the maxZ used for shadow according to both the scene and the light.
  12062. *
  12063. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  12064. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  12065. * @param activeCamera The camera we are returning the max for
  12066. * @returns the depth max z
  12067. */
  12068. getDepthMaxZ(activeCamera: Camera): number;
  12069. /**
  12070. * Prepares the list of defines specific to the light type.
  12071. * @param defines the list of defines
  12072. * @param lightIndex defines the index of the light for the effect
  12073. */
  12074. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12075. }
  12076. }
  12077. declare module BABYLON {
  12078. /**
  12079. * The HemisphericLight simulates the ambient environment light,
  12080. * so the passed direction is the light reflection direction, not the incoming direction.
  12081. */
  12082. class HemisphericLight extends Light {
  12083. /**
  12084. * The groundColor is the light in the opposite direction to the one specified during creation.
  12085. * 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.
  12086. */
  12087. groundColor: Color3;
  12088. /**
  12089. * The light reflection direction, not the incoming direction.
  12090. */
  12091. direction: Vector3;
  12092. /**
  12093. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12094. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12095. * The HemisphericLight can't cast shadows.
  12096. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12097. * @param name The friendly name of the light
  12098. * @param direction The direction of the light reflection
  12099. * @param scene The scene the light belongs to
  12100. */
  12101. constructor(name: string, direction: Vector3, scene: Scene);
  12102. protected _buildUniformLayout(): void;
  12103. /**
  12104. * Returns the string "HemisphericLight".
  12105. * @return The class name
  12106. */
  12107. getClassName(): string;
  12108. /**
  12109. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12110. * Returns the updated direction.
  12111. * @param target The target the direction should point to
  12112. * @return The computed direction
  12113. */
  12114. setDirectionToTarget(target: Vector3): Vector3;
  12115. /**
  12116. * Returns the shadow generator associated to the light.
  12117. * @returns Always null for hemispheric lights because it does not support shadows.
  12118. */
  12119. getShadowGenerator(): Nullable<IShadowGenerator>;
  12120. /**
  12121. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12122. * @param effect The effect to update
  12123. * @param lightIndex The index of the light in the effect to update
  12124. * @returns The hemispheric light
  12125. */
  12126. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12127. /**
  12128. * Computes the world matrix of the node
  12129. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12130. * @param useWasUpdatedFlag defines a reserved property
  12131. * @returns the world matrix
  12132. */
  12133. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  12134. /**
  12135. * Returns the integer 3.
  12136. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12137. */
  12138. getTypeID(): number;
  12139. /**
  12140. * Prepares the list of defines specific to the light type.
  12141. * @param defines the list of defines
  12142. * @param lightIndex defines the index of the light for the effect
  12143. */
  12144. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12145. }
  12146. }
  12147. declare module BABYLON {
  12148. /**
  12149. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  12150. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  12151. * 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.
  12152. */
  12153. abstract class Light extends Node {
  12154. /**
  12155. * Falloff Default: light is falling off following the material specification:
  12156. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  12157. */
  12158. static readonly FALLOFF_DEFAULT: number;
  12159. /**
  12160. * Falloff Physical: light is falling off following the inverse squared distance law.
  12161. */
  12162. static readonly FALLOFF_PHYSICAL: number;
  12163. /**
  12164. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  12165. * to enhance interoperability with other engines.
  12166. */
  12167. static readonly FALLOFF_GLTF: number;
  12168. /**
  12169. * Falloff Standard: light is falling off like in the standard material
  12170. * to enhance interoperability with other materials.
  12171. */
  12172. static readonly FALLOFF_STANDARD: number;
  12173. /**
  12174. * If every light affecting the material is in this lightmapMode,
  12175. * material.lightmapTexture adds or multiplies
  12176. * (depends on material.useLightmapAsShadowmap)
  12177. * after every other light calculations.
  12178. */
  12179. static readonly LIGHTMAP_DEFAULT: number;
  12180. /**
  12181. * material.lightmapTexture as only diffuse lighting from this light
  12182. * adds only specular lighting from this light
  12183. * adds dynamic shadows
  12184. */
  12185. static readonly LIGHTMAP_SPECULAR: number;
  12186. /**
  12187. * material.lightmapTexture as only lighting
  12188. * no light calculation from this light
  12189. * only adds dynamic shadows from this light
  12190. */
  12191. static readonly LIGHTMAP_SHADOWSONLY: number;
  12192. /**
  12193. * Each light type uses the default quantity according to its type:
  12194. * point/spot lights use luminous intensity
  12195. * directional lights use illuminance
  12196. */
  12197. static readonly INTENSITYMODE_AUTOMATIC: number;
  12198. /**
  12199. * lumen (lm)
  12200. */
  12201. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  12202. /**
  12203. * candela (lm/sr)
  12204. */
  12205. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  12206. /**
  12207. * lux (lm/m^2)
  12208. */
  12209. static readonly INTENSITYMODE_ILLUMINANCE: number;
  12210. /**
  12211. * nit (cd/m^2)
  12212. */
  12213. static readonly INTENSITYMODE_LUMINANCE: number;
  12214. /**
  12215. * Light type const id of the point light.
  12216. */
  12217. static readonly LIGHTTYPEID_POINTLIGHT: number;
  12218. /**
  12219. * Light type const id of the directional light.
  12220. */
  12221. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  12222. /**
  12223. * Light type const id of the spot light.
  12224. */
  12225. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  12226. /**
  12227. * Light type const id of the hemispheric light.
  12228. */
  12229. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  12230. /**
  12231. * Diffuse gives the basic color to an object.
  12232. */
  12233. diffuse: Color3;
  12234. /**
  12235. * Specular produces a highlight color on an object.
  12236. * Note: This is note affecting PBR materials.
  12237. */
  12238. specular: Color3;
  12239. /**
  12240. * Defines the falloff type for this light. This lets overrriding how punctual light are
  12241. * falling off base on range or angle.
  12242. * This can be set to any values in Light.FALLOFF_x.
  12243. *
  12244. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  12245. * other types of materials.
  12246. */
  12247. falloffType: number;
  12248. /**
  12249. * Strength of the light.
  12250. * Note: By default it is define in the framework own unit.
  12251. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  12252. */
  12253. intensity: number;
  12254. private _range;
  12255. protected _inverseSquaredRange: number;
  12256. /**
  12257. * Defines how far from the source the light is impacting in scene units.
  12258. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12259. */
  12260. /**
  12261. * Defines how far from the source the light is impacting in scene units.
  12262. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12263. */
  12264. range: number;
  12265. /**
  12266. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  12267. * of light.
  12268. */
  12269. private _photometricScale;
  12270. private _intensityMode;
  12271. /**
  12272. * Gets the photometric scale used to interpret the intensity.
  12273. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12274. */
  12275. /**
  12276. * Sets the photometric scale used to interpret the intensity.
  12277. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12278. */
  12279. intensityMode: number;
  12280. private _radius;
  12281. /**
  12282. * Gets the light radius used by PBR Materials to simulate soft area lights.
  12283. */
  12284. /**
  12285. * sets the light radius used by PBR Materials to simulate soft area lights.
  12286. */
  12287. radius: number;
  12288. private _renderPriority;
  12289. /**
  12290. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  12291. * exceeding the number allowed of the materials.
  12292. */
  12293. renderPriority: number;
  12294. private _shadowEnabled;
  12295. /**
  12296. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12297. * the current shadow generator.
  12298. */
  12299. /**
  12300. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12301. * the current shadow generator.
  12302. */
  12303. shadowEnabled: boolean;
  12304. private _includedOnlyMeshes;
  12305. /**
  12306. * Gets the only meshes impacted by this light.
  12307. */
  12308. /**
  12309. * Sets the only meshes impacted by this light.
  12310. */
  12311. includedOnlyMeshes: AbstractMesh[];
  12312. private _excludedMeshes;
  12313. /**
  12314. * Gets the meshes not impacted by this light.
  12315. */
  12316. /**
  12317. * Sets the meshes not impacted by this light.
  12318. */
  12319. excludedMeshes: AbstractMesh[];
  12320. private _excludeWithLayerMask;
  12321. /**
  12322. * Gets the layer id use to find what meshes are not impacted by the light.
  12323. * Inactive if 0
  12324. */
  12325. /**
  12326. * Sets the layer id use to find what meshes are not impacted by the light.
  12327. * Inactive if 0
  12328. */
  12329. excludeWithLayerMask: number;
  12330. private _includeOnlyWithLayerMask;
  12331. /**
  12332. * Gets the layer id use to find what meshes are impacted by the light.
  12333. * Inactive if 0
  12334. */
  12335. /**
  12336. * Sets the layer id use to find what meshes are impacted by the light.
  12337. * Inactive if 0
  12338. */
  12339. includeOnlyWithLayerMask: number;
  12340. private _lightmapMode;
  12341. /**
  12342. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12343. */
  12344. /**
  12345. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12346. */
  12347. lightmapMode: number;
  12348. /**
  12349. * Shadow generator associted to the light.
  12350. * @hidden Internal use only.
  12351. */
  12352. _shadowGenerator: Nullable<IShadowGenerator>;
  12353. /**
  12354. * @hidden Internal use only.
  12355. */
  12356. _excludedMeshesIds: string[];
  12357. /**
  12358. * @hidden Internal use only.
  12359. */
  12360. _includedOnlyMeshesIds: string[];
  12361. /**
  12362. * The current light unifom buffer.
  12363. * @hidden Internal use only.
  12364. */
  12365. _uniformBuffer: UniformBuffer;
  12366. /**
  12367. * Creates a Light object in the scene.
  12368. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12369. * @param name The firendly name of the light
  12370. * @param scene The scene the light belongs too
  12371. */
  12372. constructor(name: string, scene: Scene);
  12373. protected abstract _buildUniformLayout(): void;
  12374. /**
  12375. * Sets the passed Effect "effect" with the Light information.
  12376. * @param effect The effect to update
  12377. * @param lightIndex The index of the light in the effect to update
  12378. * @returns The light
  12379. */
  12380. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12381. /**
  12382. * Returns the string "Light".
  12383. * @returns the class name
  12384. */
  12385. getClassName(): string;
  12386. /**
  12387. * Converts the light information to a readable string for debug purpose.
  12388. * @param fullDetails Supports for multiple levels of logging within scene loading
  12389. * @returns the human readable light info
  12390. */
  12391. toString(fullDetails?: boolean): string;
  12392. /**
  12393. * Set the enabled state of this node.
  12394. * @param value - the new enabled state
  12395. */
  12396. setEnabled(value: boolean): void;
  12397. /**
  12398. * Returns the Light associated shadow generator if any.
  12399. * @return the associated shadow generator.
  12400. */
  12401. getShadowGenerator(): Nullable<IShadowGenerator>;
  12402. /**
  12403. * Returns a Vector3, the absolute light position in the World.
  12404. * @returns the world space position of the light
  12405. */
  12406. getAbsolutePosition(): Vector3;
  12407. /**
  12408. * Specifies if the light will affect the passed mesh.
  12409. * @param mesh The mesh to test against the light
  12410. * @return true the mesh is affected otherwise, false.
  12411. */
  12412. canAffectMesh(mesh: AbstractMesh): boolean;
  12413. /**
  12414. * Sort function to order lights for rendering.
  12415. * @param a First Light object to compare to second.
  12416. * @param b Second Light object to compare first.
  12417. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12418. */
  12419. static CompareLightsPriority(a: Light, b: Light): number;
  12420. /**
  12421. * Releases resources associated with this node.
  12422. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12423. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12424. */
  12425. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12426. /**
  12427. * Returns the light type ID (integer).
  12428. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12429. */
  12430. getTypeID(): number;
  12431. /**
  12432. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12433. * @returns the scaled intensity in intensity mode unit
  12434. */
  12435. getScaledIntensity(): number;
  12436. /**
  12437. * Returns a new Light object, named "name", from the current one.
  12438. * @param name The name of the cloned light
  12439. * @returns the new created light
  12440. */
  12441. clone(name: string): Nullable<Light>;
  12442. /**
  12443. * Serializes the current light into a Serialization object.
  12444. * @returns the serialized object.
  12445. */
  12446. serialize(): any;
  12447. /**
  12448. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12449. * This new light is named "name" and added to the passed scene.
  12450. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12451. * @param name The friendly name of the light
  12452. * @param scene The scene the new light will belong to
  12453. * @returns the constructor function
  12454. */
  12455. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12456. /**
  12457. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12458. * @param parsedLight The JSON representation of the light
  12459. * @param scene The scene to create the parsed light in
  12460. * @returns the created light after parsing
  12461. */
  12462. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12463. private _hookArrayForExcluded;
  12464. private _hookArrayForIncludedOnly;
  12465. private _resyncMeshes;
  12466. /**
  12467. * Forces the meshes to update their light related information in their rendering used effects
  12468. * @hidden Internal Use Only
  12469. */
  12470. _markMeshesAsLightDirty(): void;
  12471. /**
  12472. * Recomputes the cached photometric scale if needed.
  12473. */
  12474. private _computePhotometricScale;
  12475. /**
  12476. * Returns the Photometric Scale according to the light type and intensity mode.
  12477. */
  12478. private _getPhotometricScale;
  12479. /**
  12480. * Reorder the light in the scene according to their defined priority.
  12481. * @hidden Internal Use Only
  12482. */
  12483. _reorderLightsInScene(): void;
  12484. /**
  12485. * Prepares the list of defines specific to the light type.
  12486. * @param defines the list of defines
  12487. * @param lightIndex defines the index of the light for the effect
  12488. */
  12489. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12490. }
  12491. }
  12492. declare module BABYLON {
  12493. /**
  12494. * A point light is a light defined by an unique point in world space.
  12495. * The light is emitted in every direction from this point.
  12496. * A good example of a point light is a standard light bulb.
  12497. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12498. */
  12499. class PointLight extends ShadowLight {
  12500. private _shadowAngle;
  12501. /**
  12502. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12503. * This specifies what angle the shadow will use to be created.
  12504. *
  12505. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12506. */
  12507. /**
  12508. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12509. * This specifies what angle the shadow will use to be created.
  12510. *
  12511. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12512. */
  12513. shadowAngle: number;
  12514. /**
  12515. * Gets the direction if it has been set.
  12516. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12517. */
  12518. /**
  12519. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12520. */
  12521. direction: Vector3;
  12522. /**
  12523. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  12524. * A PointLight emits the light in every direction.
  12525. * It can cast shadows.
  12526. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  12527. * ```javascript
  12528. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  12529. * ```
  12530. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12531. * @param name The light friendly name
  12532. * @param position The position of the point light in the scene
  12533. * @param scene The scene the lights belongs to
  12534. */
  12535. constructor(name: string, position: Vector3, scene: Scene);
  12536. /**
  12537. * Returns the string "PointLight"
  12538. * @returns the class name
  12539. */
  12540. getClassName(): string;
  12541. /**
  12542. * Returns the integer 0.
  12543. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12544. */
  12545. getTypeID(): number;
  12546. /**
  12547. * Specifies wether or not the shadowmap should be a cube texture.
  12548. * @returns true if the shadowmap needs to be a cube texture.
  12549. */
  12550. needCube(): boolean;
  12551. /**
  12552. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  12553. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12554. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12555. */
  12556. getShadowDirection(faceIndex?: number): Vector3;
  12557. /**
  12558. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  12559. * - fov = PI / 2
  12560. * - aspect ratio : 1.0
  12561. * - z-near and far equal to the active camera minZ and maxZ.
  12562. * Returns the PointLight.
  12563. */
  12564. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12565. protected _buildUniformLayout(): void;
  12566. /**
  12567. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  12568. * @param effect The effect to update
  12569. * @param lightIndex The index of the light in the effect to update
  12570. * @returns The point light
  12571. */
  12572. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  12573. /**
  12574. * Prepares the list of defines specific to the light type.
  12575. * @param defines the list of defines
  12576. * @param lightIndex defines the index of the light for the effect
  12577. */
  12578. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12579. }
  12580. }
  12581. declare module BABYLON {
  12582. /**
  12583. * Interface describing all the common properties and methods a shadow light needs to implement.
  12584. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  12585. * as well as binding the different shadow properties to the effects.
  12586. */
  12587. interface IShadowLight extends Light {
  12588. /**
  12589. * The light id in the scene (used in scene.findLighById for instance)
  12590. */
  12591. id: string;
  12592. /**
  12593. * The position the shdow will be casted from.
  12594. */
  12595. position: Vector3;
  12596. /**
  12597. * In 2d mode (needCube being false), the direction used to cast the shadow.
  12598. */
  12599. direction: Vector3;
  12600. /**
  12601. * The transformed position. Position of the light in world space taking parenting in account.
  12602. */
  12603. transformedPosition: Vector3;
  12604. /**
  12605. * The transformed direction. Direction of the light in world space taking parenting in account.
  12606. */
  12607. transformedDirection: Vector3;
  12608. /**
  12609. * The friendly name of the light in the scene.
  12610. */
  12611. name: string;
  12612. /**
  12613. * Defines the shadow projection clipping minimum z value.
  12614. */
  12615. shadowMinZ: number;
  12616. /**
  12617. * Defines the shadow projection clipping maximum z value.
  12618. */
  12619. shadowMaxZ: number;
  12620. /**
  12621. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12622. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12623. */
  12624. computeTransformedInformation(): boolean;
  12625. /**
  12626. * Gets the scene the light belongs to.
  12627. * @returns The scene
  12628. */
  12629. getScene(): Scene;
  12630. /**
  12631. * Callback defining a custom Projection Matrix Builder.
  12632. * This can be used to override the default projection matrix computation.
  12633. */
  12634. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12635. /**
  12636. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12637. * @param matrix The materix to updated with the projection information
  12638. * @param viewMatrix The transform matrix of the light
  12639. * @param renderList The list of mesh to render in the map
  12640. * @returns The current light
  12641. */
  12642. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12643. /**
  12644. * Gets the current depth scale used in ESM.
  12645. * @returns The scale
  12646. */
  12647. getDepthScale(): number;
  12648. /**
  12649. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12650. * @returns true if a cube texture needs to be use
  12651. */
  12652. needCube(): boolean;
  12653. /**
  12654. * Detects if the projection matrix requires to be recomputed this frame.
  12655. * @returns true if it requires to be recomputed otherwise, false.
  12656. */
  12657. needProjectionMatrixCompute(): boolean;
  12658. /**
  12659. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12660. */
  12661. forceProjectionMatrixCompute(): void;
  12662. /**
  12663. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12664. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12665. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12666. */
  12667. getShadowDirection(faceIndex?: number): Vector3;
  12668. /**
  12669. * Gets the minZ used for shadow according to both the scene and the light.
  12670. * @param activeCamera The camera we are returning the min for
  12671. * @returns the depth min z
  12672. */
  12673. getDepthMinZ(activeCamera: Camera): number;
  12674. /**
  12675. * Gets the maxZ used for shadow according to both the scene and the light.
  12676. * @param activeCamera The camera we are returning the max for
  12677. * @returns the depth max z
  12678. */
  12679. getDepthMaxZ(activeCamera: Camera): number;
  12680. }
  12681. /**
  12682. * Base implementation IShadowLight
  12683. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  12684. */
  12685. abstract class ShadowLight extends Light implements IShadowLight {
  12686. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12687. protected _position: Vector3;
  12688. protected _setPosition(value: Vector3): void;
  12689. /**
  12690. * Sets the position the shadow will be casted from. Also use as the light position for both
  12691. * point and spot lights.
  12692. */
  12693. /**
  12694. * Sets the position the shadow will be casted from. Also use as the light position for both
  12695. * point and spot lights.
  12696. */
  12697. position: Vector3;
  12698. protected _direction: Vector3;
  12699. protected _setDirection(value: Vector3): void;
  12700. /**
  12701. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  12702. * Also use as the light direction on spot and directional lights.
  12703. */
  12704. /**
  12705. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  12706. * Also use as the light direction on spot and directional lights.
  12707. */
  12708. direction: Vector3;
  12709. private _shadowMinZ;
  12710. /**
  12711. * Gets the shadow projection clipping minimum z value.
  12712. */
  12713. /**
  12714. * Sets the shadow projection clipping minimum z value.
  12715. */
  12716. shadowMinZ: number;
  12717. private _shadowMaxZ;
  12718. /**
  12719. * Sets the shadow projection clipping maximum z value.
  12720. */
  12721. /**
  12722. * Gets the shadow projection clipping maximum z value.
  12723. */
  12724. shadowMaxZ: number;
  12725. /**
  12726. * Callback defining a custom Projection Matrix Builder.
  12727. * This can be used to override the default projection matrix computation.
  12728. */
  12729. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12730. /**
  12731. * The transformed position. Position of the light in world space taking parenting in account.
  12732. */
  12733. transformedPosition: Vector3;
  12734. /**
  12735. * The transformed direction. Direction of the light in world space taking parenting in account.
  12736. */
  12737. transformedDirection: Vector3;
  12738. private _needProjectionMatrixCompute;
  12739. /**
  12740. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12741. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12742. */
  12743. computeTransformedInformation(): boolean;
  12744. /**
  12745. * Return the depth scale used for the shadow map.
  12746. * @returns the depth scale.
  12747. */
  12748. getDepthScale(): number;
  12749. /**
  12750. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12751. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12752. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12753. */
  12754. getShadowDirection(faceIndex?: number): Vector3;
  12755. /**
  12756. * Returns the ShadowLight absolute position in the World.
  12757. * @returns the position vector in world space
  12758. */
  12759. getAbsolutePosition(): Vector3;
  12760. /**
  12761. * Sets the ShadowLight direction toward the passed target.
  12762. * @param target The point tot target in local space
  12763. * @returns the updated ShadowLight direction
  12764. */
  12765. setDirectionToTarget(target: Vector3): Vector3;
  12766. /**
  12767. * Returns the light rotation in euler definition.
  12768. * @returns the x y z rotation in local space.
  12769. */
  12770. getRotation(): Vector3;
  12771. /**
  12772. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12773. * @returns true if a cube texture needs to be use
  12774. */
  12775. needCube(): boolean;
  12776. /**
  12777. * Detects if the projection matrix requires to be recomputed this frame.
  12778. * @returns true if it requires to be recomputed otherwise, false.
  12779. */
  12780. needProjectionMatrixCompute(): boolean;
  12781. /**
  12782. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12783. */
  12784. forceProjectionMatrixCompute(): void;
  12785. /** @hidden */
  12786. _initCache(): void;
  12787. /** @hidden */
  12788. _isSynchronized(): boolean;
  12789. /**
  12790. * Computes the world matrix of the node
  12791. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12792. * @returns the world matrix
  12793. */
  12794. computeWorldMatrix(force?: boolean): Matrix;
  12795. /**
  12796. * Gets the minZ used for shadow according to both the scene and the light.
  12797. * @param activeCamera The camera we are returning the min for
  12798. * @returns the depth min z
  12799. */
  12800. getDepthMinZ(activeCamera: Camera): number;
  12801. /**
  12802. * Gets the maxZ used for shadow according to both the scene and the light.
  12803. * @param activeCamera The camera we are returning the max for
  12804. * @returns the depth max z
  12805. */
  12806. getDepthMaxZ(activeCamera: Camera): number;
  12807. /**
  12808. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12809. * @param matrix The materix to updated with the projection information
  12810. * @param viewMatrix The transform matrix of the light
  12811. * @param renderList The list of mesh to render in the map
  12812. * @returns The current light
  12813. */
  12814. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12815. }
  12816. }
  12817. declare module BABYLON {
  12818. /**
  12819. * A spot light is defined by a position, a direction, an angle, and an exponent.
  12820. * These values define a cone of light starting from the position, emitting toward the direction.
  12821. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  12822. * and the exponent defines the speed of the decay of the light with distance (reach).
  12823. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12824. */
  12825. class SpotLight extends ShadowLight {
  12826. private _angle;
  12827. private _innerAngle;
  12828. private _cosHalfAngle;
  12829. private _lightAngleScale;
  12830. private _lightAngleOffset;
  12831. /**
  12832. * Gets the cone angle of the spot light in Radians.
  12833. */
  12834. /**
  12835. * Sets the cone angle of the spot light in Radians.
  12836. */
  12837. angle: number;
  12838. /**
  12839. * Only used in gltf falloff mode, this defines the angle where
  12840. * the directional falloff will start before cutting at angle which could be seen
  12841. * as outer angle.
  12842. */
  12843. /**
  12844. * Only used in gltf falloff mode, this defines the angle where
  12845. * the directional falloff will start before cutting at angle which could be seen
  12846. * as outer angle.
  12847. */
  12848. innerAngle: number;
  12849. private _shadowAngleScale;
  12850. /**
  12851. * Allows scaling the angle of the light for shadow generation only.
  12852. */
  12853. /**
  12854. * Allows scaling the angle of the light for shadow generation only.
  12855. */
  12856. shadowAngleScale: number;
  12857. /**
  12858. * The light decay speed with the distance from the emission spot.
  12859. */
  12860. exponent: number;
  12861. private _projectionTextureMatrix;
  12862. /**
  12863. * Allows reading the projecton texture
  12864. */
  12865. readonly projectionTextureMatrix: Matrix;
  12866. protected _projectionTextureLightNear: number;
  12867. /**
  12868. * Gets the near clip of the Spotlight for texture projection.
  12869. */
  12870. /**
  12871. * Sets the near clip of the Spotlight for texture projection.
  12872. */
  12873. projectionTextureLightNear: number;
  12874. protected _projectionTextureLightFar: number;
  12875. /**
  12876. * Gets the far clip of the Spotlight for texture projection.
  12877. */
  12878. /**
  12879. * Sets the far clip of the Spotlight for texture projection.
  12880. */
  12881. projectionTextureLightFar: number;
  12882. protected _projectionTextureUpDirection: Vector3;
  12883. /**
  12884. * Gets the Up vector of the Spotlight for texture projection.
  12885. */
  12886. /**
  12887. * Sets the Up vector of the Spotlight for texture projection.
  12888. */
  12889. projectionTextureUpDirection: Vector3;
  12890. private _projectionTexture;
  12891. /**
  12892. * Gets the projection texture of the light.
  12893. */
  12894. /**
  12895. * Sets the projection texture of the light.
  12896. */
  12897. projectionTexture: Nullable<BaseTexture>;
  12898. private _projectionTextureViewLightDirty;
  12899. private _projectionTextureProjectionLightDirty;
  12900. private _projectionTextureDirty;
  12901. private _projectionTextureViewTargetVector;
  12902. private _projectionTextureViewLightMatrix;
  12903. private _projectionTextureProjectionLightMatrix;
  12904. private _projectionTextureScalingMatrix;
  12905. /**
  12906. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  12907. * It can cast shadows.
  12908. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12909. * @param name The light friendly name
  12910. * @param position The position of the spot light in the scene
  12911. * @param direction The direction of the light in the scene
  12912. * @param angle The cone angle of the light in Radians
  12913. * @param exponent The light decay speed with the distance from the emission spot
  12914. * @param scene The scene the lights belongs to
  12915. */
  12916. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  12917. /**
  12918. * Returns the string "SpotLight".
  12919. * @returns the class name
  12920. */
  12921. getClassName(): string;
  12922. /**
  12923. * Returns the integer 2.
  12924. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12925. */
  12926. getTypeID(): number;
  12927. /**
  12928. * Overrides the direction setter to recompute the projection texture view light Matrix.
  12929. */
  12930. protected _setDirection(value: Vector3): void;
  12931. /**
  12932. * Overrides the position setter to recompute the projection texture view light Matrix.
  12933. */
  12934. protected _setPosition(value: Vector3): void;
  12935. /**
  12936. * 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.
  12937. * Returns the SpotLight.
  12938. */
  12939. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12940. protected _computeProjectionTextureViewLightMatrix(): void;
  12941. protected _computeProjectionTextureProjectionLightMatrix(): void;
  12942. /**
  12943. * Main function for light texture projection matrix computing.
  12944. */
  12945. protected _computeProjectionTextureMatrix(): void;
  12946. protected _buildUniformLayout(): void;
  12947. private _computeAngleValues;
  12948. /**
  12949. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  12950. * @param effect The effect to update
  12951. * @param lightIndex The index of the light in the effect to update
  12952. * @returns The spot light
  12953. */
  12954. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  12955. /**
  12956. * Disposes the light and the associated resources.
  12957. */
  12958. dispose(): void;
  12959. /**
  12960. * Prepares the list of defines specific to the light type.
  12961. * @param defines the list of defines
  12962. * @param lightIndex defines the index of the light for the effect
  12963. */
  12964. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12965. }
  12966. }
  12967. declare module BABYLON {
  12968. interface ILoadingScreen {
  12969. displayLoadingUI: () => void;
  12970. hideLoadingUI: () => void;
  12971. loadingUIBackgroundColor: string;
  12972. loadingUIText: string;
  12973. }
  12974. class DefaultLoadingScreen implements ILoadingScreen {
  12975. private _renderingCanvas;
  12976. private _loadingText;
  12977. private _loadingDivBackgroundColor;
  12978. private _loadingDiv;
  12979. private _loadingTextDiv;
  12980. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  12981. displayLoadingUI(): void;
  12982. hideLoadingUI(): void;
  12983. loadingUIText: string;
  12984. loadingUIBackgroundColor: string;
  12985. private _resizeLoadingUI;
  12986. }
  12987. }
  12988. declare module BABYLON {
  12989. class SceneLoaderProgressEvent {
  12990. readonly lengthComputable: boolean;
  12991. readonly loaded: number;
  12992. readonly total: number;
  12993. constructor(lengthComputable: boolean, loaded: number, total: number);
  12994. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  12995. }
  12996. interface ISceneLoaderPluginExtensions {
  12997. [extension: string]: {
  12998. isBinary: boolean;
  12999. };
  13000. }
  13001. interface ISceneLoaderPluginFactory {
  13002. name: string;
  13003. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  13004. canDirectLoad?: (data: string) => boolean;
  13005. }
  13006. interface ISceneLoaderPlugin {
  13007. /**
  13008. * The friendly name of this plugin.
  13009. */
  13010. name: string;
  13011. /**
  13012. * The file extensions supported by this plugin.
  13013. */
  13014. extensions: string | ISceneLoaderPluginExtensions;
  13015. /**
  13016. * Import meshes into a scene.
  13017. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  13018. * @param scene The scene to import into
  13019. * @param data The data to import
  13020. * @param rootUrl The root url for scene and resources
  13021. * @param meshes The meshes array to import into
  13022. * @param particleSystems The particle systems array to import into
  13023. * @param skeletons The skeletons array to import into
  13024. * @param onError The callback when import fails
  13025. * @returns True if successful or false otherwise
  13026. */
  13027. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  13028. /**
  13029. * Load into a scene.
  13030. * @param scene The scene to load into
  13031. * @param data The data to import
  13032. * @param rootUrl The root url for scene and resources
  13033. * @param onError The callback when import fails
  13034. * @returns true if successful or false otherwise
  13035. */
  13036. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  13037. /**
  13038. * The callback that returns true if the data can be directly loaded.
  13039. */
  13040. canDirectLoad?: (data: string) => boolean;
  13041. /**
  13042. * The callback that allows custom handling of the root url based on the response url.
  13043. */
  13044. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  13045. /**
  13046. * Load into an asset container.
  13047. * @param scene The scene to load into
  13048. * @param data The data to import
  13049. * @param rootUrl The root url for scene and resources
  13050. * @param onError The callback when import fails
  13051. * @returns The loaded asset container
  13052. */
  13053. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  13054. }
  13055. interface ISceneLoaderPluginAsync {
  13056. /**
  13057. * The friendly name of this plugin.
  13058. */
  13059. name: string;
  13060. /**
  13061. * The file extensions supported by this plugin.
  13062. */
  13063. extensions: string | ISceneLoaderPluginExtensions;
  13064. /**
  13065. * Import meshes into a scene.
  13066. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  13067. * @param scene The scene to import into
  13068. * @param data The data to import
  13069. * @param rootUrl The root url for scene and resources
  13070. * @param onProgress The callback when the load progresses
  13071. * @param fileName Defines the name of the file to load
  13072. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  13073. */
  13074. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  13075. meshes: AbstractMesh[];
  13076. particleSystems: IParticleSystem[];
  13077. skeletons: Skeleton[];
  13078. animationGroups: AnimationGroup[];
  13079. }>;
  13080. /**
  13081. * Load into a scene.
  13082. * @param scene The scene to load into
  13083. * @param data The data to import
  13084. * @param rootUrl The root url for scene and resources
  13085. * @param onProgress The callback when the load progresses
  13086. * @param fileName Defines the name of the file to load
  13087. * @returns Nothing
  13088. */
  13089. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  13090. /**
  13091. * The callback that returns true if the data can be directly loaded.
  13092. */
  13093. canDirectLoad?: (data: string) => boolean;
  13094. /**
  13095. * The callback that allows custom handling of the root url based on the response url.
  13096. */
  13097. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  13098. /**
  13099. * Load into an asset container.
  13100. * @param scene The scene to load into
  13101. * @param data The data to import
  13102. * @param rootUrl The root url for scene and resources
  13103. * @param onProgress The callback when the load progresses
  13104. * @param fileName Defines the name of the file to load
  13105. * @returns The loaded asset container
  13106. */
  13107. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  13108. }
  13109. class SceneLoader {
  13110. private static _ForceFullSceneLoadingForIncremental;
  13111. private static _ShowLoadingScreen;
  13112. private static _CleanBoneMatrixWeights;
  13113. static readonly NO_LOGGING: number;
  13114. static readonly MINIMAL_LOGGING: number;
  13115. static readonly SUMMARY_LOGGING: number;
  13116. static readonly DETAILED_LOGGING: number;
  13117. private static _loggingLevel;
  13118. static ForceFullSceneLoadingForIncremental: boolean;
  13119. static ShowLoadingScreen: boolean;
  13120. static loggingLevel: number;
  13121. static CleanBoneMatrixWeights: boolean;
  13122. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  13123. private static _registeredPlugins;
  13124. private static _getDefaultPlugin;
  13125. private static _getPluginForExtension;
  13126. private static _getPluginForDirectLoad;
  13127. private static _getPluginForFilename;
  13128. private static _getDirectLoad;
  13129. private static _loadData;
  13130. private static _getFileInfo;
  13131. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  13132. static IsPluginForExtensionAvailable(extension: string): boolean;
  13133. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  13134. /**
  13135. * Import meshes into a scene
  13136. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  13137. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  13138. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  13139. * @param scene the instance of BABYLON.Scene to append to
  13140. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  13141. * @param onProgress a callback with a progress event for each file being loaded
  13142. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13143. * @param pluginExtension the extension used to determine the plugin
  13144. * @returns The loaded plugin
  13145. */
  13146. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  13147. /**
  13148. * Import meshes into a scene
  13149. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  13150. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  13151. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  13152. * @param scene the instance of BABYLON.Scene to append to
  13153. * @param onProgress a callback with a progress event for each file being loaded
  13154. * @param pluginExtension the extension used to determine the plugin
  13155. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  13156. */
  13157. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  13158. meshes: AbstractMesh[];
  13159. particleSystems: IParticleSystem[];
  13160. skeletons: Skeleton[];
  13161. animationGroups: AnimationGroup[];
  13162. }>;
  13163. /**
  13164. * Load a scene
  13165. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  13166. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  13167. * @param engine is the instance of BABYLON.Engine to use to create the scene
  13168. * @param onSuccess a callback with the scene when import succeeds
  13169. * @param onProgress a callback with a progress event for each file being loaded
  13170. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13171. * @param pluginExtension the extension used to determine the plugin
  13172. * @returns The loaded plugin
  13173. */
  13174. static Load(rootUrl: string, sceneFilename: string, engine: Engine, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  13175. /**
  13176. * Load a scene
  13177. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  13178. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  13179. * @param engine is the instance of BABYLON.Engine to use to create the scene
  13180. * @param onProgress a callback with a progress event for each file being loaded
  13181. * @param pluginExtension the extension used to determine the plugin
  13182. * @returns The loaded scene
  13183. */
  13184. static LoadAsync(rootUrl: string, sceneFilename: string, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  13185. /**
  13186. * Append a scene
  13187. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  13188. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  13189. * @param scene is the instance of BABYLON.Scene to append to
  13190. * @param onSuccess a callback with the scene when import succeeds
  13191. * @param onProgress a callback with a progress event for each file being loaded
  13192. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13193. * @param pluginExtension the extension used to determine the plugin
  13194. * @returns The loaded plugin
  13195. */
  13196. static Append(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  13197. /**
  13198. * Append a scene
  13199. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  13200. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  13201. * @param scene is the instance of BABYLON.Scene to append to
  13202. * @param onProgress a callback with a progress event for each file being loaded
  13203. * @param pluginExtension the extension used to determine the plugin
  13204. * @returns The given scene
  13205. */
  13206. static AppendAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  13207. /**
  13208. * Load a scene into an asset container
  13209. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  13210. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  13211. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  13212. * @param onSuccess a callback with the scene when import succeeds
  13213. * @param onProgress a callback with a progress event for each file being loaded
  13214. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  13215. * @param pluginExtension the extension used to determine the plugin
  13216. * @returns The loaded plugin
  13217. */
  13218. static LoadAssetContainer(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  13219. /**
  13220. * Load a scene into an asset container
  13221. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  13222. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  13223. * @param scene is the instance of BABYLON.Scene to append to
  13224. * @param onProgress a callback with a progress event for each file being loaded
  13225. * @param pluginExtension the extension used to determine the plugin
  13226. * @returns The loaded asset container
  13227. */
  13228. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  13229. }
  13230. }
  13231. declare module BABYLON {
  13232. /**
  13233. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  13234. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  13235. * 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;
  13236. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  13237. */
  13238. class ColorCurves {
  13239. private _dirty;
  13240. private _tempColor;
  13241. private _globalCurve;
  13242. private _highlightsCurve;
  13243. private _midtonesCurve;
  13244. private _shadowsCurve;
  13245. private _positiveCurve;
  13246. private _negativeCurve;
  13247. private _globalHue;
  13248. private _globalDensity;
  13249. private _globalSaturation;
  13250. private _globalExposure;
  13251. /**
  13252. * Gets the global Hue value.
  13253. * 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).
  13254. */
  13255. /**
  13256. * Sets the global Hue value.
  13257. * 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).
  13258. */
  13259. globalHue: number;
  13260. /**
  13261. * Gets the global Density value.
  13262. * 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.
  13263. * Values less than zero provide a filter of opposite hue.
  13264. */
  13265. /**
  13266. * Sets the global Density value.
  13267. * 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.
  13268. * Values less than zero provide a filter of opposite hue.
  13269. */
  13270. globalDensity: number;
  13271. /**
  13272. * Gets the global Saturation value.
  13273. * 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.
  13274. */
  13275. /**
  13276. * Sets the global Saturation value.
  13277. * 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.
  13278. */
  13279. globalSaturation: number;
  13280. /**
  13281. * Gets the global Exposure value.
  13282. * 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.
  13283. */
  13284. /**
  13285. * Sets the global Exposure value.
  13286. * 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.
  13287. */
  13288. globalExposure: number;
  13289. private _highlightsHue;
  13290. private _highlightsDensity;
  13291. private _highlightsSaturation;
  13292. private _highlightsExposure;
  13293. /**
  13294. * Gets the highlights Hue value.
  13295. * 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).
  13296. */
  13297. /**
  13298. * Sets the highlights Hue value.
  13299. * 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).
  13300. */
  13301. highlightsHue: number;
  13302. /**
  13303. * Gets the highlights Density value.
  13304. * 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.
  13305. * Values less than zero provide a filter of opposite hue.
  13306. */
  13307. /**
  13308. * Sets the highlights Density value.
  13309. * 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.
  13310. * Values less than zero provide a filter of opposite hue.
  13311. */
  13312. highlightsDensity: number;
  13313. /**
  13314. * Gets the highlights Saturation value.
  13315. * 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.
  13316. */
  13317. /**
  13318. * Sets the highlights Saturation value.
  13319. * 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.
  13320. */
  13321. highlightsSaturation: number;
  13322. /**
  13323. * Gets the highlights Exposure value.
  13324. * 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.
  13325. */
  13326. /**
  13327. * Sets the highlights Exposure value.
  13328. * 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.
  13329. */
  13330. highlightsExposure: number;
  13331. private _midtonesHue;
  13332. private _midtonesDensity;
  13333. private _midtonesSaturation;
  13334. private _midtonesExposure;
  13335. /**
  13336. * Gets the midtones Hue value.
  13337. * 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).
  13338. */
  13339. /**
  13340. * Sets the midtones Hue value.
  13341. * 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).
  13342. */
  13343. midtonesHue: number;
  13344. /**
  13345. * Gets the midtones Density value.
  13346. * 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.
  13347. * Values less than zero provide a filter of opposite hue.
  13348. */
  13349. /**
  13350. * Sets the midtones Density value.
  13351. * 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.
  13352. * Values less than zero provide a filter of opposite hue.
  13353. */
  13354. midtonesDensity: number;
  13355. /**
  13356. * Gets the midtones Saturation value.
  13357. * 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.
  13358. */
  13359. /**
  13360. * Sets the midtones Saturation value.
  13361. * 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.
  13362. */
  13363. midtonesSaturation: number;
  13364. /**
  13365. * Gets the midtones Exposure value.
  13366. * 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.
  13367. */
  13368. /**
  13369. * Sets the midtones Exposure value.
  13370. * 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.
  13371. */
  13372. midtonesExposure: number;
  13373. private _shadowsHue;
  13374. private _shadowsDensity;
  13375. private _shadowsSaturation;
  13376. private _shadowsExposure;
  13377. /**
  13378. * Gets the shadows Hue value.
  13379. * 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).
  13380. */
  13381. /**
  13382. * Sets the shadows Hue value.
  13383. * 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).
  13384. */
  13385. shadowsHue: number;
  13386. /**
  13387. * Gets the shadows Density value.
  13388. * 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.
  13389. * Values less than zero provide a filter of opposite hue.
  13390. */
  13391. /**
  13392. * Sets the shadows Density value.
  13393. * 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.
  13394. * Values less than zero provide a filter of opposite hue.
  13395. */
  13396. shadowsDensity: number;
  13397. /**
  13398. * Gets the shadows Saturation value.
  13399. * 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.
  13400. */
  13401. /**
  13402. * Sets the shadows Saturation value.
  13403. * 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.
  13404. */
  13405. shadowsSaturation: number;
  13406. /**
  13407. * Gets the shadows Exposure value.
  13408. * 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.
  13409. */
  13410. /**
  13411. * Sets the shadows Exposure value.
  13412. * 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.
  13413. */
  13414. shadowsExposure: number;
  13415. getClassName(): string;
  13416. /**
  13417. * Binds the color curves to the shader.
  13418. * @param colorCurves The color curve to bind
  13419. * @param effect The effect to bind to
  13420. */
  13421. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  13422. /**
  13423. * Prepare the list of uniforms associated with the ColorCurves effects.
  13424. * @param uniformsList The list of uniforms used in the effect
  13425. */
  13426. static PrepareUniforms(uniformsList: string[]): void;
  13427. /**
  13428. * Returns color grading data based on a hue, density, saturation and exposure value.
  13429. * @param filterHue The hue of the color filter.
  13430. * @param filterDensity The density of the color filter.
  13431. * @param saturation The saturation.
  13432. * @param exposure The exposure.
  13433. * @param result The result data container.
  13434. */
  13435. private getColorGradingDataToRef;
  13436. /**
  13437. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  13438. * @param value The input slider value in range [-100,100].
  13439. * @returns Adjusted value.
  13440. */
  13441. private static applyColorGradingSliderNonlinear;
  13442. /**
  13443. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  13444. * @param hue The hue (H) input.
  13445. * @param saturation The saturation (S) input.
  13446. * @param brightness The brightness (B) input.
  13447. * @result An RGBA color represented as Vector4.
  13448. */
  13449. private static fromHSBToRef;
  13450. /**
  13451. * Returns a value clamped between min and max
  13452. * @param value The value to clamp
  13453. * @param min The minimum of value
  13454. * @param max The maximum of value
  13455. * @returns The clamped value.
  13456. */
  13457. private static clamp;
  13458. /**
  13459. * Clones the current color curve instance.
  13460. * @return The cloned curves
  13461. */
  13462. clone(): ColorCurves;
  13463. /**
  13464. * Serializes the current color curve instance to a json representation.
  13465. * @return a JSON representation
  13466. */
  13467. serialize(): any;
  13468. /**
  13469. * Parses the color curve from a json representation.
  13470. * @param source the JSON source to parse
  13471. * @return The parsed curves
  13472. */
  13473. static Parse(source: any): ColorCurves;
  13474. }
  13475. }
  13476. declare module BABYLON {
  13477. /**
  13478. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13479. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13480. */
  13481. class EffectFallbacks {
  13482. private _defines;
  13483. private _currentRank;
  13484. private _maxRank;
  13485. private _mesh;
  13486. /**
  13487. * Removes the fallback from the bound mesh.
  13488. */
  13489. unBindMesh(): void;
  13490. /**
  13491. * Adds a fallback on the specified property.
  13492. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13493. * @param define The name of the define in the shader
  13494. */
  13495. addFallback(rank: number, define: string): void;
  13496. /**
  13497. * Sets the mesh to use CPU skinning when needing to fallback.
  13498. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13499. * @param mesh The mesh to use the fallbacks.
  13500. */
  13501. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13502. /**
  13503. * Checks to see if more fallbacks are still availible.
  13504. */
  13505. readonly isMoreFallbacks: boolean;
  13506. /**
  13507. * Removes the defines that shoould be removed when falling back.
  13508. * @param currentDefines defines the current define statements for the shader.
  13509. * @param effect defines the current effect we try to compile
  13510. * @returns The resulting defines with defines of the current rank removed.
  13511. */
  13512. reduce(currentDefines: string, effect: Effect): string;
  13513. }
  13514. /**
  13515. * Options to be used when creating an effect.
  13516. */
  13517. class EffectCreationOptions {
  13518. /**
  13519. * Atrributes that will be used in the shader.
  13520. */
  13521. attributes: string[];
  13522. /**
  13523. * Uniform varible names that will be set in the shader.
  13524. */
  13525. uniformsNames: string[];
  13526. /**
  13527. * Uniform buffer varible names that will be set in the shader.
  13528. */
  13529. uniformBuffersNames: string[];
  13530. /**
  13531. * Sampler texture variable names that will be set in the shader.
  13532. */
  13533. samplers: string[];
  13534. /**
  13535. * Define statements that will be set in the shader.
  13536. */
  13537. defines: any;
  13538. /**
  13539. * Possible fallbacks for this effect to improve performance when needed.
  13540. */
  13541. fallbacks: Nullable<EffectFallbacks>;
  13542. /**
  13543. * Callback that will be called when the shader is compiled.
  13544. */
  13545. onCompiled: Nullable<(effect: Effect) => void>;
  13546. /**
  13547. * Callback that will be called if an error occurs during shader compilation.
  13548. */
  13549. onError: Nullable<(effect: Effect, errors: string) => void>;
  13550. /**
  13551. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13552. */
  13553. indexParameters: any;
  13554. /**
  13555. * Max number of lights that can be used in the shader.
  13556. */
  13557. maxSimultaneousLights: number;
  13558. /**
  13559. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  13560. */
  13561. transformFeedbackVaryings: Nullable<string[]>;
  13562. }
  13563. /**
  13564. * Effect containing vertex and fragment shader that can be executed on an object.
  13565. */
  13566. class Effect {
  13567. /**
  13568. * Name of the effect.
  13569. */
  13570. name: any;
  13571. /**
  13572. * String container all the define statements that should be set on the shader.
  13573. */
  13574. defines: string;
  13575. /**
  13576. * Callback that will be called when the shader is compiled.
  13577. */
  13578. onCompiled: Nullable<(effect: Effect) => void>;
  13579. /**
  13580. * Callback that will be called if an error occurs during shader compilation.
  13581. */
  13582. onError: Nullable<(effect: Effect, errors: string) => void>;
  13583. /**
  13584. * Callback that will be called when effect is bound.
  13585. */
  13586. onBind: Nullable<(effect: Effect) => void>;
  13587. /**
  13588. * Unique ID of the effect.
  13589. */
  13590. uniqueId: number;
  13591. /**
  13592. * Observable that will be called when the shader is compiled.
  13593. */
  13594. onCompileObservable: Observable<Effect>;
  13595. /**
  13596. * Observable that will be called if an error occurs during shader compilation.
  13597. */
  13598. onErrorObservable: Observable<Effect>;
  13599. /** @hidden */
  13600. _onBindObservable: Nullable<Observable<Effect>>;
  13601. /**
  13602. * Observable that will be called when effect is bound.
  13603. */
  13604. readonly onBindObservable: Observable<Effect>;
  13605. /** @hidden */
  13606. _bonesComputationForcedToCPU: boolean;
  13607. private static _uniqueIdSeed;
  13608. private _engine;
  13609. private _uniformBuffersNames;
  13610. private _uniformsNames;
  13611. private _samplers;
  13612. private _isReady;
  13613. private _compilationError;
  13614. private _attributesNames;
  13615. private _attributes;
  13616. private _uniforms;
  13617. /**
  13618. * Key for the effect.
  13619. * @hidden
  13620. */
  13621. _key: string;
  13622. private _indexParameters;
  13623. private _fallbacks;
  13624. private _vertexSourceCode;
  13625. private _fragmentSourceCode;
  13626. private _vertexSourceCodeOverride;
  13627. private _fragmentSourceCodeOverride;
  13628. private _transformFeedbackVaryings;
  13629. /**
  13630. * Compiled shader to webGL program.
  13631. * @hidden
  13632. */
  13633. _program: WebGLProgram;
  13634. private _valueCache;
  13635. private static _baseCache;
  13636. /**
  13637. * Instantiates an effect.
  13638. * An effect can be used to create/manage/execute vertex and fragment shaders.
  13639. * @param baseName Name of the effect.
  13640. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  13641. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  13642. * @param samplers List of sampler variables that will be passed to the shader.
  13643. * @param engine Engine to be used to render the effect
  13644. * @param defines Define statements to be added to the shader.
  13645. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  13646. * @param onCompiled Callback that will be called when the shader is compiled.
  13647. * @param onError Callback that will be called if an error occurs during shader compilation.
  13648. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13649. */
  13650. 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);
  13651. /**
  13652. * Unique key for this effect
  13653. */
  13654. readonly key: string;
  13655. /**
  13656. * If the effect has been compiled and prepared.
  13657. * @returns if the effect is compiled and prepared.
  13658. */
  13659. isReady(): boolean;
  13660. /**
  13661. * The engine the effect was initialized with.
  13662. * @returns the engine.
  13663. */
  13664. getEngine(): Engine;
  13665. /**
  13666. * The compiled webGL program for the effect
  13667. * @returns the webGL program.
  13668. */
  13669. getProgram(): WebGLProgram;
  13670. /**
  13671. * The set of names of attribute variables for the shader.
  13672. * @returns An array of attribute names.
  13673. */
  13674. getAttributesNames(): string[];
  13675. /**
  13676. * Returns the attribute at the given index.
  13677. * @param index The index of the attribute.
  13678. * @returns The location of the attribute.
  13679. */
  13680. getAttributeLocation(index: number): number;
  13681. /**
  13682. * Returns the attribute based on the name of the variable.
  13683. * @param name of the attribute to look up.
  13684. * @returns the attribute location.
  13685. */
  13686. getAttributeLocationByName(name: string): number;
  13687. /**
  13688. * The number of attributes.
  13689. * @returns the numnber of attributes.
  13690. */
  13691. getAttributesCount(): number;
  13692. /**
  13693. * Gets the index of a uniform variable.
  13694. * @param uniformName of the uniform to look up.
  13695. * @returns the index.
  13696. */
  13697. getUniformIndex(uniformName: string): number;
  13698. /**
  13699. * Returns the attribute based on the name of the variable.
  13700. * @param uniformName of the uniform to look up.
  13701. * @returns the location of the uniform.
  13702. */
  13703. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  13704. /**
  13705. * Returns an array of sampler variable names
  13706. * @returns The array of sampler variable neames.
  13707. */
  13708. getSamplers(): string[];
  13709. /**
  13710. * The error from the last compilation.
  13711. * @returns the error string.
  13712. */
  13713. getCompilationError(): string;
  13714. /**
  13715. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  13716. * @param func The callback to be used.
  13717. */
  13718. executeWhenCompiled(func: (effect: Effect) => void): void;
  13719. /** @hidden */
  13720. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  13721. /** @hidden */
  13722. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  13723. /** @hidden */
  13724. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  13725. private _processShaderConversion;
  13726. private _processIncludes;
  13727. private _processPrecision;
  13728. /**
  13729. * Recompiles the webGL program
  13730. * @param vertexSourceCode The source code for the vertex shader.
  13731. * @param fragmentSourceCode The source code for the fragment shader.
  13732. * @param onCompiled Callback called when completed.
  13733. * @param onError Callback called on error.
  13734. * @hidden
  13735. */
  13736. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  13737. /**
  13738. * Gets the uniform locations of the the specified variable names
  13739. * @param names THe names of the variables to lookup.
  13740. * @returns Array of locations in the same order as variable names.
  13741. */
  13742. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  13743. /**
  13744. * Prepares the effect
  13745. * @hidden
  13746. */
  13747. _prepareEffect(): void;
  13748. /**
  13749. * Checks if the effect is supported. (Must be called after compilation)
  13750. */
  13751. readonly isSupported: boolean;
  13752. /**
  13753. * Binds a texture to the engine to be used as output of the shader.
  13754. * @param channel Name of the output variable.
  13755. * @param texture Texture to bind.
  13756. * @hidden
  13757. */
  13758. _bindTexture(channel: string, texture: InternalTexture): void;
  13759. /**
  13760. * Sets a texture on the engine to be used in the shader.
  13761. * @param channel Name of the sampler variable.
  13762. * @param texture Texture to set.
  13763. */
  13764. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  13765. /**
  13766. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  13767. * @param channel Name of the sampler variable.
  13768. * @param texture Texture to set.
  13769. */
  13770. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  13771. /**
  13772. * Sets an array of textures on the engine to be used in the shader.
  13773. * @param channel Name of the variable.
  13774. * @param textures Textures to set.
  13775. */
  13776. setTextureArray(channel: string, textures: BaseTexture[]): void;
  13777. /**
  13778. * 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)
  13779. * @param channel Name of the sampler variable.
  13780. * @param postProcess Post process to get the input texture from.
  13781. */
  13782. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  13783. /**
  13784. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  13785. * 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)
  13786. * @param channel Name of the sampler variable.
  13787. * @param postProcess Post process to get the output texture from.
  13788. */
  13789. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  13790. /** @hidden */
  13791. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  13792. /** @hidden */
  13793. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  13794. /** @hidden */
  13795. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  13796. /** @hidden */
  13797. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  13798. /**
  13799. * Binds a buffer to a uniform.
  13800. * @param buffer Buffer to bind.
  13801. * @param name Name of the uniform variable to bind to.
  13802. */
  13803. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  13804. /**
  13805. * Binds block to a uniform.
  13806. * @param blockName Name of the block to bind.
  13807. * @param index Index to bind.
  13808. */
  13809. bindUniformBlock(blockName: string, index: number): void;
  13810. /**
  13811. * Sets an interger value on a uniform variable.
  13812. * @param uniformName Name of the variable.
  13813. * @param value Value to be set.
  13814. * @returns this effect.
  13815. */
  13816. setInt(uniformName: string, value: number): Effect;
  13817. /**
  13818. * Sets an int array on a uniform variable.
  13819. * @param uniformName Name of the variable.
  13820. * @param array array to be set.
  13821. * @returns this effect.
  13822. */
  13823. setIntArray(uniformName: string, array: Int32Array): Effect;
  13824. /**
  13825. * 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)
  13826. * @param uniformName Name of the variable.
  13827. * @param array array to be set.
  13828. * @returns this effect.
  13829. */
  13830. setIntArray2(uniformName: string, array: Int32Array): Effect;
  13831. /**
  13832. * 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)
  13833. * @param uniformName Name of the variable.
  13834. * @param array array to be set.
  13835. * @returns this effect.
  13836. */
  13837. setIntArray3(uniformName: string, array: Int32Array): Effect;
  13838. /**
  13839. * 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)
  13840. * @param uniformName Name of the variable.
  13841. * @param array array to be set.
  13842. * @returns this effect.
  13843. */
  13844. setIntArray4(uniformName: string, array: Int32Array): Effect;
  13845. /**
  13846. * Sets an float array on a uniform variable.
  13847. * @param uniformName Name of the variable.
  13848. * @param array array to be set.
  13849. * @returns this effect.
  13850. */
  13851. setFloatArray(uniformName: string, array: Float32Array): Effect;
  13852. /**
  13853. * 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)
  13854. * @param uniformName Name of the variable.
  13855. * @param array array to be set.
  13856. * @returns this effect.
  13857. */
  13858. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  13859. /**
  13860. * 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)
  13861. * @param uniformName Name of the variable.
  13862. * @param array array to be set.
  13863. * @returns this effect.
  13864. */
  13865. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  13866. /**
  13867. * 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)
  13868. * @param uniformName Name of the variable.
  13869. * @param array array to be set.
  13870. * @returns this effect.
  13871. */
  13872. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  13873. /**
  13874. * Sets an array on a uniform variable.
  13875. * @param uniformName Name of the variable.
  13876. * @param array array to be set.
  13877. * @returns this effect.
  13878. */
  13879. setArray(uniformName: string, array: number[]): Effect;
  13880. /**
  13881. * 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)
  13882. * @param uniformName Name of the variable.
  13883. * @param array array to be set.
  13884. * @returns this effect.
  13885. */
  13886. setArray2(uniformName: string, array: number[]): Effect;
  13887. /**
  13888. * 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)
  13889. * @param uniformName Name of the variable.
  13890. * @param array array to be set.
  13891. * @returns this effect.
  13892. */
  13893. setArray3(uniformName: string, array: number[]): Effect;
  13894. /**
  13895. * 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)
  13896. * @param uniformName Name of the variable.
  13897. * @param array array to be set.
  13898. * @returns this effect.
  13899. */
  13900. setArray4(uniformName: string, array: number[]): Effect;
  13901. /**
  13902. * Sets matrices on a uniform variable.
  13903. * @param uniformName Name of the variable.
  13904. * @param matrices matrices to be set.
  13905. * @returns this effect.
  13906. */
  13907. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  13908. /**
  13909. * Sets matrix on a uniform variable.
  13910. * @param uniformName Name of the variable.
  13911. * @param matrix matrix to be set.
  13912. * @returns this effect.
  13913. */
  13914. setMatrix(uniformName: string, matrix: Matrix): Effect;
  13915. /**
  13916. * 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)
  13917. * @param uniformName Name of the variable.
  13918. * @param matrix matrix to be set.
  13919. * @returns this effect.
  13920. */
  13921. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  13922. /**
  13923. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  13924. * @param uniformName Name of the variable.
  13925. * @param matrix matrix to be set.
  13926. * @returns this effect.
  13927. */
  13928. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  13929. /**
  13930. * Sets a float on a uniform variable.
  13931. * @param uniformName Name of the variable.
  13932. * @param value value to be set.
  13933. * @returns this effect.
  13934. */
  13935. setFloat(uniformName: string, value: number): Effect;
  13936. /**
  13937. * Sets a boolean on a uniform variable.
  13938. * @param uniformName Name of the variable.
  13939. * @param bool value to be set.
  13940. * @returns this effect.
  13941. */
  13942. setBool(uniformName: string, bool: boolean): Effect;
  13943. /**
  13944. * Sets a Vector2 on a uniform variable.
  13945. * @param uniformName Name of the variable.
  13946. * @param vector2 vector2 to be set.
  13947. * @returns this effect.
  13948. */
  13949. setVector2(uniformName: string, vector2: Vector2): Effect;
  13950. /**
  13951. * Sets a float2 on a uniform variable.
  13952. * @param uniformName Name of the variable.
  13953. * @param x First float in float2.
  13954. * @param y Second float in float2.
  13955. * @returns this effect.
  13956. */
  13957. setFloat2(uniformName: string, x: number, y: number): Effect;
  13958. /**
  13959. * Sets a Vector3 on a uniform variable.
  13960. * @param uniformName Name of the variable.
  13961. * @param vector3 Value to be set.
  13962. * @returns this effect.
  13963. */
  13964. setVector3(uniformName: string, vector3: Vector3): Effect;
  13965. /**
  13966. * Sets a float3 on a uniform variable.
  13967. * @param uniformName Name of the variable.
  13968. * @param x First float in float3.
  13969. * @param y Second float in float3.
  13970. * @param z Third float in float3.
  13971. * @returns this effect.
  13972. */
  13973. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  13974. /**
  13975. * Sets a Vector4 on a uniform variable.
  13976. * @param uniformName Name of the variable.
  13977. * @param vector4 Value to be set.
  13978. * @returns this effect.
  13979. */
  13980. setVector4(uniformName: string, vector4: Vector4): Effect;
  13981. /**
  13982. * Sets a float4 on a uniform variable.
  13983. * @param uniformName Name of the variable.
  13984. * @param x First float in float4.
  13985. * @param y Second float in float4.
  13986. * @param z Third float in float4.
  13987. * @param w Fourth float in float4.
  13988. * @returns this effect.
  13989. */
  13990. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  13991. /**
  13992. * Sets a Color3 on a uniform variable.
  13993. * @param uniformName Name of the variable.
  13994. * @param color3 Value to be set.
  13995. * @returns this effect.
  13996. */
  13997. setColor3(uniformName: string, color3: Color3): Effect;
  13998. /**
  13999. * Sets a Color4 on a uniform variable.
  14000. * @param uniformName Name of the variable.
  14001. * @param color3 Value to be set.
  14002. * @param alpha Alpha value to be set.
  14003. * @returns this effect.
  14004. */
  14005. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  14006. /**
  14007. * Sets a Color4 on a uniform variable
  14008. * @param uniformName defines the name of the variable
  14009. * @param color4 defines the value to be set
  14010. * @returns this effect.
  14011. */
  14012. setDirectColor4(uniformName: string, color4: Color4): Effect;
  14013. /**
  14014. * This function will add a new shader to the shader store
  14015. * @param name the name of the shader
  14016. * @param pixelShader optional pixel shader content
  14017. * @param vertexShader optional vertex shader content
  14018. */
  14019. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  14020. /**
  14021. * Store of each shader (The can be looked up using effect.key)
  14022. */
  14023. static ShadersStore: {
  14024. [key: string]: string;
  14025. };
  14026. /**
  14027. * Store of each included file for a shader (The can be looked up using effect.key)
  14028. */
  14029. static IncludesShadersStore: {
  14030. [key: string]: string;
  14031. };
  14032. /**
  14033. * Resets the cache of effects.
  14034. */
  14035. static ResetCache(): void;
  14036. }
  14037. }
  14038. declare module BABYLON {
  14039. class FresnelParameters {
  14040. private _isEnabled;
  14041. isEnabled: boolean;
  14042. leftColor: Color3;
  14043. rightColor: Color3;
  14044. bias: number;
  14045. power: number;
  14046. clone(): FresnelParameters;
  14047. serialize(): any;
  14048. static Parse(parsedFresnelParameters: any): FresnelParameters;
  14049. }
  14050. }
  14051. declare module BABYLON {
  14052. /**
  14053. * Interface to follow in your material defines to integrate easily the
  14054. * Image proccessing functions.
  14055. * @hidden
  14056. */
  14057. interface IImageProcessingConfigurationDefines {
  14058. IMAGEPROCESSING: boolean;
  14059. VIGNETTE: boolean;
  14060. VIGNETTEBLENDMODEMULTIPLY: boolean;
  14061. VIGNETTEBLENDMODEOPAQUE: boolean;
  14062. TONEMAPPING: boolean;
  14063. TONEMAPPING_ACES: boolean;
  14064. CONTRAST: boolean;
  14065. EXPOSURE: boolean;
  14066. COLORCURVES: boolean;
  14067. COLORGRADING: boolean;
  14068. COLORGRADING3D: boolean;
  14069. SAMPLER3DGREENDEPTH: boolean;
  14070. SAMPLER3DBGRMAP: boolean;
  14071. IMAGEPROCESSINGPOSTPROCESS: boolean;
  14072. }
  14073. /**
  14074. * @hidden
  14075. */
  14076. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  14077. IMAGEPROCESSING: boolean;
  14078. VIGNETTE: boolean;
  14079. VIGNETTEBLENDMODEMULTIPLY: boolean;
  14080. VIGNETTEBLENDMODEOPAQUE: boolean;
  14081. TONEMAPPING: boolean;
  14082. TONEMAPPING_ACES: boolean;
  14083. CONTRAST: boolean;
  14084. COLORCURVES: boolean;
  14085. COLORGRADING: boolean;
  14086. COLORGRADING3D: boolean;
  14087. SAMPLER3DGREENDEPTH: boolean;
  14088. SAMPLER3DBGRMAP: boolean;
  14089. IMAGEPROCESSINGPOSTPROCESS: boolean;
  14090. EXPOSURE: boolean;
  14091. constructor();
  14092. }
  14093. /**
  14094. * This groups together the common properties used for image processing either in direct forward pass
  14095. * or through post processing effect depending on the use of the image processing pipeline in your scene
  14096. * or not.
  14097. */
  14098. class ImageProcessingConfiguration {
  14099. /**
  14100. * Default tone mapping applied in BabylonJS.
  14101. */
  14102. static readonly TONEMAPPING_STANDARD: number;
  14103. /**
  14104. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  14105. * to other engines rendering to increase portability.
  14106. */
  14107. static readonly TONEMAPPING_ACES: number;
  14108. /**
  14109. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  14110. */
  14111. colorCurves: Nullable<ColorCurves>;
  14112. private _colorCurvesEnabled;
  14113. /**
  14114. * Gets wether the color curves effect is enabled.
  14115. */
  14116. /**
  14117. * Sets wether the color curves effect is enabled.
  14118. */
  14119. colorCurvesEnabled: boolean;
  14120. /**
  14121. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  14122. */
  14123. colorGradingTexture: Nullable<BaseTexture>;
  14124. private _colorGradingEnabled;
  14125. /**
  14126. * Gets wether the color grading effect is enabled.
  14127. */
  14128. /**
  14129. * Sets wether the color grading effect is enabled.
  14130. */
  14131. colorGradingEnabled: boolean;
  14132. private _colorGradingWithGreenDepth;
  14133. /**
  14134. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  14135. */
  14136. /**
  14137. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  14138. */
  14139. colorGradingWithGreenDepth: boolean;
  14140. private _colorGradingBGR;
  14141. /**
  14142. * Gets wether the color grading texture contains BGR values.
  14143. */
  14144. /**
  14145. * Sets wether the color grading texture contains BGR values.
  14146. */
  14147. colorGradingBGR: boolean;
  14148. /** @hidden */
  14149. _exposure: number;
  14150. /**
  14151. * Gets the Exposure used in the effect.
  14152. */
  14153. /**
  14154. * Sets the Exposure used in the effect.
  14155. */
  14156. exposure: number;
  14157. private _toneMappingEnabled;
  14158. /**
  14159. * Gets wether the tone mapping effect is enabled.
  14160. */
  14161. /**
  14162. * Sets wether the tone mapping effect is enabled.
  14163. */
  14164. toneMappingEnabled: boolean;
  14165. private _toneMappingType;
  14166. /**
  14167. * Gets the type of tone mapping effect.
  14168. */
  14169. /**
  14170. * Sets the type of tone mapping effect used in BabylonJS.
  14171. */
  14172. toneMappingType: number;
  14173. protected _contrast: number;
  14174. /**
  14175. * Gets the contrast used in the effect.
  14176. */
  14177. /**
  14178. * Sets the contrast used in the effect.
  14179. */
  14180. contrast: number;
  14181. /**
  14182. * Vignette stretch size.
  14183. */
  14184. vignetteStretch: number;
  14185. /**
  14186. * Vignette centre X Offset.
  14187. */
  14188. vignetteCentreX: number;
  14189. /**
  14190. * Vignette centre Y Offset.
  14191. */
  14192. vignetteCentreY: number;
  14193. /**
  14194. * Vignette weight or intensity of the vignette effect.
  14195. */
  14196. vignetteWeight: number;
  14197. /**
  14198. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  14199. * if vignetteEnabled is set to true.
  14200. */
  14201. vignetteColor: Color4;
  14202. /**
  14203. * Camera field of view used by the Vignette effect.
  14204. */
  14205. vignetteCameraFov: number;
  14206. private _vignetteBlendMode;
  14207. /**
  14208. * Gets the vignette blend mode allowing different kind of effect.
  14209. */
  14210. /**
  14211. * Sets the vignette blend mode allowing different kind of effect.
  14212. */
  14213. vignetteBlendMode: number;
  14214. private _vignetteEnabled;
  14215. /**
  14216. * Gets wether the vignette effect is enabled.
  14217. */
  14218. /**
  14219. * Sets wether the vignette effect is enabled.
  14220. */
  14221. vignetteEnabled: boolean;
  14222. private _applyByPostProcess;
  14223. /**
  14224. * Gets wether the image processing is applied through a post process or not.
  14225. */
  14226. /**
  14227. * Sets wether the image processing is applied through a post process or not.
  14228. */
  14229. applyByPostProcess: boolean;
  14230. private _isEnabled;
  14231. /**
  14232. * Gets wether the image processing is enabled or not.
  14233. */
  14234. /**
  14235. * Sets wether the image processing is enabled or not.
  14236. */
  14237. isEnabled: boolean;
  14238. /**
  14239. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  14240. */
  14241. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  14242. /**
  14243. * Method called each time the image processing information changes requires to recompile the effect.
  14244. */
  14245. protected _updateParameters(): void;
  14246. getClassName(): string;
  14247. /**
  14248. * Prepare the list of uniforms associated with the Image Processing effects.
  14249. * @param uniformsList The list of uniforms used in the effect
  14250. * @param defines the list of defines currently in use
  14251. */
  14252. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  14253. /**
  14254. * Prepare the list of samplers associated with the Image Processing effects.
  14255. * @param uniformsList The list of uniforms used in the effect
  14256. * @param defines the list of defines currently in use
  14257. */
  14258. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  14259. /**
  14260. * Prepare the list of defines associated to the shader.
  14261. * @param defines the list of defines to complete
  14262. */
  14263. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  14264. /**
  14265. * Returns true if all the image processing information are ready.
  14266. */
  14267. isReady(): boolean;
  14268. /**
  14269. * Binds the image processing to the shader.
  14270. * @param effect The effect to bind to
  14271. */
  14272. bind(effect: Effect, aspectRatio?: number): void;
  14273. /**
  14274. * Clones the current image processing instance.
  14275. * @return The cloned image processing
  14276. */
  14277. clone(): ImageProcessingConfiguration;
  14278. /**
  14279. * Serializes the current image processing instance to a json representation.
  14280. * @return a JSON representation
  14281. */
  14282. serialize(): any;
  14283. /**
  14284. * Parses the image processing from a json representation.
  14285. * @param source the JSON source to parse
  14286. * @return The parsed image processing
  14287. */
  14288. static Parse(source: any): ImageProcessingConfiguration;
  14289. private static _VIGNETTEMODE_MULTIPLY;
  14290. private static _VIGNETTEMODE_OPAQUE;
  14291. /**
  14292. * Used to apply the vignette as a mix with the pixel color.
  14293. */
  14294. static readonly VIGNETTEMODE_MULTIPLY: number;
  14295. /**
  14296. * Used to apply the vignette as a replacement of the pixel color.
  14297. */
  14298. static readonly VIGNETTEMODE_OPAQUE: number;
  14299. }
  14300. }
  14301. declare module BABYLON {
  14302. /**
  14303. * Manages the defines for the Material
  14304. */
  14305. class MaterialDefines {
  14306. private _keys;
  14307. private _isDirty;
  14308. /** @hidden */
  14309. _renderId: number;
  14310. /** @hidden */
  14311. _areLightsDirty: boolean;
  14312. /** @hidden */
  14313. _areAttributesDirty: boolean;
  14314. /** @hidden */
  14315. _areTexturesDirty: boolean;
  14316. /** @hidden */
  14317. _areFresnelDirty: boolean;
  14318. /** @hidden */
  14319. _areMiscDirty: boolean;
  14320. /** @hidden */
  14321. _areImageProcessingDirty: boolean;
  14322. /** @hidden */
  14323. _normals: boolean;
  14324. /** @hidden */
  14325. _uvs: boolean;
  14326. /** @hidden */
  14327. _needNormals: boolean;
  14328. /** @hidden */
  14329. _needUVs: boolean;
  14330. /**
  14331. * Specifies if the material needs to be re-calculated
  14332. */
  14333. readonly isDirty: boolean;
  14334. /**
  14335. * Marks the material to indicate that it has been re-calculated
  14336. */
  14337. markAsProcessed(): void;
  14338. /**
  14339. * Marks the material to indicate that it needs to be re-calculated
  14340. */
  14341. markAsUnprocessed(): void;
  14342. /**
  14343. * Marks the material to indicate all of its defines need to be re-calculated
  14344. */
  14345. markAllAsDirty(): void;
  14346. /**
  14347. * Marks the material to indicate that image processing needs to be re-calculated
  14348. */
  14349. markAsImageProcessingDirty(): void;
  14350. /**
  14351. * Marks the material to indicate the lights need to be re-calculated
  14352. */
  14353. markAsLightDirty(): void;
  14354. /**
  14355. * Marks the attribute state as changed
  14356. */
  14357. markAsAttributesDirty(): void;
  14358. /**
  14359. * Marks the texture state as changed
  14360. */
  14361. markAsTexturesDirty(): void;
  14362. /**
  14363. * Marks the fresnel state as changed
  14364. */
  14365. markAsFresnelDirty(): void;
  14366. /**
  14367. * Marks the misc state as changed
  14368. */
  14369. markAsMiscDirty(): void;
  14370. /**
  14371. * Rebuilds the material defines
  14372. */
  14373. rebuild(): void;
  14374. /**
  14375. * Specifies if two material defines are equal
  14376. * @param other - A material define instance to compare to
  14377. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  14378. */
  14379. isEqual(other: MaterialDefines): boolean;
  14380. /**
  14381. * Clones this instance's defines to another instance
  14382. * @param other - material defines to clone values to
  14383. */
  14384. cloneTo(other: MaterialDefines): void;
  14385. /**
  14386. * Resets the material define values
  14387. */
  14388. reset(): void;
  14389. /**
  14390. * Converts the material define values to a string
  14391. * @returns - String of material define information
  14392. */
  14393. toString(): string;
  14394. }
  14395. /**
  14396. * Base class for the main features of a material in Babylon.js
  14397. */
  14398. class Material implements IAnimatable {
  14399. private static _TriangleFillMode;
  14400. private static _WireFrameFillMode;
  14401. private static _PointFillMode;
  14402. private static _PointListDrawMode;
  14403. private static _LineListDrawMode;
  14404. private static _LineLoopDrawMode;
  14405. private static _LineStripDrawMode;
  14406. private static _TriangleStripDrawMode;
  14407. private static _TriangleFanDrawMode;
  14408. /**
  14409. * Returns the triangle fill mode
  14410. */
  14411. static readonly TriangleFillMode: number;
  14412. /**
  14413. * Returns the wireframe mode
  14414. */
  14415. static readonly WireFrameFillMode: number;
  14416. /**
  14417. * Returns the point fill mode
  14418. */
  14419. static readonly PointFillMode: number;
  14420. /**
  14421. * Returns the point list draw mode
  14422. */
  14423. static readonly PointListDrawMode: number;
  14424. /**
  14425. * Returns the line list draw mode
  14426. */
  14427. static readonly LineListDrawMode: number;
  14428. /**
  14429. * Returns the line loop draw mode
  14430. */
  14431. static readonly LineLoopDrawMode: number;
  14432. /**
  14433. * Returns the line strip draw mode
  14434. */
  14435. static readonly LineStripDrawMode: number;
  14436. /**
  14437. * Returns the triangle strip draw mode
  14438. */
  14439. static readonly TriangleStripDrawMode: number;
  14440. /**
  14441. * Returns the triangle fan draw mode
  14442. */
  14443. static readonly TriangleFanDrawMode: number;
  14444. /**
  14445. * Stores the clock-wise side orientation
  14446. */
  14447. private static _ClockWiseSideOrientation;
  14448. /**
  14449. * Stores the counter clock-wise side orientation
  14450. */
  14451. private static _CounterClockWiseSideOrientation;
  14452. /**
  14453. * Returns the clock-wise side orientation
  14454. */
  14455. static readonly ClockWiseSideOrientation: number;
  14456. /**
  14457. * Returns the counter clock-wise side orientation
  14458. */
  14459. static readonly CounterClockWiseSideOrientation: number;
  14460. /**
  14461. * The dirty texture flag value
  14462. */
  14463. private static _TextureDirtyFlag;
  14464. /**
  14465. * The dirty light flag value
  14466. */
  14467. private static _LightDirtyFlag;
  14468. /**
  14469. * The dirty fresnel flag value
  14470. */
  14471. private static _FresnelDirtyFlag;
  14472. /**
  14473. * The dirty attribute flag value
  14474. */
  14475. private static _AttributesDirtyFlag;
  14476. /**
  14477. * The dirty misc flag value
  14478. */
  14479. private static _MiscDirtyFlag;
  14480. /**
  14481. * Returns the dirty texture flag value
  14482. */
  14483. static readonly TextureDirtyFlag: number;
  14484. /**
  14485. * Returns the dirty light flag value
  14486. */
  14487. static readonly LightDirtyFlag: number;
  14488. /**
  14489. * Returns the dirty fresnel flag value
  14490. */
  14491. static readonly FresnelDirtyFlag: number;
  14492. /**
  14493. * Returns the dirty attributes flag value
  14494. */
  14495. static readonly AttributesDirtyFlag: number;
  14496. /**
  14497. * Returns the dirty misc flag value
  14498. */
  14499. static readonly MiscDirtyFlag: number;
  14500. /**
  14501. * The ID of the material
  14502. */
  14503. id: string;
  14504. /**
  14505. * Gets or sets the unique id of the material
  14506. */
  14507. uniqueId: number;
  14508. /**
  14509. * The name of the material
  14510. */
  14511. name: string;
  14512. /**
  14513. * Specifies if the ready state should be checked on each call
  14514. */
  14515. checkReadyOnEveryCall: boolean;
  14516. /**
  14517. * Specifies if the ready state should be checked once
  14518. */
  14519. checkReadyOnlyOnce: boolean;
  14520. /**
  14521. * The state of the material
  14522. */
  14523. state: string;
  14524. /**
  14525. * The alpha value of the material
  14526. */
  14527. protected _alpha: number;
  14528. /**
  14529. * Sets the alpha value of the material
  14530. */
  14531. /**
  14532. * Gets the alpha value of the material
  14533. */
  14534. alpha: number;
  14535. /**
  14536. * Specifies if back face culling is enabled
  14537. */
  14538. protected _backFaceCulling: boolean;
  14539. /**
  14540. * Sets the back-face culling state
  14541. */
  14542. /**
  14543. * Gets the back-face culling state
  14544. */
  14545. backFaceCulling: boolean;
  14546. /**
  14547. * Stores the value for side orientation
  14548. */
  14549. sideOrientation: number;
  14550. /**
  14551. * Callback triggered when the material is compiled
  14552. */
  14553. onCompiled: (effect: Effect) => void;
  14554. /**
  14555. * Callback triggered when an error occurs
  14556. */
  14557. onError: (effect: Effect, errors: string) => void;
  14558. /**
  14559. * Callback triggered to get the render target textures
  14560. */
  14561. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  14562. /**
  14563. * Gets a boolean indicating that current material needs to register RTT
  14564. */
  14565. hasRenderTargetTextures: boolean;
  14566. /**
  14567. * Specifies if the material should be serialized
  14568. */
  14569. doNotSerialize: boolean;
  14570. /**
  14571. * Specifies if the effect should be stored on sub meshes
  14572. */
  14573. storeEffectOnSubMeshes: boolean;
  14574. /**
  14575. * Stores the animations for the material
  14576. */
  14577. animations: Array<Animation>;
  14578. /**
  14579. * An event triggered when the material is disposed
  14580. */
  14581. onDisposeObservable: Observable<Material>;
  14582. /**
  14583. * An observer which watches for dispose events
  14584. */
  14585. private _onDisposeObserver;
  14586. private _onUnBindObservable;
  14587. /**
  14588. * Called during a dispose event
  14589. */
  14590. onDispose: () => void;
  14591. private _onBindObservable;
  14592. /**
  14593. * An event triggered when the material is bound
  14594. */
  14595. readonly onBindObservable: Observable<AbstractMesh>;
  14596. /**
  14597. * An observer which watches for bind events
  14598. */
  14599. private _onBindObserver;
  14600. /**
  14601. * Called during a bind event
  14602. */
  14603. onBind: (Mesh: AbstractMesh) => void;
  14604. /**
  14605. * An event triggered when the material is unbound
  14606. */
  14607. readonly onUnBindObservable: Observable<Material>;
  14608. /**
  14609. * Stores the value of the alpha mode
  14610. */
  14611. private _alphaMode;
  14612. /**
  14613. * Sets the value of the alpha mode.
  14614. *
  14615. * | Value | Type | Description |
  14616. * | --- | --- | --- |
  14617. * | 0 | ALPHA_DISABLE | |
  14618. * | 1 | ALPHA_ADD | |
  14619. * | 2 | ALPHA_COMBINE | |
  14620. * | 3 | ALPHA_SUBTRACT | |
  14621. * | 4 | ALPHA_MULTIPLY | |
  14622. * | 5 | ALPHA_MAXIMIZED | |
  14623. * | 6 | ALPHA_ONEONE | |
  14624. * | 7 | ALPHA_PREMULTIPLIED | |
  14625. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  14626. * | 9 | ALPHA_INTERPOLATE | |
  14627. * | 10 | ALPHA_SCREENMODE | |
  14628. *
  14629. */
  14630. /**
  14631. * Gets the value of the alpha mode
  14632. */
  14633. alphaMode: number;
  14634. /**
  14635. * Stores the state of the need depth pre-pass value
  14636. */
  14637. private _needDepthPrePass;
  14638. /**
  14639. * Sets the need depth pre-pass value
  14640. */
  14641. /**
  14642. * Gets the depth pre-pass value
  14643. */
  14644. needDepthPrePass: boolean;
  14645. /**
  14646. * Specifies if depth writing should be disabled
  14647. */
  14648. disableDepthWrite: boolean;
  14649. /**
  14650. * Specifies if depth writing should be forced
  14651. */
  14652. forceDepthWrite: boolean;
  14653. /**
  14654. * Specifies if there should be a separate pass for culling
  14655. */
  14656. separateCullingPass: boolean;
  14657. /**
  14658. * Stores the state specifing if fog should be enabled
  14659. */
  14660. private _fogEnabled;
  14661. /**
  14662. * Sets the state for enabling fog
  14663. */
  14664. /**
  14665. * Gets the value of the fog enabled state
  14666. */
  14667. fogEnabled: boolean;
  14668. /**
  14669. * Stores the size of points
  14670. */
  14671. pointSize: number;
  14672. /**
  14673. * Stores the z offset value
  14674. */
  14675. zOffset: number;
  14676. /**
  14677. * Gets a value specifying if wireframe mode is enabled
  14678. */
  14679. /**
  14680. * Sets the state of wireframe mode
  14681. */
  14682. wireframe: boolean;
  14683. /**
  14684. * Gets the value specifying if point clouds are enabled
  14685. */
  14686. /**
  14687. * Sets the state of point cloud mode
  14688. */
  14689. pointsCloud: boolean;
  14690. /**
  14691. * Gets the material fill mode
  14692. */
  14693. /**
  14694. * Sets the material fill mode
  14695. */
  14696. fillMode: number;
  14697. /**
  14698. * @hidden
  14699. * Stores the effects for the material
  14700. */
  14701. _effect: Nullable<Effect>;
  14702. /**
  14703. * @hidden
  14704. * Specifies if the material was previously ready
  14705. */
  14706. _wasPreviouslyReady: boolean;
  14707. /**
  14708. * Specifies if uniform buffers should be used
  14709. */
  14710. private _useUBO;
  14711. /**
  14712. * Stores a reference to the scene
  14713. */
  14714. private _scene;
  14715. /**
  14716. * Stores the fill mode state
  14717. */
  14718. private _fillMode;
  14719. /**
  14720. * Specifies if the depth write state should be cached
  14721. */
  14722. private _cachedDepthWriteState;
  14723. /**
  14724. * Stores the uniform buffer
  14725. */
  14726. protected _uniformBuffer: UniformBuffer;
  14727. /**
  14728. * Creates a material instance
  14729. * @param name defines the name of the material
  14730. * @param scene defines the scene to reference
  14731. * @param doNotAdd specifies if the material should be added to the scene
  14732. */
  14733. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  14734. /**
  14735. * Returns a string representation of the current material
  14736. * @param fullDetails defines a boolean indicating which levels of logging is desired
  14737. * @returns a string with material information
  14738. */
  14739. toString(fullDetails?: boolean): string;
  14740. /**
  14741. * Gets the class name of the material
  14742. * @returns a string with the class name of the material
  14743. */
  14744. getClassName(): string;
  14745. /**
  14746. * Specifies if updates for the material been locked
  14747. */
  14748. readonly isFrozen: boolean;
  14749. /**
  14750. * Locks updates for the material
  14751. */
  14752. freeze(): void;
  14753. /**
  14754. * Unlocks updates for the material
  14755. */
  14756. unfreeze(): void;
  14757. /**
  14758. * Specifies if the material is ready to be used
  14759. * @param mesh defines the mesh to check
  14760. * @param useInstances specifies if instances should be used
  14761. * @returns a boolean indicating if the material is ready to be used
  14762. */
  14763. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14764. /**
  14765. * Specifies that the submesh is ready to be used
  14766. * @param mesh defines the mesh to check
  14767. * @param subMesh defines which submesh to check
  14768. * @param useInstances specifies that instances should be used
  14769. * @returns a boolean indicating that the submesh is ready or not
  14770. */
  14771. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14772. /**
  14773. * Returns the material effect
  14774. * @returns the effect associated with the material
  14775. */
  14776. getEffect(): Nullable<Effect>;
  14777. /**
  14778. * Returns the current scene
  14779. * @returns a Scene
  14780. */
  14781. getScene(): Scene;
  14782. /**
  14783. * Specifies if the material will require alpha blending
  14784. * @returns a boolean specifying if alpha blending is needed
  14785. */
  14786. needAlphaBlending(): boolean;
  14787. /**
  14788. * Specifies if the mesh will require alpha blending
  14789. * @param mesh defines the mesh to check
  14790. * @returns a boolean specifying if alpha blending is needed for the mesh
  14791. */
  14792. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  14793. /**
  14794. * Specifies if this material should be rendered in alpha test mode
  14795. * @returns a boolean specifying if an alpha test is needed.
  14796. */
  14797. needAlphaTesting(): boolean;
  14798. /**
  14799. * Gets the texture used for the alpha test
  14800. * @returns the texture to use for alpha testing
  14801. */
  14802. getAlphaTestTexture(): Nullable<BaseTexture>;
  14803. /**
  14804. * Marks the material to indicate that it needs to be re-calculated
  14805. */
  14806. markDirty(): void;
  14807. /** @hidden */
  14808. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  14809. /**
  14810. * Binds the material to the mesh
  14811. * @param world defines the world transformation matrix
  14812. * @param mesh defines the mesh to bind the material to
  14813. */
  14814. bind(world: Matrix, mesh?: Mesh): void;
  14815. /**
  14816. * Binds the submesh to the material
  14817. * @param world defines the world transformation matrix
  14818. * @param mesh defines the mesh containing the submesh
  14819. * @param subMesh defines the submesh to bind the material to
  14820. */
  14821. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14822. /**
  14823. * Binds the world matrix to the material
  14824. * @param world defines the world transformation matrix
  14825. */
  14826. bindOnlyWorldMatrix(world: Matrix): void;
  14827. /**
  14828. * Binds the scene's uniform buffer to the effect.
  14829. * @param effect defines the effect to bind to the scene uniform buffer
  14830. * @param sceneUbo defines the uniform buffer storing scene data
  14831. */
  14832. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  14833. /**
  14834. * Binds the view matrix to the effect
  14835. * @param effect defines the effect to bind the view matrix to
  14836. */
  14837. bindView(effect: Effect): void;
  14838. /**
  14839. * Binds the view projection matrix to the effect
  14840. * @param effect defines the effect to bind the view projection matrix to
  14841. */
  14842. bindViewProjection(effect: Effect): void;
  14843. /**
  14844. * Specifies if material alpha testing should be turned on for the mesh
  14845. * @param mesh defines the mesh to check
  14846. */
  14847. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  14848. /**
  14849. * Processes to execute after binding the material to a mesh
  14850. * @param mesh defines the rendered mesh
  14851. */
  14852. protected _afterBind(mesh?: Mesh): void;
  14853. /**
  14854. * Unbinds the material from the mesh
  14855. */
  14856. unbind(): void;
  14857. /**
  14858. * Gets the active textures from the material
  14859. * @returns an array of textures
  14860. */
  14861. getActiveTextures(): BaseTexture[];
  14862. /**
  14863. * Specifies if the material uses a texture
  14864. * @param texture defines the texture to check against the material
  14865. * @returns a boolean specifying if the material uses the texture
  14866. */
  14867. hasTexture(texture: BaseTexture): boolean;
  14868. /**
  14869. * Makes a duplicate of the material, and gives it a new name
  14870. * @param name defines the new name for the duplicated material
  14871. * @returns the cloned material
  14872. */
  14873. clone(name: string): Nullable<Material>;
  14874. /**
  14875. * Gets the meshes bound to the material
  14876. * @returns an array of meshes bound to the material
  14877. */
  14878. getBindedMeshes(): AbstractMesh[];
  14879. /**
  14880. * Force shader compilation
  14881. * @param mesh defines the mesh associated with this material
  14882. * @param onCompiled defines a function to execute once the material is compiled
  14883. * @param options defines the options to configure the compilation
  14884. */
  14885. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  14886. clipPlane: boolean;
  14887. }>): void;
  14888. /**
  14889. * Force shader compilation
  14890. * @param mesh defines the mesh that will use this material
  14891. * @param options defines additional options for compiling the shaders
  14892. * @returns a promise that resolves when the compilation completes
  14893. */
  14894. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  14895. clipPlane: boolean;
  14896. }>): Promise<void>;
  14897. /**
  14898. * Marks a define in the material to indicate that it needs to be re-computed
  14899. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  14900. */
  14901. markAsDirty(flag: number): void;
  14902. /**
  14903. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  14904. * @param func defines a function which checks material defines against the submeshes
  14905. */
  14906. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  14907. /**
  14908. * Indicates that image processing needs to be re-calculated for all submeshes
  14909. */
  14910. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  14911. /**
  14912. * Indicates that textures need to be re-calculated for all submeshes
  14913. */
  14914. protected _markAllSubMeshesAsTexturesDirty(): void;
  14915. /**
  14916. * Indicates that fresnel needs to be re-calculated for all submeshes
  14917. */
  14918. protected _markAllSubMeshesAsFresnelDirty(): void;
  14919. /**
  14920. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  14921. */
  14922. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  14923. /**
  14924. * Indicates that lights need to be re-calculated for all submeshes
  14925. */
  14926. protected _markAllSubMeshesAsLightsDirty(): void;
  14927. /**
  14928. * Indicates that attributes need to be re-calculated for all submeshes
  14929. */
  14930. protected _markAllSubMeshesAsAttributesDirty(): void;
  14931. /**
  14932. * Indicates that misc needs to be re-calculated for all submeshes
  14933. */
  14934. protected _markAllSubMeshesAsMiscDirty(): void;
  14935. /**
  14936. * Indicates that textures and misc need to be re-calculated for all submeshes
  14937. */
  14938. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  14939. /**
  14940. * Disposes the material
  14941. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  14942. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  14943. */
  14944. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14945. /**
  14946. * Serializes this material
  14947. * @returns the serialized material object
  14948. */
  14949. serialize(): any;
  14950. /**
  14951. * Creates a MultiMaterial from parsed MultiMaterial data.
  14952. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  14953. * @param scene defines the hosting scene
  14954. * @returns a new MultiMaterial
  14955. */
  14956. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  14957. /**
  14958. * Creates a material from parsed material data
  14959. * @param parsedMaterial defines parsed material data
  14960. * @param scene defines the hosting scene
  14961. * @param rootUrl defines the root URL to use to load textures
  14962. * @returns a new material
  14963. */
  14964. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  14965. }
  14966. }
  14967. declare module BABYLON {
  14968. /**
  14969. * "Static Class" containing the most commonly used helper while dealing with material for
  14970. * rendering purpose.
  14971. *
  14972. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  14973. *
  14974. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14975. */
  14976. class MaterialHelper {
  14977. /**
  14978. * Bind the current view position to an effect.
  14979. * @param effect The effect to be bound
  14980. * @param scene The scene the eyes position is used from
  14981. */
  14982. static BindEyePosition(effect: Effect, scene: Scene): void;
  14983. /**
  14984. * Helps preparing the defines values about the UVs in used in the effect.
  14985. * UVs are shared as much as we can accross chanels in the shaders.
  14986. * @param texture The texture we are preparing the UVs for
  14987. * @param defines The defines to update
  14988. * @param key The chanel key "diffuse", "specular"... used in the shader
  14989. */
  14990. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  14991. /**
  14992. * Binds a texture matrix value to its corrsponding uniform
  14993. * @param texture The texture to bind the matrix for
  14994. * @param uniformBuffer The uniform buffer receivin the data
  14995. * @param key The chanel key "diffuse", "specular"... used in the shader
  14996. */
  14997. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  14998. /**
  14999. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  15000. * @param mesh defines the current mesh
  15001. * @param scene defines the current scene
  15002. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  15003. * @param pointsCloud defines if point cloud rendering has to be turned on
  15004. * @param fogEnabled defines if fog has to be turned on
  15005. * @param alphaTest defines if alpha testing has to be turned on
  15006. * @param defines defines the current list of defines
  15007. */
  15008. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  15009. /**
  15010. * Helper used to prepare the list of defines associated with frame values for shader compilation
  15011. * @param scene defines the current scene
  15012. * @param engine defines the current engine
  15013. * @param defines specifies the list of active defines
  15014. * @param useInstances defines if instances have to be turned on
  15015. * @param useClipPlane defines if clip plane have to be turned on
  15016. */
  15017. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  15018. /**
  15019. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  15020. * @param mesh The mesh containing the geometry data we will draw
  15021. * @param defines The defines to update
  15022. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  15023. * @param useBones Precise whether bones should be used or not (override mesh info)
  15024. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  15025. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  15026. * @returns false if defines are considered not dirty and have not been checked
  15027. */
  15028. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  15029. /**
  15030. * Prepares the defines related to the light information passed in parameter
  15031. * @param scene The scene we are intending to draw
  15032. * @param mesh The mesh the effect is compiling for
  15033. * @param defines The defines to update
  15034. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  15035. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  15036. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  15037. * @returns true if normals will be required for the rest of the effect
  15038. */
  15039. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  15040. /**
  15041. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  15042. * that won t be acctive due to defines being turned off.
  15043. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  15044. * @param samplersList The samplers list
  15045. * @param defines The defines helping in the list generation
  15046. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  15047. */
  15048. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  15049. /**
  15050. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  15051. * @param defines The defines to update while falling back
  15052. * @param fallbacks The authorized effect fallbacks
  15053. * @param maxSimultaneousLights The maximum number of lights allowed
  15054. * @param rank the current rank of the Effect
  15055. * @returns The newly affected rank
  15056. */
  15057. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  15058. /**
  15059. * Prepares the list of attributes required for morph targets according to the effect defines.
  15060. * @param attribs The current list of supported attribs
  15061. * @param mesh The mesh to prepare the morph targets attributes for
  15062. * @param defines The current Defines of the effect
  15063. */
  15064. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  15065. /**
  15066. * Prepares the list of attributes required for bones according to the effect defines.
  15067. * @param attribs The current list of supported attribs
  15068. * @param mesh The mesh to prepare the bones attributes for
  15069. * @param defines The current Defines of the effect
  15070. * @param fallbacks The current efffect fallback strategy
  15071. */
  15072. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  15073. /**
  15074. * Prepares the list of attributes required for instances according to the effect defines.
  15075. * @param attribs The current list of supported attribs
  15076. * @param defines The current Defines of the effect
  15077. */
  15078. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  15079. /**
  15080. * Binds the light shadow information to the effect for the given mesh.
  15081. * @param light The light containing the generator
  15082. * @param scene The scene the lights belongs to
  15083. * @param mesh The mesh we are binding the information to render
  15084. * @param lightIndex The light index in the effect used to render the mesh
  15085. * @param effect The effect we are binding the data to
  15086. */
  15087. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  15088. /**
  15089. * Binds the light information to the effect.
  15090. * @param light The light containing the generator
  15091. * @param effect The effect we are binding the data to
  15092. * @param lightIndex The light index in the effect used to render
  15093. */
  15094. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  15095. /**
  15096. * Binds the lights information from the scene to the effect for the given mesh.
  15097. * @param scene The scene the lights belongs to
  15098. * @param mesh The mesh we are binding the information to render
  15099. * @param effect The effect we are binding the data to
  15100. * @param defines The generated defines for the effect
  15101. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  15102. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  15103. */
  15104. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  15105. /**
  15106. * Binds the fog information from the scene to the effect for the given mesh.
  15107. * @param scene The scene the lights belongs to
  15108. * @param mesh The mesh we are binding the information to render
  15109. * @param effect The effect we are binding the data to
  15110. */
  15111. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  15112. /**
  15113. * Binds the bones information from the mesh to the effect.
  15114. * @param mesh The mesh we are binding the information to render
  15115. * @param effect The effect we are binding the data to
  15116. */
  15117. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  15118. /**
  15119. * Binds the morph targets information from the mesh to the effect.
  15120. * @param abstractMesh The mesh we are binding the information to render
  15121. * @param effect The effect we are binding the data to
  15122. */
  15123. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  15124. /**
  15125. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  15126. * @param defines The generated defines used in the effect
  15127. * @param effect The effect we are binding the data to
  15128. * @param scene The scene we are willing to render with logarithmic scale for
  15129. */
  15130. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  15131. /**
  15132. * Binds the clip plane information from the scene to the effect.
  15133. * @param scene The scene the clip plane information are extracted from
  15134. * @param effect The effect we are binding the data to
  15135. */
  15136. static BindClipPlane(effect: Effect, scene: Scene): void;
  15137. }
  15138. }
  15139. declare module BABYLON {
  15140. class MultiMaterial extends Material {
  15141. private _subMaterials;
  15142. subMaterials: Nullable<Material>[];
  15143. constructor(name: string, scene: Scene);
  15144. private _hookArray;
  15145. getSubMaterial(index: number): Nullable<Material>;
  15146. getActiveTextures(): BaseTexture[];
  15147. getClassName(): string;
  15148. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15149. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  15150. serialize(): any;
  15151. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  15152. }
  15153. }
  15154. declare module BABYLON {
  15155. class PushMaterial extends Material {
  15156. protected _activeEffect: Effect;
  15157. protected _normalMatrix: Matrix;
  15158. constructor(name: string, scene: Scene);
  15159. getEffect(): Effect;
  15160. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15161. /**
  15162. * Binds the given world matrix to the active effect
  15163. *
  15164. * @param world the matrix to bind
  15165. */
  15166. bindOnlyWorldMatrix(world: Matrix): void;
  15167. /**
  15168. * Binds the given normal matrix to the active effect
  15169. *
  15170. * @param normalMatrix the matrix to bind
  15171. */
  15172. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  15173. bind(world: Matrix, mesh?: Mesh): void;
  15174. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  15175. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  15176. }
  15177. }
  15178. declare module BABYLON {
  15179. class ShaderMaterial extends Material {
  15180. private _shaderPath;
  15181. private _options;
  15182. private _textures;
  15183. private _textureArrays;
  15184. private _floats;
  15185. private _ints;
  15186. private _floatsArrays;
  15187. private _colors3;
  15188. private _colors3Arrays;
  15189. private _colors4;
  15190. private _vectors2;
  15191. private _vectors3;
  15192. private _vectors4;
  15193. private _matrices;
  15194. private _matrices3x3;
  15195. private _matrices2x2;
  15196. private _vectors2Arrays;
  15197. private _vectors3Arrays;
  15198. private _cachedWorldViewMatrix;
  15199. private _renderId;
  15200. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  15201. getClassName(): string;
  15202. needAlphaBlending(): boolean;
  15203. needAlphaTesting(): boolean;
  15204. private _checkUniform;
  15205. setTexture(name: string, texture: Texture): ShaderMaterial;
  15206. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15207. setFloat(name: string, value: number): ShaderMaterial;
  15208. setInt(name: string, value: number): ShaderMaterial;
  15209. setFloats(name: string, value: number[]): ShaderMaterial;
  15210. setColor3(name: string, value: Color3): ShaderMaterial;
  15211. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15212. setColor4(name: string, value: Color4): ShaderMaterial;
  15213. setVector2(name: string, value: Vector2): ShaderMaterial;
  15214. setVector3(name: string, value: Vector3): ShaderMaterial;
  15215. setVector4(name: string, value: Vector4): ShaderMaterial;
  15216. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15217. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15218. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15219. setArray2(name: string, value: number[]): ShaderMaterial;
  15220. setArray3(name: string, value: number[]): ShaderMaterial;
  15221. private _checkCache;
  15222. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15223. bindOnlyWorldMatrix(world: Matrix): void;
  15224. bind(world: Matrix, mesh?: Mesh): void;
  15225. getActiveTextures(): BaseTexture[];
  15226. hasTexture(texture: BaseTexture): boolean;
  15227. clone(name: string): ShaderMaterial;
  15228. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  15229. serialize(): any;
  15230. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15231. }
  15232. }
  15233. declare module BABYLON {
  15234. /** @hidden */
  15235. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  15236. MAINUV1: boolean;
  15237. MAINUV2: boolean;
  15238. DIFFUSE: boolean;
  15239. DIFFUSEDIRECTUV: number;
  15240. AMBIENT: boolean;
  15241. AMBIENTDIRECTUV: number;
  15242. OPACITY: boolean;
  15243. OPACITYDIRECTUV: number;
  15244. OPACITYRGB: boolean;
  15245. REFLECTION: boolean;
  15246. EMISSIVE: boolean;
  15247. EMISSIVEDIRECTUV: number;
  15248. SPECULAR: boolean;
  15249. SPECULARDIRECTUV: number;
  15250. BUMP: boolean;
  15251. BUMPDIRECTUV: number;
  15252. PARALLAX: boolean;
  15253. PARALLAXOCCLUSION: boolean;
  15254. SPECULAROVERALPHA: boolean;
  15255. CLIPPLANE: boolean;
  15256. CLIPPLANE2: boolean;
  15257. CLIPPLANE3: boolean;
  15258. CLIPPLANE4: boolean;
  15259. ALPHATEST: boolean;
  15260. DEPTHPREPASS: boolean;
  15261. ALPHAFROMDIFFUSE: boolean;
  15262. POINTSIZE: boolean;
  15263. FOG: boolean;
  15264. SPECULARTERM: boolean;
  15265. DIFFUSEFRESNEL: boolean;
  15266. OPACITYFRESNEL: boolean;
  15267. REFLECTIONFRESNEL: boolean;
  15268. REFRACTIONFRESNEL: boolean;
  15269. EMISSIVEFRESNEL: boolean;
  15270. FRESNEL: boolean;
  15271. NORMAL: boolean;
  15272. UV1: boolean;
  15273. UV2: boolean;
  15274. VERTEXCOLOR: boolean;
  15275. VERTEXALPHA: boolean;
  15276. NUM_BONE_INFLUENCERS: number;
  15277. BonesPerMesh: number;
  15278. INSTANCES: boolean;
  15279. GLOSSINESS: boolean;
  15280. ROUGHNESS: boolean;
  15281. EMISSIVEASILLUMINATION: boolean;
  15282. LINKEMISSIVEWITHDIFFUSE: boolean;
  15283. REFLECTIONFRESNELFROMSPECULAR: boolean;
  15284. LIGHTMAP: boolean;
  15285. LIGHTMAPDIRECTUV: number;
  15286. OBJECTSPACE_NORMALMAP: boolean;
  15287. USELIGHTMAPASSHADOWMAP: boolean;
  15288. REFLECTIONMAP_3D: boolean;
  15289. REFLECTIONMAP_SPHERICAL: boolean;
  15290. REFLECTIONMAP_PLANAR: boolean;
  15291. REFLECTIONMAP_CUBIC: boolean;
  15292. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  15293. REFLECTIONMAP_PROJECTION: boolean;
  15294. REFLECTIONMAP_SKYBOX: boolean;
  15295. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  15296. REFLECTIONMAP_EXPLICIT: boolean;
  15297. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  15298. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  15299. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  15300. INVERTCUBICMAP: boolean;
  15301. LOGARITHMICDEPTH: boolean;
  15302. REFRACTION: boolean;
  15303. REFRACTIONMAP_3D: boolean;
  15304. REFLECTIONOVERALPHA: boolean;
  15305. TWOSIDEDLIGHTING: boolean;
  15306. SHADOWFLOAT: boolean;
  15307. MORPHTARGETS: boolean;
  15308. MORPHTARGETS_NORMAL: boolean;
  15309. MORPHTARGETS_TANGENT: boolean;
  15310. NUM_MORPH_INFLUENCERS: number;
  15311. NONUNIFORMSCALING: boolean;
  15312. PREMULTIPLYALPHA: boolean;
  15313. IMAGEPROCESSING: boolean;
  15314. VIGNETTE: boolean;
  15315. VIGNETTEBLENDMODEMULTIPLY: boolean;
  15316. VIGNETTEBLENDMODEOPAQUE: boolean;
  15317. TONEMAPPING: boolean;
  15318. TONEMAPPING_ACES: boolean;
  15319. CONTRAST: boolean;
  15320. COLORCURVES: boolean;
  15321. COLORGRADING: boolean;
  15322. COLORGRADING3D: boolean;
  15323. SAMPLER3DGREENDEPTH: boolean;
  15324. SAMPLER3DBGRMAP: boolean;
  15325. IMAGEPROCESSINGPOSTPROCESS: boolean;
  15326. /**
  15327. * If the reflection texture on this material is in linear color space
  15328. * @hidden
  15329. */
  15330. IS_REFLECTION_LINEAR: boolean;
  15331. /**
  15332. * If the refraction texture on this material is in linear color space
  15333. * @hidden
  15334. */
  15335. IS_REFRACTION_LINEAR: boolean;
  15336. EXPOSURE: boolean;
  15337. constructor();
  15338. setReflectionMode(modeToEnable: string): void;
  15339. }
  15340. class StandardMaterial extends PushMaterial {
  15341. private _diffuseTexture;
  15342. diffuseTexture: Nullable<BaseTexture>;
  15343. private _ambientTexture;
  15344. ambientTexture: Nullable<BaseTexture>;
  15345. private _opacityTexture;
  15346. opacityTexture: Nullable<BaseTexture>;
  15347. private _reflectionTexture;
  15348. reflectionTexture: Nullable<BaseTexture>;
  15349. private _emissiveTexture;
  15350. emissiveTexture: Nullable<BaseTexture>;
  15351. private _specularTexture;
  15352. specularTexture: Nullable<BaseTexture>;
  15353. private _bumpTexture;
  15354. bumpTexture: Nullable<BaseTexture>;
  15355. private _lightmapTexture;
  15356. lightmapTexture: Nullable<BaseTexture>;
  15357. private _refractionTexture;
  15358. refractionTexture: Nullable<BaseTexture>;
  15359. ambientColor: Color3;
  15360. diffuseColor: Color3;
  15361. specularColor: Color3;
  15362. emissiveColor: Color3;
  15363. specularPower: number;
  15364. private _useAlphaFromDiffuseTexture;
  15365. useAlphaFromDiffuseTexture: boolean;
  15366. private _useEmissiveAsIllumination;
  15367. useEmissiveAsIllumination: boolean;
  15368. private _linkEmissiveWithDiffuse;
  15369. linkEmissiveWithDiffuse: boolean;
  15370. private _useSpecularOverAlpha;
  15371. useSpecularOverAlpha: boolean;
  15372. private _useReflectionOverAlpha;
  15373. useReflectionOverAlpha: boolean;
  15374. private _disableLighting;
  15375. disableLighting: boolean;
  15376. private _useObjectSpaceNormalMap;
  15377. /**
  15378. * Allows using an object space normal map (instead of tangent space).
  15379. */
  15380. useObjectSpaceNormalMap: boolean;
  15381. private _useParallax;
  15382. useParallax: boolean;
  15383. private _useParallaxOcclusion;
  15384. useParallaxOcclusion: boolean;
  15385. parallaxScaleBias: number;
  15386. private _roughness;
  15387. roughness: number;
  15388. indexOfRefraction: number;
  15389. invertRefractionY: boolean;
  15390. /**
  15391. * Defines the alpha limits in alpha test mode
  15392. */
  15393. alphaCutOff: number;
  15394. private _useLightmapAsShadowmap;
  15395. useLightmapAsShadowmap: boolean;
  15396. private _diffuseFresnelParameters;
  15397. diffuseFresnelParameters: FresnelParameters;
  15398. private _opacityFresnelParameters;
  15399. opacityFresnelParameters: FresnelParameters;
  15400. private _reflectionFresnelParameters;
  15401. reflectionFresnelParameters: FresnelParameters;
  15402. private _refractionFresnelParameters;
  15403. refractionFresnelParameters: FresnelParameters;
  15404. private _emissiveFresnelParameters;
  15405. emissiveFresnelParameters: FresnelParameters;
  15406. private _useReflectionFresnelFromSpecular;
  15407. useReflectionFresnelFromSpecular: boolean;
  15408. private _useGlossinessFromSpecularMapAlpha;
  15409. useGlossinessFromSpecularMapAlpha: boolean;
  15410. private _maxSimultaneousLights;
  15411. maxSimultaneousLights: number;
  15412. /**
  15413. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  15414. */
  15415. private _invertNormalMapX;
  15416. invertNormalMapX: boolean;
  15417. /**
  15418. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  15419. */
  15420. private _invertNormalMapY;
  15421. invertNormalMapY: boolean;
  15422. /**
  15423. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  15424. */
  15425. private _twoSidedLighting;
  15426. twoSidedLighting: boolean;
  15427. /**
  15428. * Default configuration related to image processing available in the standard Material.
  15429. */
  15430. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15431. /**
  15432. * Gets the image processing configuration used either in this material.
  15433. */
  15434. /**
  15435. * Sets the Default image processing configuration used either in the this material.
  15436. *
  15437. * If sets to null, the scene one is in use.
  15438. */
  15439. imageProcessingConfiguration: ImageProcessingConfiguration;
  15440. /**
  15441. * Keep track of the image processing observer to allow dispose and replace.
  15442. */
  15443. private _imageProcessingObserver;
  15444. /**
  15445. * Attaches a new image processing configuration to the Standard Material.
  15446. * @param configuration
  15447. */
  15448. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15449. /**
  15450. * Gets wether the color curves effect is enabled.
  15451. */
  15452. /**
  15453. * Sets wether the color curves effect is enabled.
  15454. */
  15455. cameraColorCurvesEnabled: boolean;
  15456. /**
  15457. * Gets wether the color grading effect is enabled.
  15458. */
  15459. /**
  15460. * Gets wether the color grading effect is enabled.
  15461. */
  15462. cameraColorGradingEnabled: boolean;
  15463. /**
  15464. * Gets wether tonemapping is enabled or not.
  15465. */
  15466. /**
  15467. * Sets wether tonemapping is enabled or not
  15468. */
  15469. cameraToneMappingEnabled: boolean;
  15470. /**
  15471. * The camera exposure used on this material.
  15472. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  15473. * This corresponds to a photographic exposure.
  15474. */
  15475. /**
  15476. * The camera exposure used on this material.
  15477. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  15478. * This corresponds to a photographic exposure.
  15479. */
  15480. cameraExposure: number;
  15481. /**
  15482. * Gets The camera contrast used on this material.
  15483. */
  15484. /**
  15485. * Sets The camera contrast used on this material.
  15486. */
  15487. cameraContrast: number;
  15488. /**
  15489. * Gets the Color Grading 2D Lookup Texture.
  15490. */
  15491. /**
  15492. * Sets the Color Grading 2D Lookup Texture.
  15493. */
  15494. cameraColorGradingTexture: Nullable<BaseTexture>;
  15495. /**
  15496. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15497. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15498. * 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;
  15499. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15500. */
  15501. /**
  15502. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15503. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15504. * 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;
  15505. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15506. */
  15507. cameraColorCurves: Nullable<ColorCurves>;
  15508. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  15509. protected _renderTargets: SmartArray<RenderTargetTexture>;
  15510. protected _worldViewProjectionMatrix: Matrix;
  15511. protected _globalAmbientColor: Color3;
  15512. protected _useLogarithmicDepth: boolean;
  15513. constructor(name: string, scene: Scene);
  15514. /**
  15515. * Gets a boolean indicating that current material needs to register RTT
  15516. */
  15517. readonly hasRenderTargetTextures: boolean;
  15518. getClassName(): string;
  15519. useLogarithmicDepth: boolean;
  15520. needAlphaBlending(): boolean;
  15521. needAlphaTesting(): boolean;
  15522. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  15523. getAlphaTestTexture(): Nullable<BaseTexture>;
  15524. /**
  15525. * Child classes can use it to update shaders
  15526. */
  15527. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  15528. buildUniformLayout(): void;
  15529. unbind(): void;
  15530. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  15531. getAnimatables(): IAnimatable[];
  15532. getActiveTextures(): BaseTexture[];
  15533. hasTexture(texture: BaseTexture): boolean;
  15534. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  15535. clone(name: string): StandardMaterial;
  15536. serialize(): any;
  15537. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  15538. static _DiffuseTextureEnabled: boolean;
  15539. static DiffuseTextureEnabled: boolean;
  15540. static _AmbientTextureEnabled: boolean;
  15541. static AmbientTextureEnabled: boolean;
  15542. static _OpacityTextureEnabled: boolean;
  15543. static OpacityTextureEnabled: boolean;
  15544. static _ReflectionTextureEnabled: boolean;
  15545. static ReflectionTextureEnabled: boolean;
  15546. static _EmissiveTextureEnabled: boolean;
  15547. static EmissiveTextureEnabled: boolean;
  15548. static _SpecularTextureEnabled: boolean;
  15549. static SpecularTextureEnabled: boolean;
  15550. static _BumpTextureEnabled: boolean;
  15551. static BumpTextureEnabled: boolean;
  15552. static _LightmapTextureEnabled: boolean;
  15553. static LightmapTextureEnabled: boolean;
  15554. static _RefractionTextureEnabled: boolean;
  15555. static RefractionTextureEnabled: boolean;
  15556. static _ColorGradingTextureEnabled: boolean;
  15557. static ColorGradingTextureEnabled: boolean;
  15558. static _FresnelEnabled: boolean;
  15559. static FresnelEnabled: boolean;
  15560. }
  15561. }
  15562. declare module BABYLON {
  15563. class UniformBuffer {
  15564. private _engine;
  15565. private _buffer;
  15566. private _data;
  15567. private _bufferData;
  15568. private _dynamic?;
  15569. private _uniformLocations;
  15570. private _uniformSizes;
  15571. private _uniformLocationPointer;
  15572. private _needSync;
  15573. private _noUBO;
  15574. private _currentEffect;
  15575. private static _MAX_UNIFORM_SIZE;
  15576. private static _tempBuffer;
  15577. /**
  15578. * Wrapper for updateUniform.
  15579. * @method updateMatrix3x3
  15580. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15581. * @param {Float32Array} matrix
  15582. */
  15583. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  15584. /**
  15585. * Wrapper for updateUniform.
  15586. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15587. * @param {Float32Array} matrix
  15588. */
  15589. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  15590. /**
  15591. * Wrapper for updateUniform.
  15592. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15593. * @param {number} x
  15594. */
  15595. updateFloat: (name: string, x: number) => void;
  15596. /**
  15597. * Wrapper for updateUniform.
  15598. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15599. * @param {number} x
  15600. * @param {number} y
  15601. * @param {string} [suffix] Suffix to add to the uniform name.
  15602. */
  15603. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  15604. /**
  15605. * Wrapper for updateUniform.
  15606. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15607. * @param {number} x
  15608. * @param {number} y
  15609. * @param {number} z
  15610. * @param {string} [suffix] Suffix to add to the uniform name.
  15611. */
  15612. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  15613. /**
  15614. * Wrapper for updateUniform.
  15615. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15616. * @param {number} x
  15617. * @param {number} y
  15618. * @param {number} z
  15619. * @param {number} w
  15620. * @param {string} [suffix] Suffix to add to the uniform name.
  15621. */
  15622. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  15623. /**
  15624. * Wrapper for updateUniform.
  15625. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15626. * @param {Matrix} A 4x4 matrix.
  15627. */
  15628. updateMatrix: (name: string, mat: Matrix) => void;
  15629. /**
  15630. * Wrapper for updateUniform.
  15631. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15632. * @param {Vector3} vector
  15633. */
  15634. updateVector3: (name: string, vector: Vector3) => void;
  15635. /**
  15636. * Wrapper for updateUniform.
  15637. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15638. * @param {Vector4} vector
  15639. */
  15640. updateVector4: (name: string, vector: Vector4) => void;
  15641. /**
  15642. * Wrapper for updateUniform.
  15643. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15644. * @param {Color3} color
  15645. * @param {string} [suffix] Suffix to add to the uniform name.
  15646. */
  15647. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  15648. /**
  15649. * Wrapper for updateUniform.
  15650. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15651. * @param {Color3} color
  15652. * @param {number} alpha
  15653. * @param {string} [suffix] Suffix to add to the uniform name.
  15654. */
  15655. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  15656. /**
  15657. * Uniform buffer objects.
  15658. *
  15659. * Handles blocks of uniform on the GPU.
  15660. *
  15661. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  15662. *
  15663. * For more information, please refer to :
  15664. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  15665. */
  15666. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  15667. /**
  15668. * Indicates if the buffer is using the WebGL2 UBO implementation,
  15669. * or just falling back on setUniformXXX calls.
  15670. */
  15671. readonly useUbo: boolean;
  15672. /**
  15673. * Indicates if the WebGL underlying uniform buffer is in sync
  15674. * with the javascript cache data.
  15675. */
  15676. readonly isSync: boolean;
  15677. /**
  15678. * Indicates if the WebGL underlying uniform buffer is dynamic.
  15679. * Also, a dynamic UniformBuffer will disable cache verification and always
  15680. * update the underlying WebGL uniform buffer to the GPU.
  15681. */
  15682. isDynamic(): boolean;
  15683. /**
  15684. * The data cache on JS side.
  15685. */
  15686. getData(): Float32Array;
  15687. /**
  15688. * The underlying WebGL Uniform buffer.
  15689. */
  15690. getBuffer(): Nullable<WebGLBuffer>;
  15691. /**
  15692. * std140 layout specifies how to align data within an UBO structure.
  15693. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  15694. * for specs.
  15695. */
  15696. private _fillAlignment;
  15697. /**
  15698. * Adds an uniform in the buffer.
  15699. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  15700. * for the layout to be correct !
  15701. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15702. * @param {number|number[]} size Data size, or data directly.
  15703. */
  15704. addUniform(name: string, size: number | number[]): void;
  15705. /**
  15706. * Wrapper for addUniform.
  15707. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15708. * @param {Matrix} mat A 4x4 matrix.
  15709. */
  15710. addMatrix(name: string, mat: Matrix): void;
  15711. /**
  15712. * Wrapper for addUniform.
  15713. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15714. * @param {number} x
  15715. * @param {number} y
  15716. */
  15717. addFloat2(name: string, x: number, y: number): void;
  15718. /**
  15719. * Wrapper for addUniform.
  15720. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15721. * @param {number} x
  15722. * @param {number} y
  15723. * @param {number} z
  15724. */
  15725. addFloat3(name: string, x: number, y: number, z: number): void;
  15726. /**
  15727. * Wrapper for addUniform.
  15728. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15729. * @param {Color3} color
  15730. */
  15731. addColor3(name: string, color: Color3): void;
  15732. /**
  15733. * Wrapper for addUniform.
  15734. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15735. * @param {Color3} color
  15736. * @param {number} alpha
  15737. */
  15738. addColor4(name: string, color: Color3, alpha: number): void;
  15739. /**
  15740. * Wrapper for addUniform.
  15741. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15742. * @param {Vector3} vector
  15743. */
  15744. addVector3(name: string, vector: Vector3): void;
  15745. /**
  15746. * Wrapper for addUniform.
  15747. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15748. */
  15749. addMatrix3x3(name: string): void;
  15750. /**
  15751. * Wrapper for addUniform.
  15752. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15753. */
  15754. addMatrix2x2(name: string): void;
  15755. /**
  15756. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  15757. */
  15758. create(): void;
  15759. /** @hidden */
  15760. _rebuild(): void;
  15761. /**
  15762. * Updates the WebGL Uniform Buffer on the GPU.
  15763. * If the `dynamic` flag is set to true, no cache comparison is done.
  15764. * Otherwise, the buffer will be updated only if the cache differs.
  15765. */
  15766. update(): void;
  15767. /**
  15768. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  15769. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15770. * @param {number[]|Float32Array} data Flattened data
  15771. * @param {number} size Size of the data.
  15772. */
  15773. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  15774. private _updateMatrix3x3ForUniform;
  15775. private _updateMatrix3x3ForEffect;
  15776. private _updateMatrix2x2ForEffect;
  15777. private _updateMatrix2x2ForUniform;
  15778. private _updateFloatForEffect;
  15779. private _updateFloatForUniform;
  15780. private _updateFloat2ForEffect;
  15781. private _updateFloat2ForUniform;
  15782. private _updateFloat3ForEffect;
  15783. private _updateFloat3ForUniform;
  15784. private _updateFloat4ForEffect;
  15785. private _updateFloat4ForUniform;
  15786. private _updateMatrixForEffect;
  15787. private _updateMatrixForUniform;
  15788. private _updateVector3ForEffect;
  15789. private _updateVector3ForUniform;
  15790. private _updateVector4ForEffect;
  15791. private _updateVector4ForUniform;
  15792. private _updateColor3ForEffect;
  15793. private _updateColor3ForUniform;
  15794. private _updateColor4ForEffect;
  15795. private _updateColor4ForUniform;
  15796. /**
  15797. * Sets a sampler uniform on the effect.
  15798. * @param {string} name Name of the sampler.
  15799. * @param {Texture} texture
  15800. */
  15801. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  15802. /**
  15803. * Directly updates the value of the uniform in the cache AND on the GPU.
  15804. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15805. * @param {number[]|Float32Array} data Flattened data
  15806. */
  15807. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  15808. /**
  15809. * Binds this uniform buffer to an effect.
  15810. * @param {Effect} effect
  15811. * @param {string} name Name of the uniform block in the shader.
  15812. */
  15813. bindToEffect(effect: Effect, name: string): void;
  15814. /**
  15815. * Disposes the uniform buffer.
  15816. */
  15817. dispose(): void;
  15818. }
  15819. }
  15820. declare module BABYLON {
  15821. class Scalar {
  15822. /**
  15823. * Two pi constants convenient for computation.
  15824. */
  15825. static TwoPi: number;
  15826. /**
  15827. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  15828. */
  15829. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  15830. /**
  15831. * Returns a string : the upper case translation of the number i to hexadecimal.
  15832. */
  15833. static ToHex(i: number): string;
  15834. /**
  15835. * Returns -1 if value is negative and +1 is value is positive.
  15836. * Returns the value itself if it's equal to zero.
  15837. */
  15838. static Sign(value: number): number;
  15839. /**
  15840. * Returns the value itself if it's between min and max.
  15841. * Returns min if the value is lower than min.
  15842. * Returns max if the value is greater than max.
  15843. */
  15844. static Clamp(value: number, min?: number, max?: number): number;
  15845. /**
  15846. * Returns the log2 of value.
  15847. */
  15848. static Log2(value: number): number;
  15849. /**
  15850. * Loops the value, so that it is never larger than length and never smaller than 0.
  15851. *
  15852. * This is similar to the modulo operator but it works with floating point numbers.
  15853. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  15854. * With t = 5 and length = 2.5, the result would be 0.0.
  15855. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  15856. */
  15857. static Repeat(value: number, length: number): number;
  15858. /**
  15859. * Normalize the value between 0.0 and 1.0 using min and max values
  15860. */
  15861. static Normalize(value: number, min: number, max: number): number;
  15862. /**
  15863. * Denormalize the value from 0.0 and 1.0 using min and max values
  15864. */
  15865. static Denormalize(normalized: number, min: number, max: number): number;
  15866. /**
  15867. * Calculates the shortest difference between two given angles given in degrees.
  15868. */
  15869. static DeltaAngle(current: number, target: number): number;
  15870. /**
  15871. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  15872. *
  15873. * The returned value will move back and forth between 0 and length
  15874. */
  15875. static PingPong(tx: number, length: number): number;
  15876. /**
  15877. * Interpolates between min and max with smoothing at the limits.
  15878. *
  15879. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  15880. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  15881. */
  15882. static SmoothStep(from: number, to: number, tx: number): number;
  15883. /**
  15884. * Moves a value current towards target.
  15885. *
  15886. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  15887. * Negative values of maxDelta pushes the value away from target.
  15888. */
  15889. static MoveTowards(current: number, target: number, maxDelta: number): number;
  15890. /**
  15891. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15892. *
  15893. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  15894. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  15895. */
  15896. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  15897. /**
  15898. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  15899. */
  15900. static Lerp(start: number, end: number, amount: number): number;
  15901. /**
  15902. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15903. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  15904. */
  15905. static LerpAngle(start: number, end: number, amount: number): number;
  15906. /**
  15907. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  15908. */
  15909. static InverseLerp(a: number, b: number, value: number): number;
  15910. /**
  15911. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  15912. */
  15913. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  15914. /**
  15915. * Returns a random float number between and min and max values
  15916. */
  15917. static RandomRange(min: number, max: number): number;
  15918. /**
  15919. * This function returns percentage of a number in a given range.
  15920. *
  15921. * RangeToPercent(40,20,60) will return 0.5 (50%)
  15922. * RangeToPercent(34,0,100) will return 0.34 (34%)
  15923. */
  15924. static RangeToPercent(number: number, min: number, max: number): number;
  15925. /**
  15926. * This function returns number that corresponds to the percentage in a given range.
  15927. *
  15928. * PercentToRange(0.34,0,100) will return 34.
  15929. */
  15930. static PercentToRange(percent: number, min: number, max: number): number;
  15931. /**
  15932. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  15933. * @param angle The angle to normalize in radian.
  15934. * @return The converted angle.
  15935. */
  15936. static NormalizeRadians(angle: number): number;
  15937. }
  15938. }
  15939. declare module BABYLON {
  15940. const ToGammaSpace: number;
  15941. const ToLinearSpace = 2.2;
  15942. const Epsilon = 0.001;
  15943. /**
  15944. * Class used to hold a RBG color
  15945. */
  15946. class Color3 {
  15947. /**
  15948. * Defines the red component (between 0 and 1, default is 0)
  15949. */
  15950. r: number;
  15951. /**
  15952. * Defines the green component (between 0 and 1, default is 0)
  15953. */
  15954. g: number;
  15955. /**
  15956. * Defines the blue component (between 0 and 1, default is 0)
  15957. */
  15958. b: number;
  15959. /**
  15960. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  15961. * @param r defines the red component (between 0 and 1, default is 0)
  15962. * @param g defines the green component (between 0 and 1, default is 0)
  15963. * @param b defines the blue component (between 0 and 1, default is 0)
  15964. */
  15965. constructor(
  15966. /**
  15967. * Defines the red component (between 0 and 1, default is 0)
  15968. */
  15969. r?: number,
  15970. /**
  15971. * Defines the green component (between 0 and 1, default is 0)
  15972. */
  15973. g?: number,
  15974. /**
  15975. * Defines the blue component (between 0 and 1, default is 0)
  15976. */
  15977. b?: number);
  15978. /**
  15979. * Creates a string with the Color3 current values
  15980. * @returns the string representation of the Color3 object
  15981. */
  15982. toString(): string;
  15983. /**
  15984. * Returns the string "Color3"
  15985. * @returns "Color3"
  15986. */
  15987. getClassName(): string;
  15988. /**
  15989. * Compute the Color3 hash code
  15990. * @returns an unique number that can be used to hash Color3 objects
  15991. */
  15992. getHashCode(): number;
  15993. /**
  15994. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  15995. * @param array defines the array where to store the r,g,b components
  15996. * @param index defines an optional index in the target array to define where to start storing values
  15997. * @returns the current Color3 object
  15998. */
  15999. toArray(array: FloatArray, index?: number): Color3;
  16000. /**
  16001. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  16002. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  16003. * @returns a new {BABYLON.Color4} object
  16004. */
  16005. toColor4(alpha?: number): Color4;
  16006. /**
  16007. * Returns a new array populated with 3 numeric elements : red, green and blue values
  16008. * @returns the new array
  16009. */
  16010. asArray(): number[];
  16011. /**
  16012. * Returns the luminance value
  16013. * @returns a float value
  16014. */
  16015. toLuminance(): number;
  16016. /**
  16017. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  16018. * @param otherColor defines the second operand
  16019. * @returns the new Color3 object
  16020. */
  16021. multiply(otherColor: Color3): Color3;
  16022. /**
  16023. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  16024. * @param otherColor defines the second operand
  16025. * @param result defines the Color3 object where to store the result
  16026. * @returns the current Color3
  16027. */
  16028. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  16029. /**
  16030. * Determines equality between Color3 objects
  16031. * @param otherColor defines the second operand
  16032. * @returns true if the rgb values are equal to the given ones
  16033. */
  16034. equals(otherColor: Color3): boolean;
  16035. /**
  16036. * Determines equality between the current Color3 object and a set of r,b,g values
  16037. * @param r defines the red component to check
  16038. * @param g defines the green component to check
  16039. * @param b defines the blue component to check
  16040. * @returns true if the rgb values are equal to the given ones
  16041. */
  16042. equalsFloats(r: number, g: number, b: number): boolean;
  16043. /**
  16044. * Multiplies in place each rgb value by scale
  16045. * @param scale defines the scaling factor
  16046. * @returns the updated Color3
  16047. */
  16048. scale(scale: number): Color3;
  16049. /**
  16050. * Multiplies the rgb values by scale and stores the result into "result"
  16051. * @param scale defines the scaling factor
  16052. * @param result defines the Color3 object where to store the result
  16053. * @returns the unmodified current Color3
  16054. */
  16055. scaleToRef(scale: number, result: Color3): Color3;
  16056. /**
  16057. * Scale the current Color3 values by a factor and add the result to a given Color3
  16058. * @param scale defines the scale factor
  16059. * @param result defines color to store the result into
  16060. * @returns the unmodified current Color3
  16061. */
  16062. scaleAndAddToRef(scale: number, result: Color3): Color3;
  16063. /**
  16064. * Clamps the rgb values by the min and max values and stores the result into "result"
  16065. * @param min defines minimum clamping value (default is 0)
  16066. * @param max defines maximum clamping value (default is 1)
  16067. * @param result defines color to store the result into
  16068. * @returns the original Color3
  16069. */
  16070. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  16071. /**
  16072. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  16073. * @param otherColor defines the second operand
  16074. * @returns the new Color3
  16075. */
  16076. add(otherColor: Color3): Color3;
  16077. /**
  16078. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  16079. * @param otherColor defines the second operand
  16080. * @param result defines Color3 object to store the result into
  16081. * @returns the unmodified current Color3
  16082. */
  16083. addToRef(otherColor: Color3, result: Color3): Color3;
  16084. /**
  16085. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  16086. * @param otherColor defines the second operand
  16087. * @returns the new Color3
  16088. */
  16089. subtract(otherColor: Color3): Color3;
  16090. /**
  16091. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  16092. * @param otherColor defines the second operand
  16093. * @param result defines Color3 object to store the result into
  16094. * @returns the unmodified current Color3
  16095. */
  16096. subtractToRef(otherColor: Color3, result: Color3): Color3;
  16097. /**
  16098. * Copy the current object
  16099. * @returns a new Color3 copied the current one
  16100. */
  16101. clone(): Color3;
  16102. /**
  16103. * Copies the rgb values from the source in the current Color3
  16104. * @param source defines the source Color3 object
  16105. * @returns the updated Color3 object
  16106. */
  16107. copyFrom(source: Color3): Color3;
  16108. /**
  16109. * Updates the Color3 rgb values from the given floats
  16110. * @param r defines the red component to read from
  16111. * @param g defines the green component to read from
  16112. * @param b defines the blue component to read from
  16113. * @returns the current Color3 object
  16114. */
  16115. copyFromFloats(r: number, g: number, b: number): Color3;
  16116. /**
  16117. * Updates the Color3 rgb values from the given floats
  16118. * @param r defines the red component to read from
  16119. * @param g defines the green component to read from
  16120. * @param b defines the blue component to read from
  16121. * @returns the current Color3 object
  16122. */
  16123. set(r: number, g: number, b: number): Color3;
  16124. /**
  16125. * Compute the Color3 hexadecimal code as a string
  16126. * @returns a string containing the hexadecimal representation of the Color3 object
  16127. */
  16128. toHexString(): string;
  16129. /**
  16130. * Computes a new Color3 converted from the current one to linear space
  16131. * @returns a new Color3 object
  16132. */
  16133. toLinearSpace(): Color3;
  16134. /**
  16135. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  16136. * @param convertedColor defines the Color3 object where to store the linear space version
  16137. * @returns the unmodified Color3
  16138. */
  16139. toLinearSpaceToRef(convertedColor: Color3): Color3;
  16140. /**
  16141. * Computes a new Color3 converted from the current one to gamma space
  16142. * @returns a new Color3 object
  16143. */
  16144. toGammaSpace(): Color3;
  16145. /**
  16146. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  16147. * @param convertedColor defines the Color3 object where to store the gamma space version
  16148. * @returns the unmodified Color3
  16149. */
  16150. toGammaSpaceToRef(convertedColor: Color3): Color3;
  16151. /**
  16152. * Creates a new Color3 from the string containing valid hexadecimal values
  16153. * @param hex defines a string containing valid hexadecimal values
  16154. * @returns a new Color3 object
  16155. */
  16156. static FromHexString(hex: string): Color3;
  16157. /**
  16158. * Creates a new Vector3 from the starting index of the given array
  16159. * @param array defines the source array
  16160. * @param offset defines an offset in the source array
  16161. * @returns a new Color3 object
  16162. */
  16163. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  16164. /**
  16165. * Creates a new Color3 from integer values (< 256)
  16166. * @param r defines the red component to read from (value between 0 and 255)
  16167. * @param g defines the green component to read from (value between 0 and 255)
  16168. * @param b defines the blue component to read from (value between 0 and 255)
  16169. * @returns a new Color3 object
  16170. */
  16171. static FromInts(r: number, g: number, b: number): Color3;
  16172. /**
  16173. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  16174. * @param start defines the start Color3 value
  16175. * @param end defines the end Color3 value
  16176. * @param amount defines the gradient value between start and end
  16177. * @returns a new Color3 object
  16178. */
  16179. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  16180. /**
  16181. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  16182. * @param left defines the start value
  16183. * @param right defines the end value
  16184. * @param amount defines the gradient factor
  16185. * @param result defines the Color3 object where to store the result
  16186. */
  16187. static LerpToRef(left: Color3, right: Color3, amount: number, result: Color3): void;
  16188. /**
  16189. * Returns a Color3 value containing a red color
  16190. * @returns a new Color3 object
  16191. */
  16192. static Red(): Color3;
  16193. /**
  16194. * Returns a Color3 value containing a green color
  16195. * @returns a new Color3 object
  16196. */
  16197. static Green(): Color3;
  16198. /**
  16199. * Returns a Color3 value containing a blue color
  16200. * @returns a new Color3 object
  16201. */
  16202. static Blue(): Color3;
  16203. /**
  16204. * Returns a Color3 value containing a black color
  16205. * @returns a new Color3 object
  16206. */
  16207. static Black(): Color3;
  16208. /**
  16209. * Returns a Color3 value containing a white color
  16210. * @returns a new Color3 object
  16211. */
  16212. static White(): Color3;
  16213. /**
  16214. * Returns a Color3 value containing a purple color
  16215. * @returns a new Color3 object
  16216. */
  16217. static Purple(): Color3;
  16218. /**
  16219. * Returns a Color3 value containing a magenta color
  16220. * @returns a new Color3 object
  16221. */
  16222. static Magenta(): Color3;
  16223. /**
  16224. * Returns a Color3 value containing a yellow color
  16225. * @returns a new Color3 object
  16226. */
  16227. static Yellow(): Color3;
  16228. /**
  16229. * Returns a Color3 value containing a gray color
  16230. * @returns a new Color3 object
  16231. */
  16232. static Gray(): Color3;
  16233. /**
  16234. * Returns a Color3 value containing a teal color
  16235. * @returns a new Color3 object
  16236. */
  16237. static Teal(): Color3;
  16238. /**
  16239. * Returns a Color3 value containing a random color
  16240. * @returns a new Color3 object
  16241. */
  16242. static Random(): Color3;
  16243. }
  16244. /**
  16245. * Class used to hold a RBGA color
  16246. */
  16247. class Color4 {
  16248. /**
  16249. * Defines the red component (between 0 and 1, default is 0)
  16250. */
  16251. r: number;
  16252. /**
  16253. * Defines the green component (between 0 and 1, default is 0)
  16254. */
  16255. g: number;
  16256. /**
  16257. * Defines the blue component (between 0 and 1, default is 0)
  16258. */
  16259. b: number;
  16260. /**
  16261. * Defines the alpha component (between 0 and 1, default is 1)
  16262. */
  16263. a: number;
  16264. /**
  16265. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  16266. * @param r defines the red component (between 0 and 1, default is 0)
  16267. * @param g defines the green component (between 0 and 1, default is 0)
  16268. * @param b defines the blue component (between 0 and 1, default is 0)
  16269. * @param a defines the alpha component (between 0 and 1, default is 1)
  16270. */
  16271. constructor(
  16272. /**
  16273. * Defines the red component (between 0 and 1, default is 0)
  16274. */
  16275. r?: number,
  16276. /**
  16277. * Defines the green component (between 0 and 1, default is 0)
  16278. */
  16279. g?: number,
  16280. /**
  16281. * Defines the blue component (between 0 and 1, default is 0)
  16282. */
  16283. b?: number,
  16284. /**
  16285. * Defines the alpha component (between 0 and 1, default is 1)
  16286. */
  16287. a?: number);
  16288. /**
  16289. * Adds in place the given Color4 values to the current Color4 object
  16290. * @param right defines the second operand
  16291. * @returns the current updated Color4 object
  16292. */
  16293. addInPlace(right: Color4): Color4;
  16294. /**
  16295. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  16296. * @returns the new array
  16297. */
  16298. asArray(): number[];
  16299. /**
  16300. * Stores from the starting index in the given array the Color4 successive values
  16301. * @param array defines the array where to store the r,g,b components
  16302. * @param index defines an optional index in the target array to define where to start storing values
  16303. * @returns the current Color4 object
  16304. */
  16305. toArray(array: number[], index?: number): Color4;
  16306. /**
  16307. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  16308. * @param right defines the second operand
  16309. * @returns a new Color4 object
  16310. */
  16311. add(right: Color4): Color4;
  16312. /**
  16313. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  16314. * @param right defines the second operand
  16315. * @returns a new Color4 object
  16316. */
  16317. subtract(right: Color4): Color4;
  16318. /**
  16319. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  16320. * @param right defines the second operand
  16321. * @param result defines the Color4 object where to store the result
  16322. * @returns the current Color4 object
  16323. */
  16324. subtractToRef(right: Color4, result: Color4): Color4;
  16325. /**
  16326. * Creates a new Color4 with the current Color4 values multiplied by scale
  16327. * @param scale defines the scaling factor to apply
  16328. * @returns a new Color4 object
  16329. */
  16330. scale(scale: number): Color4;
  16331. /**
  16332. * Multiplies the current Color4 values by scale and stores the result in "result"
  16333. * @param scale defines the scaling factor to apply
  16334. * @param result defines the Color4 object where to store the result
  16335. * @returns the current unmodified Color4
  16336. */
  16337. scaleToRef(scale: number, result: Color4): Color4;
  16338. /**
  16339. * Scale the current Color4 values by a factor and add the result to a given Color4
  16340. * @param scale defines the scale factor
  16341. * @param result defines the Color4 object where to store the result
  16342. * @returns the unmodified current Color4
  16343. */
  16344. scaleAndAddToRef(scale: number, result: Color4): Color4;
  16345. /**
  16346. * Clamps the rgb values by the min and max values and stores the result into "result"
  16347. * @param min defines minimum clamping value (default is 0)
  16348. * @param max defines maximum clamping value (default is 1)
  16349. * @param result defines color to store the result into.
  16350. * @returns the cuurent Color4
  16351. */
  16352. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  16353. /**
  16354. * Multipy an Color4 value by another and return a new Color4 object
  16355. * @param color defines the Color4 value to multiply by
  16356. * @returns a new Color4 object
  16357. */
  16358. multiply(color: Color4): Color4;
  16359. /**
  16360. * Multipy a Color4 value by another and push the result in a reference value
  16361. * @param color defines the Color4 value to multiply by
  16362. * @param result defines the Color4 to fill the result in
  16363. * @returns the result Color4
  16364. */
  16365. multiplyToRef(color: Color4, result: Color4): Color4;
  16366. /**
  16367. * Creates a string with the Color4 current values
  16368. * @returns the string representation of the Color4 object
  16369. */
  16370. toString(): string;
  16371. /**
  16372. * Returns the string "Color4"
  16373. * @returns "Color4"
  16374. */
  16375. getClassName(): string;
  16376. /**
  16377. * Compute the Color4 hash code
  16378. * @returns an unique number that can be used to hash Color4 objects
  16379. */
  16380. getHashCode(): number;
  16381. /**
  16382. * Creates a new Color4 copied from the current one
  16383. * @returns a new Color4 object
  16384. */
  16385. clone(): Color4;
  16386. /**
  16387. * Copies the given Color4 values into the current one
  16388. * @param source defines the source Color4 object
  16389. * @returns the current updated Color4 object
  16390. */
  16391. copyFrom(source: Color4): Color4;
  16392. /**
  16393. * Copies the given float values into the current one
  16394. * @param r defines the red component to read from
  16395. * @param g defines the green component to read from
  16396. * @param b defines the blue component to read from
  16397. * @param a defines the alpha component to read from
  16398. * @returns the current updated Color4 object
  16399. */
  16400. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  16401. /**
  16402. * Copies the given float values into the current one
  16403. * @param r defines the red component to read from
  16404. * @param g defines the green component to read from
  16405. * @param b defines the blue component to read from
  16406. * @param a defines the alpha component to read from
  16407. * @returns the current updated Color4 object
  16408. */
  16409. set(r: number, g: number, b: number, a: number): Color4;
  16410. /**
  16411. * Compute the Color4 hexadecimal code as a string
  16412. * @returns a string containing the hexadecimal representation of the Color4 object
  16413. */
  16414. toHexString(): string;
  16415. /**
  16416. * Computes a new Color4 converted from the current one to linear space
  16417. * @returns a new Color4 object
  16418. */
  16419. toLinearSpace(): Color4;
  16420. /**
  16421. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  16422. * @param convertedColor defines the Color4 object where to store the linear space version
  16423. * @returns the unmodified Color4
  16424. */
  16425. toLinearSpaceToRef(convertedColor: Color4): Color4;
  16426. /**
  16427. * Computes a new Color4 converted from the current one to gamma space
  16428. * @returns a new Color4 object
  16429. */
  16430. toGammaSpace(): Color4;
  16431. /**
  16432. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  16433. * @param convertedColor defines the Color4 object where to store the gamma space version
  16434. * @returns the unmodified Color4
  16435. */
  16436. toGammaSpaceToRef(convertedColor: Color4): Color4;
  16437. /**
  16438. * Creates a new Color4 from the string containing valid hexadecimal values
  16439. * @param hex defines a string containing valid hexadecimal values
  16440. * @returns a new Color4 object
  16441. */
  16442. static FromHexString(hex: string): Color4;
  16443. /**
  16444. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  16445. * @param left defines the start value
  16446. * @param right defines the end value
  16447. * @param amount defines the gradient factor
  16448. * @returns a new Color4 object
  16449. */
  16450. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  16451. /**
  16452. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  16453. * @param left defines the start value
  16454. * @param right defines the end value
  16455. * @param amount defines the gradient factor
  16456. * @param result defines the Color4 object where to store data
  16457. */
  16458. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  16459. /**
  16460. * Creates a new Color4 from a Color3 and an alpha value
  16461. * @param color3 defines the source Color3 to read from
  16462. * @param alpha defines the alpha component (1.0 by default)
  16463. * @returns a new Color4 object
  16464. */
  16465. static FromColor3(color3: Color3, alpha?: number): Color4;
  16466. /**
  16467. * Creates a new Color4 from the starting index element of the given array
  16468. * @param array defines the source array to read from
  16469. * @param offset defines the offset in the source array
  16470. * @returns a new Color4 object
  16471. */
  16472. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  16473. /**
  16474. * Creates a new Color3 from integer values (< 256)
  16475. * @param r defines the red component to read from (value between 0 and 255)
  16476. * @param g defines the green component to read from (value between 0 and 255)
  16477. * @param b defines the blue component to read from (value between 0 and 255)
  16478. * @param a defines the alpha component to read from (value between 0 and 255)
  16479. * @returns a new Color3 object
  16480. */
  16481. static FromInts(r: number, g: number, b: number, a: number): Color4;
  16482. /**
  16483. * Check the content of a given array and convert it to an array containing RGBA data
  16484. * If the original array was already containing count * 4 values then it is returned directly
  16485. * @param colors defines the array to check
  16486. * @param count defines the number of RGBA data to expect
  16487. * @returns an array containing count * 4 values (RGBA)
  16488. */
  16489. static CheckColors4(colors: number[], count: number): number[];
  16490. }
  16491. /**
  16492. * Class representing a vector containing 2 coordinates
  16493. */
  16494. class Vector2 {
  16495. /** defines the first coordinate */
  16496. x: number;
  16497. /** defines the second coordinate */
  16498. y: number;
  16499. /**
  16500. * Creates a new Vector2 from the given x and y coordinates
  16501. * @param x defines the first coordinate
  16502. * @param y defines the second coordinate
  16503. */
  16504. constructor(
  16505. /** defines the first coordinate */
  16506. x?: number,
  16507. /** defines the second coordinate */
  16508. y?: number);
  16509. /**
  16510. * Gets a string with the Vector2 coordinates
  16511. * @returns a string with the Vector2 coordinates
  16512. */
  16513. toString(): string;
  16514. /**
  16515. * Gets class name
  16516. * @returns the string "Vector2"
  16517. */
  16518. getClassName(): string;
  16519. /**
  16520. * Gets current vector hash code
  16521. * @returns the Vector2 hash code as a number
  16522. */
  16523. getHashCode(): number;
  16524. /**
  16525. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  16526. * @param array defines the source array
  16527. * @param index defines the offset in source array
  16528. * @returns the current Vector2
  16529. */
  16530. toArray(array: FloatArray, index?: number): Vector2;
  16531. /**
  16532. * Copy the current vector to an array
  16533. * @returns a new array with 2 elements: the Vector2 coordinates.
  16534. */
  16535. asArray(): number[];
  16536. /**
  16537. * Sets the Vector2 coordinates with the given Vector2 coordinates
  16538. * @param source defines the source Vector2
  16539. * @returns the current updated Vector2
  16540. */
  16541. copyFrom(source: Vector2): Vector2;
  16542. /**
  16543. * Sets the Vector2 coordinates with the given floats
  16544. * @param x defines the first coordinate
  16545. * @param y defines the second coordinate
  16546. * @returns the current updated Vector2
  16547. */
  16548. copyFromFloats(x: number, y: number): Vector2;
  16549. /**
  16550. * Sets the Vector2 coordinates with the given floats
  16551. * @param x defines the first coordinate
  16552. * @param y defines the second coordinate
  16553. * @returns the current updated Vector2
  16554. */
  16555. set(x: number, y: number): Vector2;
  16556. /**
  16557. * Add another vector with the current one
  16558. * @param otherVector defines the other vector
  16559. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  16560. */
  16561. add(otherVector: Vector2): Vector2;
  16562. /**
  16563. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  16564. * @param otherVector defines the other vector
  16565. * @param result defines the target vector
  16566. * @returns the unmodified current Vector2
  16567. */
  16568. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  16569. /**
  16570. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  16571. * @param otherVector defines the other vector
  16572. * @returns the current updated Vector2
  16573. */
  16574. addInPlace(otherVector: Vector2): Vector2;
  16575. /**
  16576. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  16577. * @param otherVector defines the other vector
  16578. * @returns a new Vector2
  16579. */
  16580. addVector3(otherVector: Vector3): Vector2;
  16581. /**
  16582. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  16583. * @param otherVector defines the other vector
  16584. * @returns a new Vector2
  16585. */
  16586. subtract(otherVector: Vector2): Vector2;
  16587. /**
  16588. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  16589. * @param otherVector defines the other vector
  16590. * @param result defines the target vector
  16591. * @returns the unmodified current Vector2
  16592. */
  16593. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  16594. /**
  16595. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  16596. * @param otherVector defines the other vector
  16597. * @returns the current updated Vector2
  16598. */
  16599. subtractInPlace(otherVector: Vector2): Vector2;
  16600. /**
  16601. * Multiplies in place the current Vector2 coordinates by the given ones
  16602. * @param otherVector defines the other vector
  16603. * @returns the current updated Vector2
  16604. */
  16605. multiplyInPlace(otherVector: Vector2): Vector2;
  16606. /**
  16607. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  16608. * @param otherVector defines the other vector
  16609. * @returns a new Vector2
  16610. */
  16611. multiply(otherVector: Vector2): Vector2;
  16612. /**
  16613. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  16614. * @param otherVector defines the other vector
  16615. * @param result defines the target vector
  16616. * @returns the unmodified current Vector2
  16617. */
  16618. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  16619. /**
  16620. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  16621. * @param x defines the first coordinate
  16622. * @param y defines the second coordinate
  16623. * @returns a new Vector2
  16624. */
  16625. multiplyByFloats(x: number, y: number): Vector2;
  16626. /**
  16627. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  16628. * @param otherVector defines the other vector
  16629. * @returns a new Vector2
  16630. */
  16631. divide(otherVector: Vector2): Vector2;
  16632. /**
  16633. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  16634. * @param otherVector defines the other vector
  16635. * @param result defines the target vector
  16636. * @returns the unmodified current Vector2
  16637. */
  16638. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  16639. /**
  16640. * Divides the current Vector2 coordinates by the given ones
  16641. * @param otherVector defines the other vector
  16642. * @returns the current updated Vector2
  16643. */
  16644. divideInPlace(otherVector: Vector2): Vector2;
  16645. /**
  16646. * Gets a new Vector2 with current Vector2 negated coordinates
  16647. * @returns a new Vector2
  16648. */
  16649. negate(): Vector2;
  16650. /**
  16651. * Multiply the Vector2 coordinates by scale
  16652. * @param scale defines the scaling factor
  16653. * @returns the current updated Vector2
  16654. */
  16655. scaleInPlace(scale: number): Vector2;
  16656. /**
  16657. * Returns a new Vector2 scaled by "scale" from the current Vector2
  16658. * @param scale defines the scaling factor
  16659. * @returns a new Vector2
  16660. */
  16661. scale(scale: number): Vector2;
  16662. /**
  16663. * Scale the current Vector2 values by a factor to a given Vector2
  16664. * @param scale defines the scale factor
  16665. * @param result defines the Vector2 object where to store the result
  16666. * @returns the unmodified current Vector2
  16667. */
  16668. scaleToRef(scale: number, result: Vector2): Vector2;
  16669. /**
  16670. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  16671. * @param scale defines the scale factor
  16672. * @param result defines the Vector2 object where to store the result
  16673. * @returns the unmodified current Vector2
  16674. */
  16675. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  16676. /**
  16677. * Gets a boolean if two vectors are equals
  16678. * @param otherVector defines the other vector
  16679. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  16680. */
  16681. equals(otherVector: Vector2): boolean;
  16682. /**
  16683. * Gets a boolean if two vectors are equals (using an epsilon value)
  16684. * @param otherVector defines the other vector
  16685. * @param epsilon defines the minimal distance to consider equality
  16686. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  16687. */
  16688. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  16689. /**
  16690. * Gets a new Vector2 from current Vector2 floored values
  16691. * @returns a new Vector2
  16692. */
  16693. floor(): Vector2;
  16694. /**
  16695. * Gets a new Vector2 from current Vector2 floored values
  16696. * @returns a new Vector2
  16697. */
  16698. fract(): Vector2;
  16699. /**
  16700. * Gets the length of the vector
  16701. * @returns the vector length (float)
  16702. */
  16703. length(): number;
  16704. /**
  16705. * Gets the vector squared length
  16706. * @returns the vector squared length (float)
  16707. */
  16708. lengthSquared(): number;
  16709. /**
  16710. * Normalize the vector
  16711. * @returns the current updated Vector2
  16712. */
  16713. normalize(): Vector2;
  16714. /**
  16715. * Gets a new Vector2 copied from the Vector2
  16716. * @returns a new Vector2
  16717. */
  16718. clone(): Vector2;
  16719. /**
  16720. * Gets a new Vector2(0, 0)
  16721. * @returns a new Vector2
  16722. */
  16723. static Zero(): Vector2;
  16724. /**
  16725. * Gets a new Vector2(1, 1)
  16726. * @returns a new Vector2
  16727. */
  16728. static One(): Vector2;
  16729. /**
  16730. * Gets a new Vector2 set from the given index element of the given array
  16731. * @param array defines the data source
  16732. * @param offset defines the offset in the data source
  16733. * @returns a new Vector2
  16734. */
  16735. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  16736. /**
  16737. * Sets "result" from the given index element of the given array
  16738. * @param array defines the data source
  16739. * @param offset defines the offset in the data source
  16740. * @param result defines the target vector
  16741. */
  16742. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  16743. /**
  16744. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  16745. * @param value1 defines 1st point of control
  16746. * @param value2 defines 2nd point of control
  16747. * @param value3 defines 3rd point of control
  16748. * @param value4 defines 4th point of control
  16749. * @param amount defines the interpolation factor
  16750. * @returns a new Vector2
  16751. */
  16752. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  16753. /**
  16754. * 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".
  16755. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  16756. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  16757. * @param value defines the value to clamp
  16758. * @param min defines the lower limit
  16759. * @param max defines the upper limit
  16760. * @returns a new Vector2
  16761. */
  16762. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  16763. /**
  16764. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  16765. * @param value1 defines the 1st control point
  16766. * @param tangent1 defines the outgoing tangent
  16767. * @param value2 defines the 2nd control point
  16768. * @param tangent2 defines the incoming tangent
  16769. * @param amount defines the interpolation factor
  16770. * @returns a new Vector2
  16771. */
  16772. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  16773. /**
  16774. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  16775. * @param start defines the start vector
  16776. * @param end defines the end vector
  16777. * @param amount defines the interpolation factor
  16778. * @returns a new Vector2
  16779. */
  16780. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  16781. /**
  16782. * Gets the dot product of the vector "left" and the vector "right"
  16783. * @param left defines first vector
  16784. * @param right defines second vector
  16785. * @returns the dot product (float)
  16786. */
  16787. static Dot(left: Vector2, right: Vector2): number;
  16788. /**
  16789. * Returns a new Vector2 equal to the normalized given vector
  16790. * @param vector defines the vector to normalize
  16791. * @returns a new Vector2
  16792. */
  16793. static Normalize(vector: Vector2): Vector2;
  16794. /**
  16795. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  16796. * @param left defines 1st vector
  16797. * @param right defines 2nd vector
  16798. * @returns a new Vector2
  16799. */
  16800. static Minimize(left: Vector2, right: Vector2): Vector2;
  16801. /**
  16802. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  16803. * @param left defines 1st vector
  16804. * @param right defines 2nd vector
  16805. * @returns a new Vector2
  16806. */
  16807. static Maximize(left: Vector2, right: Vector2): Vector2;
  16808. /**
  16809. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  16810. * @param vector defines the vector to transform
  16811. * @param transformation defines the matrix to apply
  16812. * @returns a new Vector2
  16813. */
  16814. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  16815. /**
  16816. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  16817. * @param vector defines the vector to transform
  16818. * @param transformation defines the matrix to apply
  16819. * @param result defines the target vector
  16820. */
  16821. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  16822. /**
  16823. * Determines if a given vector is included in a triangle
  16824. * @param p defines the vector to test
  16825. * @param p0 defines 1st triangle point
  16826. * @param p1 defines 2nd triangle point
  16827. * @param p2 defines 3rd triangle point
  16828. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  16829. */
  16830. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  16831. /**
  16832. * Gets the distance between the vectors "value1" and "value2"
  16833. * @param value1 defines first vector
  16834. * @param value2 defines second vector
  16835. * @returns the distance between vectors
  16836. */
  16837. static Distance(value1: Vector2, value2: Vector2): number;
  16838. /**
  16839. * Returns the squared distance between the vectors "value1" and "value2"
  16840. * @param value1 defines first vector
  16841. * @param value2 defines second vector
  16842. * @returns the squared distance between vectors
  16843. */
  16844. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  16845. /**
  16846. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  16847. * @param value1 defines first vector
  16848. * @param value2 defines second vector
  16849. * @returns a new Vector2
  16850. */
  16851. static Center(value1: Vector2, value2: Vector2): Vector2;
  16852. /**
  16853. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  16854. * @param p defines the middle point
  16855. * @param segA defines one point of the segment
  16856. * @param segB defines the other point of the segment
  16857. * @returns the shortest distance
  16858. */
  16859. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  16860. }
  16861. /**
  16862. * Classed used to store (x,y,z) vector representation
  16863. * A Vector3 is the main object used in 3D geometry
  16864. * It can represent etiher the coordinates of a point the space, either a direction
  16865. * Reminder: Babylon.js uses a left handed forward facing system
  16866. */
  16867. class Vector3 {
  16868. /**
  16869. * Defines the first coordinates (on X axis)
  16870. */
  16871. x: number;
  16872. /**
  16873. * Defines the second coordinates (on Y axis)
  16874. */
  16875. y: number;
  16876. /**
  16877. * Defines the third coordinates (on Z axis)
  16878. */
  16879. z: number;
  16880. /**
  16881. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  16882. * @param x defines the first coordinates (on X axis)
  16883. * @param y defines the second coordinates (on Y axis)
  16884. * @param z defines the third coordinates (on Z axis)
  16885. */
  16886. constructor(
  16887. /**
  16888. * Defines the first coordinates (on X axis)
  16889. */
  16890. x?: number,
  16891. /**
  16892. * Defines the second coordinates (on Y axis)
  16893. */
  16894. y?: number,
  16895. /**
  16896. * Defines the third coordinates (on Z axis)
  16897. */
  16898. z?: number);
  16899. /**
  16900. * Creates a string representation of the Vector3
  16901. * @returns a string with the Vector3 coordinates.
  16902. */
  16903. toString(): string;
  16904. /**
  16905. * Gets the class name
  16906. * @returns the string "Vector3"
  16907. */
  16908. getClassName(): string;
  16909. /**
  16910. * Creates the Vector3 hash code
  16911. * @returns a number which tends to be unique between Vector3 instances
  16912. */
  16913. getHashCode(): number;
  16914. /**
  16915. * Creates an array containing three elements : the coordinates of the Vector3
  16916. * @returns a new array of numbers
  16917. */
  16918. asArray(): number[];
  16919. /**
  16920. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  16921. * @param array defines the destination array
  16922. * @param index defines the offset in the destination array
  16923. * @returns the current Vector3
  16924. */
  16925. toArray(array: FloatArray, index?: number): Vector3;
  16926. /**
  16927. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  16928. * @returns a new Quaternion object, computed from the Vector3 coordinates
  16929. */
  16930. toQuaternion(): Quaternion;
  16931. /**
  16932. * Adds the given vector to the current Vector3
  16933. * @param otherVector defines the second operand
  16934. * @returns the current updated Vector3
  16935. */
  16936. addInPlace(otherVector: Vector3): Vector3;
  16937. /**
  16938. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  16939. * @param otherVector defines the second operand
  16940. * @returns the resulting Vector3
  16941. */
  16942. add(otherVector: Vector3): Vector3;
  16943. /**
  16944. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  16945. * @param otherVector defines the second operand
  16946. * @param result defines the Vector3 object where to store the result
  16947. * @returns the current Vector3
  16948. */
  16949. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  16950. /**
  16951. * Subtract the given vector from the current Vector3
  16952. * @param otherVector defines the second operand
  16953. * @returns the current updated Vector3
  16954. */
  16955. subtractInPlace(otherVector: Vector3): Vector3;
  16956. /**
  16957. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  16958. * @param otherVector defines the second operand
  16959. * @returns the resulting Vector3
  16960. */
  16961. subtract(otherVector: Vector3): Vector3;
  16962. /**
  16963. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  16964. * @param otherVector defines the second operand
  16965. * @param result defines the Vector3 object where to store the result
  16966. * @returns the current Vector3
  16967. */
  16968. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  16969. /**
  16970. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  16971. * @param x defines the x coordinate of the operand
  16972. * @param y defines the y coordinate of the operand
  16973. * @param z defines the z coordinate of the operand
  16974. * @returns the resulting Vector3
  16975. */
  16976. subtractFromFloats(x: number, y: number, z: number): Vector3;
  16977. /**
  16978. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  16979. * @param x defines the x coordinate of the operand
  16980. * @param y defines the y coordinate of the operand
  16981. * @param z defines the z coordinate of the operand
  16982. * @param result defines the Vector3 object where to store the result
  16983. * @returns the current Vector3
  16984. */
  16985. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  16986. /**
  16987. * Gets a new Vector3 set with the current Vector3 negated coordinates
  16988. * @returns a new Vector3
  16989. */
  16990. negate(): Vector3;
  16991. /**
  16992. * Multiplies the Vector3 coordinates by the float "scale"
  16993. * @param scale defines the multiplier factor
  16994. * @returns the current updated Vector3
  16995. */
  16996. scaleInPlace(scale: number): Vector3;
  16997. /**
  16998. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  16999. * @param scale defines the multiplier factor
  17000. * @returns a new Vector3
  17001. */
  17002. scale(scale: number): Vector3;
  17003. /**
  17004. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  17005. * @param scale defines the multiplier factor
  17006. * @param result defines the Vector3 object where to store the result
  17007. * @returns the current Vector3
  17008. */
  17009. scaleToRef(scale: number, result: Vector3): Vector3;
  17010. /**
  17011. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  17012. * @param scale defines the scale factor
  17013. * @param result defines the Vector3 object where to store the result
  17014. * @returns the unmodified current Vector3
  17015. */
  17016. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  17017. /**
  17018. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  17019. * @param otherVector defines the second operand
  17020. * @returns true if both vectors are equals
  17021. */
  17022. equals(otherVector: Vector3): boolean;
  17023. /**
  17024. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  17025. * @param otherVector defines the second operand
  17026. * @param epsilon defines the minimal distance to define values as equals
  17027. * @returns true if both vectors are distant less than epsilon
  17028. */
  17029. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  17030. /**
  17031. * Returns true if the current Vector3 coordinates equals the given floats
  17032. * @param x defines the x coordinate of the operand
  17033. * @param y defines the y coordinate of the operand
  17034. * @param z defines the z coordinate of the operand
  17035. * @returns true if both vectors are equals
  17036. */
  17037. equalsToFloats(x: number, y: number, z: number): boolean;
  17038. /**
  17039. * Multiplies the current Vector3 coordinates by the given ones
  17040. * @param otherVector defines the second operand
  17041. * @returns the current updated Vector3
  17042. */
  17043. multiplyInPlace(otherVector: Vector3): Vector3;
  17044. /**
  17045. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  17046. * @param otherVector defines the second operand
  17047. * @returns the new Vector3
  17048. */
  17049. multiply(otherVector: Vector3): Vector3;
  17050. /**
  17051. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  17052. * @param otherVector defines the second operand
  17053. * @param result defines the Vector3 object where to store the result
  17054. * @returns the current Vector3
  17055. */
  17056. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  17057. /**
  17058. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  17059. * @param x defines the x coordinate of the operand
  17060. * @param y defines the y coordinate of the operand
  17061. * @param z defines the z coordinate of the operand
  17062. * @returns the new Vector3
  17063. */
  17064. multiplyByFloats(x: number, y: number, z: number): Vector3;
  17065. /**
  17066. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  17067. * @param otherVector defines the second operand
  17068. * @returns the new Vector3
  17069. */
  17070. divide(otherVector: Vector3): Vector3;
  17071. /**
  17072. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  17073. * @param otherVector defines the second operand
  17074. * @param result defines the Vector3 object where to store the result
  17075. * @returns the current Vector3
  17076. */
  17077. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  17078. /**
  17079. * Divides the current Vector3 coordinates by the given ones.
  17080. * @param otherVector defines the second operand
  17081. * @returns the current updated Vector3
  17082. */
  17083. divideInPlace(otherVector: Vector3): Vector3;
  17084. /**
  17085. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  17086. * @param other defines the second operand
  17087. * @returns the current updated Vector3
  17088. */
  17089. minimizeInPlace(other: Vector3): Vector3;
  17090. /**
  17091. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  17092. * @param other defines the second operand
  17093. * @returns the current updated Vector3
  17094. */
  17095. maximizeInPlace(other: Vector3): Vector3;
  17096. /**
  17097. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  17098. */
  17099. readonly isNonUniform: boolean;
  17100. /**
  17101. * Gets a new Vector3 from current Vector3 floored values
  17102. * @returns a new Vector3
  17103. */
  17104. floor(): Vector3;
  17105. /**
  17106. * Gets a new Vector3 from current Vector3 floored values
  17107. * @returns a new Vector3
  17108. */
  17109. fract(): Vector3;
  17110. /**
  17111. * Gets the length of the Vector3
  17112. * @returns the length of the Vecto3
  17113. */
  17114. length(): number;
  17115. /**
  17116. * Gets the squared length of the Vector3
  17117. * @returns squared length of the Vector3
  17118. */
  17119. lengthSquared(): number;
  17120. /**
  17121. * Normalize the current Vector3.
  17122. * Please note that this is an in place operation.
  17123. * @returns the current updated Vector3
  17124. */
  17125. normalize(): Vector3;
  17126. /**
  17127. * Normalize the current Vector3 to a new vector
  17128. * @returns the new Vector3
  17129. */
  17130. normalizeToNew(): Vector3;
  17131. /**
  17132. * Normalize the current Vector3 to the reference
  17133. * @param reference define the Vector3 to update
  17134. * @returns the updated Vector3
  17135. */
  17136. normalizeToRef(reference: Vector3): Vector3;
  17137. /**
  17138. * Creates a new Vector3 copied from the current Vector3
  17139. * @returns the new Vector3
  17140. */
  17141. clone(): Vector3;
  17142. /**
  17143. * Copies the given vector coordinates to the current Vector3 ones
  17144. * @param source defines the source Vector3
  17145. * @returns the current updated Vector3
  17146. */
  17147. copyFrom(source: Vector3): Vector3;
  17148. /**
  17149. * Copies the given floats to the current Vector3 coordinates
  17150. * @param x defines the x coordinate of the operand
  17151. * @param y defines the y coordinate of the operand
  17152. * @param z defines the z coordinate of the operand
  17153. * @returns the current updated Vector3
  17154. */
  17155. copyFromFloats(x: number, y: number, z: number): Vector3;
  17156. /**
  17157. * Copies the given floats to the current Vector3 coordinates
  17158. * @param x defines the x coordinate of the operand
  17159. * @param y defines the y coordinate of the operand
  17160. * @param z defines the z coordinate of the operand
  17161. * @returns the current updated Vector3
  17162. */
  17163. set(x: number, y: number, z: number): Vector3;
  17164. /**
  17165. * Get the clip factor between two vectors
  17166. * @param vector0 defines the first operand
  17167. * @param vector1 defines the second operand
  17168. * @param axis defines the axis to use
  17169. * @param size defines the size along the axis
  17170. * @returns the clip factor
  17171. */
  17172. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  17173. /**
  17174. * Get angle between two vectors
  17175. * @param vector0 angle between vector0 and vector1
  17176. * @param vector1 angle between vector0 and vector1
  17177. * @param normal direction of the normal
  17178. * @return the angle between vector0 and vector1
  17179. */
  17180. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  17181. /**
  17182. * Returns a new Vector3 set from the index "offset" of the given array
  17183. * @param array defines the source array
  17184. * @param offset defines the offset in the source array
  17185. * @returns the new Vector3
  17186. */
  17187. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  17188. /**
  17189. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  17190. * This function is deprecated. Use FromArray instead
  17191. * @param array defines the source array
  17192. * @param offset defines the offset in the source array
  17193. * @returns the new Vector3
  17194. */
  17195. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  17196. /**
  17197. * Sets the given vector "result" with the element values from the index "offset" of the given array
  17198. * @param array defines the source array
  17199. * @param offset defines the offset in the source array
  17200. * @param result defines the Vector3 where to store the result
  17201. */
  17202. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  17203. /**
  17204. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  17205. * This function is deprecated. Use FromArrayToRef instead.
  17206. * @param array defines the source array
  17207. * @param offset defines the offset in the source array
  17208. * @param result defines the Vector3 where to store the result
  17209. */
  17210. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  17211. /**
  17212. * Sets the given vector "result" with the given floats.
  17213. * @param x defines the x coordinate of the source
  17214. * @param y defines the y coordinate of the source
  17215. * @param z defines the z coordinate of the source
  17216. * @param result defines the Vector3 where to store the result
  17217. */
  17218. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  17219. /**
  17220. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  17221. * @returns a new empty Vector3
  17222. */
  17223. static Zero(): Vector3;
  17224. /**
  17225. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  17226. * @returns a new unit Vector3
  17227. */
  17228. static One(): Vector3;
  17229. /**
  17230. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  17231. * @returns a new up Vector3
  17232. */
  17233. static Up(): Vector3;
  17234. /**
  17235. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  17236. * @returns a new down Vector3
  17237. */
  17238. static Down(): Vector3;
  17239. /**
  17240. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  17241. * @returns a new forward Vector3
  17242. */
  17243. static Forward(): Vector3;
  17244. /**
  17245. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  17246. * @returns a new right Vector3
  17247. */
  17248. static Right(): Vector3;
  17249. /**
  17250. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  17251. * @returns a new left Vector3
  17252. */
  17253. static Left(): Vector3;
  17254. /**
  17255. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  17256. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  17257. * @param vector defines the Vector3 to transform
  17258. * @param transformation defines the transformation matrix
  17259. * @returns the transformed Vector3
  17260. */
  17261. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  17262. /**
  17263. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  17264. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  17265. * @param vector defines the Vector3 to transform
  17266. * @param transformation defines the transformation matrix
  17267. * @param result defines the Vector3 where to store the result
  17268. */
  17269. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  17270. /**
  17271. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  17272. * This method computes tranformed coordinates only, not transformed direction vectors
  17273. * @param x define the x coordinate of the source vector
  17274. * @param y define the y coordinate of the source vector
  17275. * @param z define the z coordinate of the source vector
  17276. * @param transformation defines the transformation matrix
  17277. * @param result defines the Vector3 where to store the result
  17278. */
  17279. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  17280. /**
  17281. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  17282. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  17283. * @param vector defines the Vector3 to transform
  17284. * @param transformation defines the transformation matrix
  17285. * @returns the new Vector3
  17286. */
  17287. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  17288. /**
  17289. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  17290. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  17291. * @param vector defines the Vector3 to transform
  17292. * @param transformation defines the transformation matrix
  17293. * @param result defines the Vector3 where to store the result
  17294. */
  17295. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  17296. /**
  17297. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  17298. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  17299. * @param x define the x coordinate of the source vector
  17300. * @param y define the y coordinate of the source vector
  17301. * @param z define the z coordinate of the source vector
  17302. * @param transformation defines the transformation matrix
  17303. * @param result defines the Vector3 where to store the result
  17304. */
  17305. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  17306. /**
  17307. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  17308. * @param value1 defines the first control point
  17309. * @param value2 defines the second control point
  17310. * @param value3 defines the third control point
  17311. * @param value4 defines the fourth control point
  17312. * @param amount defines the amount on the spline to use
  17313. * @returns the new Vector3
  17314. */
  17315. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  17316. /**
  17317. * 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"
  17318. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  17319. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  17320. * @param value defines the current value
  17321. * @param min defines the lower range value
  17322. * @param max defines the upper range value
  17323. * @returns the new Vector3
  17324. */
  17325. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  17326. /**
  17327. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  17328. * @param value1 defines the first control point
  17329. * @param tangent1 defines the first tangent vector
  17330. * @param value2 defines the second control point
  17331. * @param tangent2 defines the second tangent vector
  17332. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  17333. * @returns the new Vector3
  17334. */
  17335. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  17336. /**
  17337. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  17338. * @param start defines the start value
  17339. * @param end defines the end value
  17340. * @param amount max defines amount between both (between 0 and 1)
  17341. * @returns the new Vector3
  17342. */
  17343. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  17344. /**
  17345. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  17346. * @param start defines the start value
  17347. * @param end defines the end value
  17348. * @param amount max defines amount between both (between 0 and 1)
  17349. * @param result defines the Vector3 where to store the result
  17350. */
  17351. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  17352. /**
  17353. * Returns the dot product (float) between the vectors "left" and "right"
  17354. * @param left defines the left operand
  17355. * @param right defines the right operand
  17356. * @returns the dot product
  17357. */
  17358. static Dot(left: Vector3, right: Vector3): number;
  17359. /**
  17360. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  17361. * The cross product is then orthogonal to both "left" and "right"
  17362. * @param left defines the left operand
  17363. * @param right defines the right operand
  17364. * @returns the cross product
  17365. */
  17366. static Cross(left: Vector3, right: Vector3): Vector3;
  17367. /**
  17368. * Sets the given vector "result" with the cross product of "left" and "right"
  17369. * The cross product is then orthogonal to both "left" and "right"
  17370. * @param left defines the left operand
  17371. * @param right defines the right operand
  17372. * @param result defines the Vector3 where to store the result
  17373. */
  17374. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  17375. /**
  17376. * Returns a new Vector3 as the normalization of the given vector
  17377. * @param vector defines the Vector3 to normalize
  17378. * @returns the new Vector3
  17379. */
  17380. static Normalize(vector: Vector3): Vector3;
  17381. /**
  17382. * Sets the given vector "result" with the normalization of the given first vector
  17383. * @param vector defines the Vector3 to normalize
  17384. * @param result defines the Vector3 where to store the result
  17385. */
  17386. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  17387. private static _viewportMatrixCache;
  17388. /**
  17389. * Project a Vector3 onto screen space
  17390. * @param vector defines the Vector3 to project
  17391. * @param world defines the world matrix to use
  17392. * @param transform defines the transform (view x projection) matrix to use
  17393. * @param viewport defines the screen viewport to use
  17394. * @returns the new Vector3
  17395. */
  17396. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  17397. /**
  17398. * Unproject from screen space to object space
  17399. * @param source defines the screen space Vector3 to use
  17400. * @param viewportWidth defines the current width of the viewport
  17401. * @param viewportHeight defines the current height of the viewport
  17402. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17403. * @param transform defines the transform (view x projection) matrix to use
  17404. * @returns the new Vector3
  17405. */
  17406. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  17407. /**
  17408. * Unproject from screen space to object space
  17409. * @param source defines the screen space Vector3 to use
  17410. * @param viewportWidth defines the current width of the viewport
  17411. * @param viewportHeight defines the current height of the viewport
  17412. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17413. * @param view defines the view matrix to use
  17414. * @param projection defines the projection matrix to use
  17415. * @returns the new Vector3
  17416. */
  17417. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  17418. /**
  17419. * Unproject from screen space to object space
  17420. * @param source defines the screen space Vector3 to use
  17421. * @param viewportWidth defines the current width of the viewport
  17422. * @param viewportHeight defines the current height of the viewport
  17423. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17424. * @param view defines the view matrix to use
  17425. * @param projection defines the projection matrix to use
  17426. * @param result defines the Vector3 where to store the result
  17427. */
  17428. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  17429. /**
  17430. * Unproject from screen space to object space
  17431. * @param sourceX defines the screen space x coordinate to use
  17432. * @param sourceY defines the screen space y coordinate to use
  17433. * @param sourceZ defines the screen space z coordinate to use
  17434. * @param viewportWidth defines the current width of the viewport
  17435. * @param viewportHeight defines the current height of the viewport
  17436. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  17437. * @param view defines the view matrix to use
  17438. * @param projection defines the projection matrix to use
  17439. * @param result defines the Vector3 where to store the result
  17440. */
  17441. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  17442. /**
  17443. * Gets the minimal coordinate values between two Vector3
  17444. * @param left defines the first operand
  17445. * @param right defines the second operand
  17446. * @returns the new Vector3
  17447. */
  17448. static Minimize(left: Vector3, right: Vector3): Vector3;
  17449. /**
  17450. * Gets the maximal coordinate values between two Vector3
  17451. * @param left defines the first operand
  17452. * @param right defines the second operand
  17453. * @returns the new Vector3
  17454. */
  17455. static Maximize(left: Vector3, right: Vector3): Vector3;
  17456. /**
  17457. * Returns the distance between the vectors "value1" and "value2"
  17458. * @param value1 defines the first operand
  17459. * @param value2 defines the second operand
  17460. * @returns the distance
  17461. */
  17462. static Distance(value1: Vector3, value2: Vector3): number;
  17463. /**
  17464. * Returns the squared distance between the vectors "value1" and "value2"
  17465. * @param value1 defines the first operand
  17466. * @param value2 defines the second operand
  17467. * @returns the squared distance
  17468. */
  17469. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  17470. /**
  17471. * Returns a new Vector3 located at the center between "value1" and "value2"
  17472. * @param value1 defines the first operand
  17473. * @param value2 defines the second operand
  17474. * @returns the new Vector3
  17475. */
  17476. static Center(value1: Vector3, value2: Vector3): Vector3;
  17477. /**
  17478. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  17479. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  17480. * to something in order to rotate it from its local system to the given target system
  17481. * Note: axis1, axis2 and axis3 are normalized during this operation
  17482. * @param axis1 defines the first axis
  17483. * @param axis2 defines the second axis
  17484. * @param axis3 defines the third axis
  17485. * @returns a new Vector3
  17486. */
  17487. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  17488. /**
  17489. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  17490. * @param axis1 defines the first axis
  17491. * @param axis2 defines the second axis
  17492. * @param axis3 defines the third axis
  17493. * @param ref defines the Vector3 where to store the result
  17494. */
  17495. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  17496. }
  17497. class Vector4 {
  17498. x: number;
  17499. y: number;
  17500. z: number;
  17501. w: number;
  17502. /**
  17503. * Creates a Vector4 object from the given floats.
  17504. */
  17505. constructor(x: number, y: number, z: number, w: number);
  17506. /**
  17507. * Returns the string with the Vector4 coordinates.
  17508. */
  17509. toString(): string;
  17510. /**
  17511. * Returns the string "Vector4".
  17512. */
  17513. getClassName(): string;
  17514. /**
  17515. * Returns the Vector4 hash code.
  17516. */
  17517. getHashCode(): number;
  17518. /**
  17519. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  17520. */
  17521. asArray(): number[];
  17522. /**
  17523. * Populates the given array from the given index with the Vector4 coordinates.
  17524. * Returns the Vector4.
  17525. */
  17526. toArray(array: FloatArray, index?: number): Vector4;
  17527. /**
  17528. * Adds the given vector to the current Vector4.
  17529. * Returns the updated Vector4.
  17530. */
  17531. addInPlace(otherVector: Vector4): Vector4;
  17532. /**
  17533. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  17534. */
  17535. add(otherVector: Vector4): Vector4;
  17536. /**
  17537. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  17538. * Returns the current Vector4.
  17539. */
  17540. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  17541. /**
  17542. * Subtract in place the given vector from the current Vector4.
  17543. * Returns the updated Vector4.
  17544. */
  17545. subtractInPlace(otherVector: Vector4): Vector4;
  17546. /**
  17547. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  17548. */
  17549. subtract(otherVector: Vector4): Vector4;
  17550. /**
  17551. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  17552. * Returns the current Vector4.
  17553. */
  17554. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  17555. /**
  17556. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  17557. */
  17558. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  17559. /**
  17560. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  17561. * Returns the current Vector4.
  17562. */
  17563. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  17564. /**
  17565. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  17566. */
  17567. negate(): Vector4;
  17568. /**
  17569. * Multiplies the current Vector4 coordinates by scale (float).
  17570. * Returns the updated Vector4.
  17571. */
  17572. scaleInPlace(scale: number): Vector4;
  17573. /**
  17574. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  17575. */
  17576. scale(scale: number): Vector4;
  17577. /**
  17578. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  17579. * Returns the current Vector4.
  17580. */
  17581. scaleToRef(scale: number, result: Vector4): Vector4;
  17582. /**
  17583. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  17584. * @param scale defines the scale factor
  17585. * @param result defines the Vector4 object where to store the result
  17586. * @returns the unmodified current Vector4
  17587. */
  17588. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  17589. /**
  17590. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  17591. */
  17592. equals(otherVector: Vector4): boolean;
  17593. /**
  17594. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  17595. */
  17596. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  17597. /**
  17598. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  17599. */
  17600. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  17601. /**
  17602. * Multiplies in place the current Vector4 by the given one.
  17603. * Returns the updated Vector4.
  17604. */
  17605. multiplyInPlace(otherVector: Vector4): Vector4;
  17606. /**
  17607. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  17608. */
  17609. multiply(otherVector: Vector4): Vector4;
  17610. /**
  17611. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  17612. * Returns the current Vector4.
  17613. */
  17614. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  17615. /**
  17616. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  17617. */
  17618. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  17619. /**
  17620. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  17621. */
  17622. divide(otherVector: Vector4): Vector4;
  17623. /**
  17624. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  17625. * Returns the current Vector4.
  17626. */
  17627. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  17628. /**
  17629. * Divides the current Vector3 coordinates by the given ones.
  17630. * @returns the updated Vector3.
  17631. */
  17632. divideInPlace(otherVector: Vector4): Vector4;
  17633. /**
  17634. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  17635. * @param other defines the second operand
  17636. * @returns the current updated Vector4
  17637. */
  17638. minimizeInPlace(other: Vector4): Vector4;
  17639. /**
  17640. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  17641. * @param other defines the second operand
  17642. * @returns the current updated Vector4
  17643. */
  17644. maximizeInPlace(other: Vector4): Vector4;
  17645. /**
  17646. * Gets a new Vector4 from current Vector4 floored values
  17647. * @returns a new Vector4
  17648. */
  17649. floor(): Vector4;
  17650. /**
  17651. * Gets a new Vector4 from current Vector3 floored values
  17652. * @returns a new Vector4
  17653. */
  17654. fract(): Vector4;
  17655. /**
  17656. * Returns the Vector4 length (float).
  17657. */
  17658. length(): number;
  17659. /**
  17660. * Returns the Vector4 squared length (float).
  17661. */
  17662. lengthSquared(): number;
  17663. /**
  17664. * Normalizes in place the Vector4.
  17665. * Returns the updated Vector4.
  17666. */
  17667. normalize(): Vector4;
  17668. /**
  17669. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  17670. */
  17671. toVector3(): Vector3;
  17672. /**
  17673. * Returns a new Vector4 copied from the current one.
  17674. */
  17675. clone(): Vector4;
  17676. /**
  17677. * Updates the current Vector4 with the given one coordinates.
  17678. * Returns the updated Vector4.
  17679. */
  17680. copyFrom(source: Vector4): Vector4;
  17681. /**
  17682. * Updates the current Vector4 coordinates with the given floats.
  17683. * Returns the updated Vector4.
  17684. */
  17685. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  17686. /**
  17687. * Updates the current Vector4 coordinates with the given floats.
  17688. * Returns the updated Vector4.
  17689. */
  17690. set(x: number, y: number, z: number, w: number): Vector4;
  17691. /**
  17692. * Returns a new Vector4 set from the starting index of the given array.
  17693. */
  17694. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  17695. /**
  17696. * Updates the given vector "result" from the starting index of the given array.
  17697. */
  17698. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  17699. /**
  17700. * Updates the given vector "result" from the starting index of the given Float32Array.
  17701. */
  17702. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  17703. /**
  17704. * Updates the given vector "result" coordinates from the given floats.
  17705. */
  17706. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  17707. /**
  17708. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  17709. */
  17710. static Zero(): Vector4;
  17711. /**
  17712. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  17713. */
  17714. static One(): Vector4;
  17715. /**
  17716. * Returns a new normalized Vector4 from the given one.
  17717. */
  17718. static Normalize(vector: Vector4): Vector4;
  17719. /**
  17720. * Updates the given vector "result" from the normalization of the given one.
  17721. */
  17722. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  17723. static Minimize(left: Vector4, right: Vector4): Vector4;
  17724. static Maximize(left: Vector4, right: Vector4): Vector4;
  17725. /**
  17726. * Returns the distance (float) between the vectors "value1" and "value2".
  17727. */
  17728. static Distance(value1: Vector4, value2: Vector4): number;
  17729. /**
  17730. * Returns the squared distance (float) between the vectors "value1" and "value2".
  17731. */
  17732. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  17733. /**
  17734. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  17735. */
  17736. static Center(value1: Vector4, value2: Vector4): Vector4;
  17737. /**
  17738. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  17739. * This methods computes transformed normalized direction vectors only.
  17740. */
  17741. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  17742. /**
  17743. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  17744. * This methods computes transformed normalized direction vectors only.
  17745. */
  17746. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  17747. /**
  17748. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  17749. * This methods computes transformed normalized direction vectors only.
  17750. */
  17751. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  17752. }
  17753. interface ISize {
  17754. width: number;
  17755. height: number;
  17756. }
  17757. class Size implements ISize {
  17758. width: number;
  17759. height: number;
  17760. /**
  17761. * Creates a Size object from the given width and height (floats).
  17762. */
  17763. constructor(width: number, height: number);
  17764. toString(): string;
  17765. /**
  17766. * Returns the string "Size"
  17767. */
  17768. getClassName(): string;
  17769. /**
  17770. * Returns the Size hash code.
  17771. */
  17772. getHashCode(): number;
  17773. /**
  17774. * Updates the current size from the given one.
  17775. * Returns the updated Size.
  17776. */
  17777. copyFrom(src: Size): void;
  17778. /**
  17779. * Updates in place the current Size from the given floats.
  17780. * Returns the updated Size.
  17781. */
  17782. copyFromFloats(width: number, height: number): Size;
  17783. /**
  17784. * Updates in place the current Size from the given floats.
  17785. * Returns the updated Size.
  17786. */
  17787. set(width: number, height: number): Size;
  17788. /**
  17789. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  17790. */
  17791. multiplyByFloats(w: number, h: number): Size;
  17792. /**
  17793. * Returns a new Size copied from the given one.
  17794. */
  17795. clone(): Size;
  17796. /**
  17797. * Boolean : True if the current Size and the given one width and height are strictly equal.
  17798. */
  17799. equals(other: Size): boolean;
  17800. /**
  17801. * Returns the surface of the Size : width * height (float).
  17802. */
  17803. readonly surface: number;
  17804. /**
  17805. * Returns a new Size set to (0.0, 0.0)
  17806. */
  17807. static Zero(): Size;
  17808. /**
  17809. * Returns a new Size set as the addition result of the current Size and the given one.
  17810. */
  17811. add(otherSize: Size): Size;
  17812. /**
  17813. * Returns a new Size set as the subtraction result of the given one from the current Size.
  17814. */
  17815. subtract(otherSize: Size): Size;
  17816. /**
  17817. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  17818. */
  17819. static Lerp(start: Size, end: Size, amount: number): Size;
  17820. }
  17821. /**
  17822. * Class used to store quaternion data
  17823. * @see https://en.wikipedia.org/wiki/Quaternion
  17824. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  17825. */
  17826. class Quaternion {
  17827. /** defines the first component (0 by default) */
  17828. x: number;
  17829. /** defines the second component (0 by default) */
  17830. y: number;
  17831. /** defines the third component (0 by default) */
  17832. z: number;
  17833. /** defines the fourth component (1.0 by default) */
  17834. w: number;
  17835. /**
  17836. * Creates a new Quaternion from the given floats
  17837. * @param x defines the first component (0 by default)
  17838. * @param y defines the second component (0 by default)
  17839. * @param z defines the third component (0 by default)
  17840. * @param w defines the fourth component (1.0 by default)
  17841. */
  17842. constructor(
  17843. /** defines the first component (0 by default) */
  17844. x?: number,
  17845. /** defines the second component (0 by default) */
  17846. y?: number,
  17847. /** defines the third component (0 by default) */
  17848. z?: number,
  17849. /** defines the fourth component (1.0 by default) */
  17850. w?: number);
  17851. /**
  17852. * Gets a string representation for the current quaternion
  17853. * @returns a string with the Quaternion coordinates
  17854. */
  17855. toString(): string;
  17856. /**
  17857. * Gets the class name of the quaternion
  17858. * @returns the string "Quaternion"
  17859. */
  17860. getClassName(): string;
  17861. /**
  17862. * Gets a hash code for this quaternion
  17863. * @returns the quaternion hash code
  17864. */
  17865. getHashCode(): number;
  17866. /**
  17867. * Copy the quaternion to an array
  17868. * @returns a new array populated with 4 elements from the quaternion coordinates
  17869. */
  17870. asArray(): number[];
  17871. /**
  17872. * Check if two quaternions are equals
  17873. * @param otherQuaternion defines the second operand
  17874. * @return true if the current quaternion and the given one coordinates are strictly equals
  17875. */
  17876. equals(otherQuaternion: Quaternion): boolean;
  17877. /**
  17878. * Clone the current quaternion
  17879. * @returns a new quaternion copied from the current one
  17880. */
  17881. clone(): Quaternion;
  17882. /**
  17883. * Copy a quaternion to the current one
  17884. * @param other defines the other quaternion
  17885. * @returns the updated current quaternion
  17886. */
  17887. copyFrom(other: Quaternion): Quaternion;
  17888. /**
  17889. * Updates the current quaternion with the given float coordinates
  17890. * @param x defines the x coordinate
  17891. * @param y defines the y coordinate
  17892. * @param z defines the z coordinate
  17893. * @param w defines the w coordinate
  17894. * @returns the updated current quaternion
  17895. */
  17896. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  17897. /**
  17898. * Updates the current quaternion from the given float coordinates
  17899. * @param x defines the x coordinate
  17900. * @param y defines the y coordinate
  17901. * @param z defines the z coordinate
  17902. * @param w defines the w coordinate
  17903. * @returns the updated current quaternion
  17904. */
  17905. set(x: number, y: number, z: number, w: number): Quaternion;
  17906. /**
  17907. * Adds two quaternions
  17908. * @param other defines the second operand
  17909. * @returns a new quaternion as the addition result of the given one and the current quaternion
  17910. */
  17911. add(other: Quaternion): Quaternion;
  17912. /**
  17913. * Add a quaternion to the current one
  17914. * @param other defines the quaternion to add
  17915. * @returns the current quaternion
  17916. */
  17917. addInPlace(other: Quaternion): Quaternion;
  17918. /**
  17919. * Subtract two quaternions
  17920. * @param other defines the second operand
  17921. * @returns a new quaternion as the subtraction result of the given one from the current one
  17922. */
  17923. subtract(other: Quaternion): Quaternion;
  17924. /**
  17925. * Multiplies the current quaternion by a scale factor
  17926. * @param value defines the scale factor
  17927. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  17928. */
  17929. scale(value: number): Quaternion;
  17930. /**
  17931. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  17932. * @param scale defines the scale factor
  17933. * @param result defines the Quaternion object where to store the result
  17934. * @returns the unmodified current quaternion
  17935. */
  17936. scaleToRef(scale: number, result: Quaternion): Quaternion;
  17937. /**
  17938. * Multiplies in place the current quaternion by a scale factor
  17939. * @param value defines the scale factor
  17940. * @returns the current modified quaternion
  17941. */
  17942. scaleInPlace(value: number): Quaternion;
  17943. /**
  17944. * Scale the current quaternion values by a factor and add the result to a given quaternion
  17945. * @param scale defines the scale factor
  17946. * @param result defines the Quaternion object where to store the result
  17947. * @returns the unmodified current quaternion
  17948. */
  17949. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  17950. /**
  17951. * Multiplies two quaternions
  17952. * @param q1 defines the second operand
  17953. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  17954. */
  17955. multiply(q1: Quaternion): Quaternion;
  17956. /**
  17957. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  17958. * @param q1 defines the second operand
  17959. * @param result defines the target quaternion
  17960. * @returns the current quaternion
  17961. */
  17962. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  17963. /**
  17964. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  17965. * @param q1 defines the second operand
  17966. * @returns the currentupdated quaternion
  17967. */
  17968. multiplyInPlace(q1: Quaternion): Quaternion;
  17969. /**
  17970. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  17971. * @param ref defines the target quaternion
  17972. * @returns the current quaternion
  17973. */
  17974. conjugateToRef(ref: Quaternion): Quaternion;
  17975. /**
  17976. * Conjugates in place (1-q) the current quaternion
  17977. * @returns the current updated quaternion
  17978. */
  17979. conjugateInPlace(): Quaternion;
  17980. /**
  17981. * Conjugates in place (1-q) the current quaternion
  17982. * @returns a new quaternion
  17983. */
  17984. conjugate(): Quaternion;
  17985. /**
  17986. * Gets length of current quaternion
  17987. * @returns the quaternion length (float)
  17988. */
  17989. length(): number;
  17990. /**
  17991. * Normalize in place the current quaternion
  17992. * @returns the current updated quaternion
  17993. */
  17994. normalize(): Quaternion;
  17995. /**
  17996. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  17997. * @param order is a reserved parameter and is ignore for now
  17998. * @returns a new Vector3 containing the Euler angles
  17999. */
  18000. toEulerAngles(order?: string): Vector3;
  18001. /**
  18002. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  18003. * @param result defines the vector which will be filled with the Euler angles
  18004. * @param order is a reserved parameter and is ignore for now
  18005. * @returns the current unchanged quaternion
  18006. */
  18007. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  18008. /**
  18009. * Updates the given rotation matrix with the current quaternion values
  18010. * @param result defines the target matrix
  18011. * @returns the current unchanged quaternion
  18012. */
  18013. toRotationMatrix(result: Matrix): Quaternion;
  18014. /**
  18015. * Updates the current quaternion from the given rotation matrix values
  18016. * @param matrix defines the source matrix
  18017. * @returns the current updated quaternion
  18018. */
  18019. fromRotationMatrix(matrix: Matrix): Quaternion;
  18020. /**
  18021. * Creates a new quaternion from a rotation matrix
  18022. * @param matrix defines the source matrix
  18023. * @returns a new quaternion created from the given rotation matrix values
  18024. */
  18025. static FromRotationMatrix(matrix: Matrix): Quaternion;
  18026. /**
  18027. * Updates the given quaternion with the given rotation matrix values
  18028. * @param matrix defines the source matrix
  18029. * @param result defines the target quaternion
  18030. */
  18031. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  18032. /**
  18033. * Returns the dot product (float) between the quaternions "left" and "right"
  18034. * @param left defines the left operand
  18035. * @param right defines the right operand
  18036. * @returns the dot product
  18037. */
  18038. static Dot(left: Quaternion, right: Quaternion): number;
  18039. /**
  18040. * Checks if the two quaternions are close to each other
  18041. * @param quat0 defines the first quaternion to check
  18042. * @param quat1 defines the second quaternion to check
  18043. * @returns true if the two quaternions are close to each other
  18044. */
  18045. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  18046. /**
  18047. * Creates an empty quaternion
  18048. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  18049. */
  18050. static Zero(): Quaternion;
  18051. /**
  18052. * Inverse a given quaternion
  18053. * @param q defines the source quaternion
  18054. * @returns a new quaternion as the inverted current quaternion
  18055. */
  18056. static Inverse(q: Quaternion): Quaternion;
  18057. /**
  18058. * Creates an identity quaternion
  18059. * @returns the identity quaternion
  18060. */
  18061. static Identity(): Quaternion;
  18062. /**
  18063. * Gets a boolean indicating if the given quaternion is identity
  18064. * @param quaternion defines the quaternion to check
  18065. * @returns true if the quaternion is identity
  18066. */
  18067. static IsIdentity(quaternion: Quaternion): boolean;
  18068. /**
  18069. * Creates a quaternion from a rotation around an axis
  18070. * @param axis defines the axis to use
  18071. * @param angle defines the angle to use
  18072. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  18073. */
  18074. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  18075. /**
  18076. * Creates a rotation around an axis and stores it into the given quaternion
  18077. * @param axis defines the axis to use
  18078. * @param angle defines the angle to use
  18079. * @param result defines the target quaternion
  18080. * @returns the target quaternion
  18081. */
  18082. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  18083. /**
  18084. * Creates a new quaternion from data stored into an array
  18085. * @param array defines the data source
  18086. * @param offset defines the offset in the source array where the data starts
  18087. * @returns a new quaternion
  18088. */
  18089. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  18090. /**
  18091. * Creates a new quaternion from the given Euler float angles (y, x, z)
  18092. * @param yaw defines the rotation around Y axis
  18093. * @param pitch defines the rotation around X axis
  18094. * @param roll defines the rotation around Z axis
  18095. * @returns the new quaternion
  18096. */
  18097. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  18098. /**
  18099. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  18100. * @param yaw defines the rotation around Y axis
  18101. * @param pitch defines the rotation around X axis
  18102. * @param roll defines the rotation around Z axis
  18103. * @param result defines the target quaternion
  18104. */
  18105. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  18106. /**
  18107. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  18108. * @param alpha defines the rotation around first axis
  18109. * @param beta defines the rotation around second axis
  18110. * @param gamma defines the rotation around third axis
  18111. * @returns the new quaternion
  18112. */
  18113. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  18114. /**
  18115. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  18116. * @param alpha defines the rotation around first axis
  18117. * @param beta defines the rotation around second axis
  18118. * @param gamma defines the rotation around third axis
  18119. * @param result defines the target quaternion
  18120. */
  18121. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  18122. /**
  18123. * 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)
  18124. * @param axis1 defines the first axis
  18125. * @param axis2 defines the second axis
  18126. * @param axis3 defines the third axis
  18127. * @returns the new quaternion
  18128. */
  18129. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  18130. /**
  18131. * 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
  18132. * @param axis1 defines the first axis
  18133. * @param axis2 defines the second axis
  18134. * @param axis3 defines the third axis
  18135. * @param ref defines the target quaternion
  18136. */
  18137. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  18138. /**
  18139. * Interpolates between two quaternions
  18140. * @param left defines first quaternion
  18141. * @param right defines second quaternion
  18142. * @param amount defines the gradient to use
  18143. * @returns the new interpolated quaternion
  18144. */
  18145. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  18146. /**
  18147. * Interpolates between two quaternions and stores it into a target quaternion
  18148. * @param left defines first quaternion
  18149. * @param right defines second quaternion
  18150. * @param amount defines the gradient to use
  18151. * @param result defines the target quaternion
  18152. */
  18153. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  18154. /**
  18155. * Interpolate between two quaternions using Hermite interpolation
  18156. * @param value1 defines first quaternion
  18157. * @param tangent1 defines the incoming tangent
  18158. * @param value2 defines second quaternion
  18159. * @param tangent2 defines the outgoing tangent
  18160. * @param amount defines the target quaternion
  18161. * @returns the new interpolated quaternion
  18162. */
  18163. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  18164. }
  18165. /**
  18166. * Class used to store matrix data (4x4)
  18167. */
  18168. class Matrix {
  18169. private static _tempQuaternion;
  18170. private static _xAxis;
  18171. private static _yAxis;
  18172. private static _zAxis;
  18173. private static _updateFlagSeed;
  18174. private static _identityReadOnly;
  18175. private _isIdentity;
  18176. private _isIdentityDirty;
  18177. /**
  18178. * Gets the update flag of the matrix which is an unique number for the matrix.
  18179. * It will be incremented every time the matrix data change.
  18180. * You can use it to speed the comparison between two versions of the same matrix.
  18181. */
  18182. updateFlag: number;
  18183. /**
  18184. * Gets or sets the internal data of the matrix
  18185. */
  18186. m: Float32Array;
  18187. /** @hidden */
  18188. _markAsUpdated(): void;
  18189. /**
  18190. * Creates an empty matrix (filled with zeros)
  18191. */
  18192. constructor();
  18193. /**
  18194. * Check if the current matrix is indentity
  18195. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  18196. * @returns true is the matrix is the identity matrix
  18197. */
  18198. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  18199. /**
  18200. * Gets the determinant of the matrix
  18201. * @returns the matrix determinant
  18202. */
  18203. determinant(): number;
  18204. /**
  18205. * Returns the matrix as a Float32Array
  18206. * @returns the matrix underlying array
  18207. */
  18208. toArray(): Float32Array;
  18209. /**
  18210. * Returns the matrix as a Float32Array
  18211. * @returns the matrix underlying array.
  18212. */
  18213. asArray(): Float32Array;
  18214. /**
  18215. * Inverts the current matrix in place
  18216. * @returns the current inverted matrix
  18217. */
  18218. invert(): Matrix;
  18219. /**
  18220. * Sets all the matrix elements to zero
  18221. * @returns the current matrix
  18222. */
  18223. reset(): Matrix;
  18224. /**
  18225. * Adds the current matrix with a second one
  18226. * @param other defines the matrix to add
  18227. * @returns a new matrix as the addition of the current matrix and the given one
  18228. */
  18229. add(other: Matrix): Matrix;
  18230. /**
  18231. * Sets the given matrix "result" to the addition of the current matrix and the given one
  18232. * @param other defines the matrix to add
  18233. * @param result defines the target matrix
  18234. * @returns the current matrix
  18235. */
  18236. addToRef(other: Matrix, result: Matrix): Matrix;
  18237. /**
  18238. * Adds in place the given matrix to the current matrix
  18239. * @param other defines the second operand
  18240. * @returns the current updated matrix
  18241. */
  18242. addToSelf(other: Matrix): Matrix;
  18243. /**
  18244. * Sets the given matrix to the current inverted Matrix
  18245. * @param other defines the target matrix
  18246. * @returns the unmodified current matrix
  18247. */
  18248. invertToRef(other: Matrix): Matrix;
  18249. /**
  18250. * Inserts the translation vector (using 3 floats) in the current matrix
  18251. * @param x defines the 1st component of the translation
  18252. * @param y defines the 2nd component of the translation
  18253. * @param z defines the 3rd component of the translation
  18254. * @returns the current updated matrix
  18255. */
  18256. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  18257. /**
  18258. * Inserts the translation vector in the current matrix
  18259. * @param vector3 defines the translation to insert
  18260. * @returns the current updated matrix
  18261. */
  18262. setTranslation(vector3: Vector3): Matrix;
  18263. /**
  18264. * Gets the translation value of the current matrix
  18265. * @returns a new Vector3 as the extracted translation from the matrix
  18266. */
  18267. getTranslation(): Vector3;
  18268. /**
  18269. * Fill a Vector3 with the extracted translation from the matrix
  18270. * @param result defines the Vector3 where to store the translation
  18271. * @returns the current matrix
  18272. */
  18273. getTranslationToRef(result: Vector3): Matrix;
  18274. /**
  18275. * Remove rotation and scaling part from the matrix
  18276. * @returns the updated matrix
  18277. */
  18278. removeRotationAndScaling(): Matrix;
  18279. /**
  18280. * Multiply two matrices
  18281. * @param other defines the second operand
  18282. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  18283. */
  18284. multiply(other: Matrix): Matrix;
  18285. /**
  18286. * Copy the current matrix from the given one
  18287. * @param other defines the source matrix
  18288. * @returns the current updated matrix
  18289. */
  18290. copyFrom(other: Matrix): Matrix;
  18291. /**
  18292. * Populates the given array from the starting index with the current matrix values
  18293. * @param array defines the target array
  18294. * @param offset defines the offset in the target array where to start storing values
  18295. * @returns the current matrix
  18296. */
  18297. copyToArray(array: Float32Array, offset?: number): Matrix;
  18298. /**
  18299. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  18300. * @param other defines the second operand
  18301. * @param result defines the matrix where to store the multiplication
  18302. * @returns the current matrix
  18303. */
  18304. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  18305. /**
  18306. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  18307. * @param other defines the second operand
  18308. * @param result defines the array where to store the multiplication
  18309. * @param offset defines the offset in the target array where to start storing values
  18310. * @returns the current matrix
  18311. */
  18312. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  18313. /**
  18314. * Check equality between this matrix and a second one
  18315. * @param value defines the second matrix to compare
  18316. * @returns true is the current matrix and the given one values are strictly equal
  18317. */
  18318. equals(value: Matrix): boolean;
  18319. /**
  18320. * Clone the current matrix
  18321. * @returns a new matrix from the current matrix
  18322. */
  18323. clone(): Matrix;
  18324. /**
  18325. * Returns the name of the current matrix class
  18326. * @returns the string "Matrix"
  18327. */
  18328. getClassName(): string;
  18329. /**
  18330. * Gets the hash code of the current matrix
  18331. * @returns the hash code
  18332. */
  18333. getHashCode(): number;
  18334. /**
  18335. * Decomposes the current Matrix into a translation, rotation and scaling components
  18336. * @param scale defines the scale vector3 given as a reference to update
  18337. * @param rotation defines the rotation quaternion given as a reference to update
  18338. * @param translation defines the translation vector3 given as a reference to update
  18339. * @returns true if operation was successful
  18340. */
  18341. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  18342. /**
  18343. * Gets specific row of the matrix
  18344. * @param index defines the number of the row to get
  18345. * @returns the index-th row of the current matrix as a new Vector4
  18346. */
  18347. getRow(index: number): Nullable<Vector4>;
  18348. /**
  18349. * Sets the index-th row of the current matrix to the vector4 values
  18350. * @param index defines the number of the row to set
  18351. * @param row defines the target vector4
  18352. * @returns the updated current matrix
  18353. */
  18354. setRow(index: number, row: Vector4): Matrix;
  18355. /**
  18356. * Compute the transpose of the matrix
  18357. * @returns the new transposed matrix
  18358. */
  18359. transpose(): Matrix;
  18360. /**
  18361. * Compute the transpose of the matrix and store it in a given matrix
  18362. * @param result defines the target matrix
  18363. * @returns the current matrix
  18364. */
  18365. transposeToRef(result: Matrix): Matrix;
  18366. /**
  18367. * Sets the index-th row of the current matrix with the given 4 x float values
  18368. * @param index defines the row index
  18369. * @param x defines the x component to set
  18370. * @param y defines the y component to set
  18371. * @param z defines the z component to set
  18372. * @param w defines the w component to set
  18373. * @returns the updated current matrix
  18374. */
  18375. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  18376. /**
  18377. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  18378. * @param scale defines the scale factor
  18379. * @returns a new matrix
  18380. */
  18381. scale(scale: number): Matrix;
  18382. /**
  18383. * Scale the current matrix values by a factor to a given result matrix
  18384. * @param scale defines the scale factor
  18385. * @param result defines the matrix to store the result
  18386. * @returns the current matrix
  18387. */
  18388. scaleToRef(scale: number, result: Matrix): Matrix;
  18389. /**
  18390. * Scale the current matrix values by a factor and add the result to a given matrix
  18391. * @param scale defines the scale factor
  18392. * @param result defines the Matrix to store the result
  18393. * @returns the current matrix
  18394. */
  18395. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  18396. /**
  18397. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  18398. * @param ref matrix to store the result
  18399. */
  18400. toNormalMatrix(ref: Matrix): void;
  18401. /**
  18402. * Gets only rotation part of the current matrix
  18403. * @returns a new matrix sets to the extracted rotation matrix from the current one
  18404. */
  18405. getRotationMatrix(): Matrix;
  18406. /**
  18407. * Extracts the rotation matrix from the current one and sets it as the given "result"
  18408. * @param result defines the target matrix to store data to
  18409. * @returns the current matrix
  18410. */
  18411. getRotationMatrixToRef(result: Matrix): Matrix;
  18412. /**
  18413. * Creates a matrix from an array
  18414. * @param array defines the source array
  18415. * @param offset defines an offset in the source array
  18416. * @returns a new Matrix set from the starting index of the given array
  18417. */
  18418. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  18419. /**
  18420. * Copy the content of an array into a given matrix
  18421. * @param array defines the source array
  18422. * @param offset defines an offset in the source array
  18423. * @param result defines the target matrix
  18424. */
  18425. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  18426. /**
  18427. * Stores an array into a matrix after having multiplied each component by a given factor
  18428. * @param array defines the source array
  18429. * @param offset defines the offset in the source array
  18430. * @param scale defines the scaling factor
  18431. * @param result defines the target matrix
  18432. */
  18433. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  18434. /**
  18435. * Stores a list of values (16) inside a given matrix
  18436. * @param initialM11 defines 1st value of 1st row
  18437. * @param initialM12 defines 2nd value of 1st row
  18438. * @param initialM13 defines 3rd value of 1st row
  18439. * @param initialM14 defines 4th value of 1st row
  18440. * @param initialM21 defines 1st value of 2nd row
  18441. * @param initialM22 defines 2nd value of 2nd row
  18442. * @param initialM23 defines 3rd value of 2nd row
  18443. * @param initialM24 defines 4th value of 2nd row
  18444. * @param initialM31 defines 1st value of 3rd row
  18445. * @param initialM32 defines 2nd value of 3rd row
  18446. * @param initialM33 defines 3rd value of 3rd row
  18447. * @param initialM34 defines 4th value of 3rd row
  18448. * @param initialM41 defines 1st value of 4th row
  18449. * @param initialM42 defines 2nd value of 4th row
  18450. * @param initialM43 defines 3rd value of 4th row
  18451. * @param initialM44 defines 4th value of 4th row
  18452. * @param result defines the target matrix
  18453. */
  18454. 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;
  18455. /**
  18456. * Gets an identity matrix that must not be updated
  18457. */
  18458. static readonly IdentityReadOnly: Matrix;
  18459. /**
  18460. * Creates new matrix from a list of values (16)
  18461. * @param initialM11 defines 1st value of 1st row
  18462. * @param initialM12 defines 2nd value of 1st row
  18463. * @param initialM13 defines 3rd value of 1st row
  18464. * @param initialM14 defines 4th value of 1st row
  18465. * @param initialM21 defines 1st value of 2nd row
  18466. * @param initialM22 defines 2nd value of 2nd row
  18467. * @param initialM23 defines 3rd value of 2nd row
  18468. * @param initialM24 defines 4th value of 2nd row
  18469. * @param initialM31 defines 1st value of 3rd row
  18470. * @param initialM32 defines 2nd value of 3rd row
  18471. * @param initialM33 defines 3rd value of 3rd row
  18472. * @param initialM34 defines 4th value of 3rd row
  18473. * @param initialM41 defines 1st value of 4th row
  18474. * @param initialM42 defines 2nd value of 4th row
  18475. * @param initialM43 defines 3rd value of 4th row
  18476. * @param initialM44 defines 4th value of 4th row
  18477. * @returns the new matrix
  18478. */
  18479. 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;
  18480. /**
  18481. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  18482. * @param scale defines the scale vector3
  18483. * @param rotation defines the rotation quaternion
  18484. * @param translation defines the translation vector3
  18485. * @returns a new matrix
  18486. */
  18487. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  18488. /**
  18489. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  18490. * @param scale defines the scale vector3
  18491. * @param rotation defines the rotation quaternion
  18492. * @param translation defines the translation vector3
  18493. * @param result defines the target matrix
  18494. */
  18495. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  18496. /**
  18497. * Creates a new identity matrix
  18498. * @returns a new identity matrix
  18499. */
  18500. static Identity(): Matrix;
  18501. /**
  18502. * Creates a new identity matrix and stores the result in a given matrix
  18503. * @param result defines the target matrix
  18504. */
  18505. static IdentityToRef(result: Matrix): void;
  18506. /**
  18507. * Creates a new zero matrix
  18508. * @returns a new zero matrix
  18509. */
  18510. static Zero(): Matrix;
  18511. /**
  18512. * Creates a new rotation matrix for "angle" radians around the X axis
  18513. * @param angle defines the angle (in radians) to use
  18514. * @return the new matrix
  18515. */
  18516. static RotationX(angle: number): Matrix;
  18517. /**
  18518. * Creates a new matrix as the invert of a given matrix
  18519. * @param source defines the source matrix
  18520. * @returns the new matrix
  18521. */
  18522. static Invert(source: Matrix): Matrix;
  18523. /**
  18524. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  18525. * @param angle defines the angle (in radians) to use
  18526. * @param result defines the target matrix
  18527. */
  18528. static RotationXToRef(angle: number, result: Matrix): void;
  18529. /**
  18530. * Creates a new rotation matrix for "angle" radians around the Y axis
  18531. * @param angle defines the angle (in radians) to use
  18532. * @return the new matrix
  18533. */
  18534. static RotationY(angle: number): Matrix;
  18535. /**
  18536. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  18537. * @param angle defines the angle (in radians) to use
  18538. * @param result defines the target matrix
  18539. */
  18540. static RotationYToRef(angle: number, result: Matrix): void;
  18541. /**
  18542. * Creates a new rotation matrix for "angle" radians around the Z axis
  18543. * @param angle defines the angle (in radians) to use
  18544. * @return the new matrix
  18545. */
  18546. static RotationZ(angle: number): Matrix;
  18547. /**
  18548. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  18549. * @param angle defines the angle (in radians) to use
  18550. * @param result defines the target matrix
  18551. */
  18552. static RotationZToRef(angle: number, result: Matrix): void;
  18553. /**
  18554. * Creates a new rotation matrix for "angle" radians around the given axis
  18555. * @param axis defines the axis to use
  18556. * @param angle defines the angle (in radians) to use
  18557. * @return the new matrix
  18558. */
  18559. static RotationAxis(axis: Vector3, angle: number): Matrix;
  18560. /**
  18561. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  18562. * @param axis defines the axis to use
  18563. * @param angle defines the angle (in radians) to use
  18564. * @param result defines the target matrix
  18565. */
  18566. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  18567. /**
  18568. * Creates a rotation matrix
  18569. * @param yaw defines the yaw angle in radians (Y axis)
  18570. * @param pitch defines the pitch angle in radians (X axis)
  18571. * @param roll defines the roll angle in radians (X axis)
  18572. * @returns the new rotation matrix
  18573. */
  18574. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  18575. /**
  18576. * Creates a rotation matrix and stores it in a given matrix
  18577. * @param yaw defines the yaw angle in radians (Y axis)
  18578. * @param pitch defines the pitch angle in radians (X axis)
  18579. * @param roll defines the roll angle in radians (X axis)
  18580. * @param result defines the target matrix
  18581. */
  18582. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  18583. /**
  18584. * Creates a scaling matrix
  18585. * @param x defines the scale factor on X axis
  18586. * @param y defines the scale factor on Y axis
  18587. * @param z defines the scale factor on Z axis
  18588. * @returns the new matrix
  18589. */
  18590. static Scaling(x: number, y: number, z: number): Matrix;
  18591. /**
  18592. * Creates a scaling matrix and stores it in a given matrix
  18593. * @param x defines the scale factor on X axis
  18594. * @param y defines the scale factor on Y axis
  18595. * @param z defines the scale factor on Z axis
  18596. * @param result defines the target matrix
  18597. */
  18598. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  18599. /**
  18600. * Creates a translation matrix
  18601. * @param x defines the translation on X axis
  18602. * @param y defines the translation on Y axis
  18603. * @param z defines the translationon Z axis
  18604. * @returns the new matrix
  18605. */
  18606. static Translation(x: number, y: number, z: number): Matrix;
  18607. /**
  18608. * Creates a translation matrix and stores it in a given matrix
  18609. * @param x defines the translation on X axis
  18610. * @param y defines the translation on Y axis
  18611. * @param z defines the translationon Z axis
  18612. * @param result defines the target matrix
  18613. */
  18614. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  18615. /**
  18616. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  18617. * @param startValue defines the start value
  18618. * @param endValue defines the end value
  18619. * @param gradient defines the gradient factor
  18620. * @returns the new matrix
  18621. */
  18622. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  18623. /**
  18624. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  18625. * @param startValue defines the start value
  18626. * @param endValue defines the end value
  18627. * @param gradient defines the gradient factor
  18628. * @param result defines the Matrix object where to store data
  18629. */
  18630. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  18631. /**
  18632. * Builds a new matrix whose values are computed by:
  18633. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  18634. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  18635. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  18636. * @param startValue defines the first matrix
  18637. * @param endValue defines the second matrix
  18638. * @param gradient defines the gradient between the two matrices
  18639. * @returns the new matrix
  18640. */
  18641. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  18642. /**
  18643. * Update a matrix to values which are computed by:
  18644. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  18645. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  18646. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  18647. * @param startValue defines the first matrix
  18648. * @param endValue defines the second matrix
  18649. * @param gradient defines the gradient between the two matrices
  18650. * @param result defines the target matrix
  18651. */
  18652. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  18653. /**
  18654. * 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"
  18655. * This function works in left handed mode
  18656. * @param eye defines the final position of the entity
  18657. * @param target defines where the entity should look at
  18658. * @param up defines the up vector for the entity
  18659. * @returns the new matrix
  18660. */
  18661. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  18662. /**
  18663. * 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".
  18664. * This function works in left handed mode
  18665. * @param eye defines the final position of the entity
  18666. * @param target defines where the entity should look at
  18667. * @param up defines the up vector for the entity
  18668. * @param result defines the target matrix
  18669. */
  18670. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  18671. /**
  18672. * 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"
  18673. * This function works in right handed mode
  18674. * @param eye defines the final position of the entity
  18675. * @param target defines where the entity should look at
  18676. * @param up defines the up vector for the entity
  18677. * @returns the new matrix
  18678. */
  18679. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  18680. /**
  18681. * 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".
  18682. * This function works in right handed mode
  18683. * @param eye defines the final position of the entity
  18684. * @param target defines where the entity should look at
  18685. * @param up defines the up vector for the entity
  18686. * @param result defines the target matrix
  18687. */
  18688. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  18689. /**
  18690. * Create a left-handed orthographic projection matrix
  18691. * @param width defines the viewport width
  18692. * @param height defines the viewport height
  18693. * @param znear defines the near clip plane
  18694. * @param zfar defines the far clip plane
  18695. * @returns a new matrix as a left-handed orthographic projection matrix
  18696. */
  18697. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18698. /**
  18699. * Store a left-handed orthographic projection to a given matrix
  18700. * @param width defines the viewport width
  18701. * @param height defines the viewport height
  18702. * @param znear defines the near clip plane
  18703. * @param zfar defines the far clip plane
  18704. * @param result defines the target matrix
  18705. */
  18706. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  18707. /**
  18708. * Create a left-handed orthographic projection matrix
  18709. * @param left defines the viewport left coordinate
  18710. * @param right defines the viewport right coordinate
  18711. * @param bottom defines the viewport bottom coordinate
  18712. * @param top defines the viewport top coordinate
  18713. * @param znear defines the near clip plane
  18714. * @param zfar defines the far clip plane
  18715. * @returns a new matrix as a left-handed orthographic projection matrix
  18716. */
  18717. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  18718. /**
  18719. * Stores a left-handed orthographic projection into a given matrix
  18720. * @param left defines the viewport left coordinate
  18721. * @param right defines the viewport right coordinate
  18722. * @param bottom defines the viewport bottom coordinate
  18723. * @param top defines the viewport top coordinate
  18724. * @param znear defines the near clip plane
  18725. * @param zfar defines the far clip plane
  18726. * @param result defines the target matrix
  18727. */
  18728. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18729. /**
  18730. * Creates a right-handed orthographic projection matrix
  18731. * @param left defines the viewport left coordinate
  18732. * @param right defines the viewport right coordinate
  18733. * @param bottom defines the viewport bottom coordinate
  18734. * @param top defines the viewport top coordinate
  18735. * @param znear defines the near clip plane
  18736. * @param zfar defines the far clip plane
  18737. * @returns a new matrix as a right-handed orthographic projection matrix
  18738. */
  18739. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  18740. /**
  18741. * Stores a right-handed orthographic projection into a given matrix
  18742. * @param left defines the viewport left coordinate
  18743. * @param right defines the viewport right coordinate
  18744. * @param bottom defines the viewport bottom coordinate
  18745. * @param top defines the viewport top coordinate
  18746. * @param znear defines the near clip plane
  18747. * @param zfar defines the far clip plane
  18748. * @param result defines the target matrix
  18749. */
  18750. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18751. /**
  18752. * Creates a left-handed perspective projection matrix
  18753. * @param width defines the viewport width
  18754. * @param height defines the viewport height
  18755. * @param znear defines the near clip plane
  18756. * @param zfar defines the far clip plane
  18757. * @returns a new matrix as a left-handed perspective projection matrix
  18758. */
  18759. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18760. /**
  18761. * Creates a left-handed perspective projection matrix
  18762. * @param fov defines the horizontal field of view
  18763. * @param aspect defines the aspect ratio
  18764. * @param znear defines the near clip plane
  18765. * @param zfar defines the far clip plane
  18766. * @returns a new matrix as a left-handed perspective projection matrix
  18767. */
  18768. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18769. /**
  18770. * Stores a left-handed perspective projection into a given matrix
  18771. * @param fov defines the horizontal field of view
  18772. * @param aspect defines the aspect ratio
  18773. * @param znear defines the near clip plane
  18774. * @param zfar defines the far clip plane
  18775. * @param result defines the target matrix
  18776. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18777. */
  18778. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18779. /**
  18780. * Creates a right-handed perspective projection matrix
  18781. * @param fov defines the horizontal field of view
  18782. * @param aspect defines the aspect ratio
  18783. * @param znear defines the near clip plane
  18784. * @param zfar defines the far clip plane
  18785. * @returns a new matrix as a right-handed perspective projection matrix
  18786. */
  18787. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18788. /**
  18789. * Stores a right-handed perspective projection into a given matrix
  18790. * @param fov defines the horizontal field of view
  18791. * @param aspect defines the aspect ratio
  18792. * @param znear defines the near clip plane
  18793. * @param zfar defines the far clip plane
  18794. * @param result defines the target matrix
  18795. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18796. */
  18797. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18798. /**
  18799. * Stores a perspective projection for WebVR info a given matrix
  18800. * @param fov defines the field of view
  18801. * @param znear defines the near clip plane
  18802. * @param zfar defines the far clip plane
  18803. * @param result defines the target matrix
  18804. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  18805. */
  18806. static PerspectiveFovWebVRToRef(fov: {
  18807. upDegrees: number;
  18808. downDegrees: number;
  18809. leftDegrees: number;
  18810. rightDegrees: number;
  18811. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  18812. /**
  18813. * Computes a complete transformation matrix
  18814. * @param viewport defines the viewport to use
  18815. * @param world defines the world matrix
  18816. * @param view defines the view matrix
  18817. * @param projection defines the projection matrix
  18818. * @param zmin defines the near clip plane
  18819. * @param zmax defines the far clip plane
  18820. * @returns the transformation matrix
  18821. */
  18822. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  18823. /**
  18824. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  18825. * @param matrix defines the matrix to use
  18826. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  18827. */
  18828. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  18829. /**
  18830. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  18831. * @param matrix defines the matrix to use
  18832. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  18833. */
  18834. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  18835. /**
  18836. * Compute the transpose of a given matrix
  18837. * @param matrix defines the matrix to transpose
  18838. * @returns the new matrix
  18839. */
  18840. static Transpose(matrix: Matrix): Matrix;
  18841. /**
  18842. * Compute the transpose of a matrix and store it in a target matrix
  18843. * @param matrix defines the matrix to transpose
  18844. * @param result defines the target matrix
  18845. */
  18846. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  18847. /**
  18848. * Computes a reflection matrix from a plane
  18849. * @param plane defines the reflection plane
  18850. * @returns a new matrix
  18851. */
  18852. static Reflection(plane: Plane): Matrix;
  18853. /**
  18854. * Computes a reflection matrix from a plane
  18855. * @param plane defines the reflection plane
  18856. * @param result defines the target matrix
  18857. */
  18858. static ReflectionToRef(plane: Plane, result: Matrix): void;
  18859. /**
  18860. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  18861. * @param xaxis defines the value of the 1st axis
  18862. * @param yaxis defines the value of the 2nd axis
  18863. * @param zaxis defines the value of the 3rd axis
  18864. * @param result defines the target matrix
  18865. */
  18866. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  18867. /**
  18868. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  18869. * @param quat defines the quaternion to use
  18870. * @param result defines the target matrix
  18871. */
  18872. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  18873. }
  18874. class Plane {
  18875. normal: Vector3;
  18876. d: number;
  18877. /**
  18878. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  18879. */
  18880. constructor(a: number, b: number, c: number, d: number);
  18881. /**
  18882. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  18883. */
  18884. asArray(): number[];
  18885. /**
  18886. * Returns a new plane copied from the current Plane.
  18887. */
  18888. clone(): Plane;
  18889. /**
  18890. * Returns the string "Plane".
  18891. */
  18892. getClassName(): string;
  18893. /**
  18894. * Returns the Plane hash code.
  18895. */
  18896. getHashCode(): number;
  18897. /**
  18898. * Normalize the current Plane in place.
  18899. * Returns the updated Plane.
  18900. */
  18901. normalize(): Plane;
  18902. /**
  18903. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  18904. */
  18905. transform(transformation: Matrix): Plane;
  18906. /**
  18907. * Returns the dot product (float) of the point coordinates and the plane normal.
  18908. */
  18909. dotCoordinate(point: Vector3): number;
  18910. /**
  18911. * Updates the current Plane from the plane defined by the three given points.
  18912. * Returns the updated Plane.
  18913. */
  18914. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18915. /**
  18916. * Boolean : True is the vector "direction" is the same side than the plane normal.
  18917. */
  18918. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  18919. /**
  18920. * Returns the signed distance (float) from the given point to the Plane.
  18921. */
  18922. signedDistanceTo(point: Vector3): number;
  18923. /**
  18924. * Returns a new Plane from the given array.
  18925. */
  18926. static FromArray(array: ArrayLike<number>): Plane;
  18927. /**
  18928. * Returns a new Plane defined by the three given points.
  18929. */
  18930. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18931. /**
  18932. * Returns a new Plane the normal vector to this plane at the given origin point.
  18933. * Note : the vector "normal" is updated because normalized.
  18934. */
  18935. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  18936. /**
  18937. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  18938. */
  18939. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  18940. }
  18941. class Viewport {
  18942. x: number;
  18943. y: number;
  18944. width: number;
  18945. height: number;
  18946. /**
  18947. * Creates a Viewport object located at (x, y) and sized (width, height).
  18948. */
  18949. constructor(x: number, y: number, width: number, height: number);
  18950. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  18951. /**
  18952. * Returns a new Viewport copied from the current one.
  18953. */
  18954. clone(): Viewport;
  18955. }
  18956. class Frustum {
  18957. /**
  18958. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  18959. */
  18960. static GetPlanes(transform: Matrix): Plane[];
  18961. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18962. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18963. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18964. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18965. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18966. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18967. /**
  18968. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  18969. */
  18970. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  18971. }
  18972. /** Defines supported spaces */
  18973. enum Space {
  18974. /** Local (object) space */
  18975. LOCAL = 0,
  18976. /** World space */
  18977. WORLD = 1,
  18978. /** Bone space */
  18979. BONE = 2
  18980. }
  18981. /** Defines the 3 main axes */
  18982. class Axis {
  18983. /** X axis */
  18984. static X: Vector3;
  18985. /** Y axis */
  18986. static Y: Vector3;
  18987. /** Z axis */
  18988. static Z: Vector3;
  18989. }
  18990. class BezierCurve {
  18991. /**
  18992. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  18993. */
  18994. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  18995. }
  18996. /**
  18997. * Defines potential orientation for back face culling
  18998. */
  18999. enum Orientation {
  19000. /**
  19001. * Clockwise
  19002. */
  19003. CW = 0,
  19004. /** Counter clockwise */
  19005. CCW = 1
  19006. }
  19007. /**
  19008. * Defines angle representation
  19009. */
  19010. class Angle {
  19011. private _radians;
  19012. /**
  19013. * Creates an Angle object of "radians" radians (float).
  19014. */
  19015. constructor(radians: number);
  19016. /**
  19017. * Get value in degrees
  19018. * @returns the Angle value in degrees (float)
  19019. */
  19020. degrees(): number;
  19021. /**
  19022. * Get value in radians
  19023. * @returns the Angle value in radians (float)
  19024. */
  19025. radians(): number;
  19026. /**
  19027. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  19028. * @param a defines first vector
  19029. * @param b defines second vector
  19030. * @returns a new Angle
  19031. */
  19032. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  19033. /**
  19034. * Gets a new Angle object from the given float in radians
  19035. * @param radians defines the angle value in radians
  19036. * @returns a new Angle
  19037. */
  19038. static FromRadians(radians: number): Angle;
  19039. /**
  19040. * Gets a new Angle object from the given float in degrees
  19041. * @param degrees defines the angle value in degrees
  19042. * @returns a new Angle
  19043. */
  19044. static FromDegrees(degrees: number): Angle;
  19045. }
  19046. class Arc2 {
  19047. startPoint: Vector2;
  19048. midPoint: Vector2;
  19049. endPoint: Vector2;
  19050. centerPoint: Vector2;
  19051. radius: number;
  19052. angle: Angle;
  19053. startAngle: Angle;
  19054. orientation: Orientation;
  19055. /**
  19056. * Creates an Arc object from the three given points : start, middle and end.
  19057. */
  19058. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  19059. }
  19060. class Path2 {
  19061. private _points;
  19062. private _length;
  19063. closed: boolean;
  19064. /**
  19065. * Creates a Path2 object from the starting 2D coordinates x and y.
  19066. */
  19067. constructor(x: number, y: number);
  19068. /**
  19069. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  19070. * Returns the updated Path2.
  19071. */
  19072. addLineTo(x: number, y: number): Path2;
  19073. /**
  19074. * 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.
  19075. * Returns the updated Path2.
  19076. */
  19077. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  19078. /**
  19079. * Closes the Path2.
  19080. * Returns the Path2.
  19081. */
  19082. close(): Path2;
  19083. /**
  19084. * Returns the Path2 total length (float).
  19085. */
  19086. length(): number;
  19087. /**
  19088. * Returns the Path2 internal array of points.
  19089. */
  19090. getPoints(): Vector2[];
  19091. /**
  19092. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  19093. */
  19094. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  19095. /**
  19096. * Returns a new Path2 starting at the coordinates (x, y).
  19097. */
  19098. static StartingAt(x: number, y: number): Path2;
  19099. }
  19100. class Path3D {
  19101. path: Vector3[];
  19102. private _curve;
  19103. private _distances;
  19104. private _tangents;
  19105. private _normals;
  19106. private _binormals;
  19107. private _raw;
  19108. /**
  19109. * new Path3D(path, normal, raw)
  19110. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  19111. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  19112. * path : an array of Vector3, the curve axis of the Path3D
  19113. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  19114. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  19115. */
  19116. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  19117. /**
  19118. * Returns the Path3D array of successive Vector3 designing its curve.
  19119. */
  19120. getCurve(): Vector3[];
  19121. /**
  19122. * Returns an array populated with tangent vectors on each Path3D curve point.
  19123. */
  19124. getTangents(): Vector3[];
  19125. /**
  19126. * Returns an array populated with normal vectors on each Path3D curve point.
  19127. */
  19128. getNormals(): Vector3[];
  19129. /**
  19130. * Returns an array populated with binormal vectors on each Path3D curve point.
  19131. */
  19132. getBinormals(): Vector3[];
  19133. /**
  19134. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  19135. */
  19136. getDistances(): number[];
  19137. /**
  19138. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  19139. * Returns the same object updated.
  19140. */
  19141. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  19142. private _compute;
  19143. private _getFirstNonNullVector;
  19144. private _getLastNonNullVector;
  19145. private _normalVector;
  19146. }
  19147. class Curve3 {
  19148. private _points;
  19149. private _length;
  19150. /**
  19151. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  19152. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  19153. * @param v1 (Vector3) the control point
  19154. * @param v2 (Vector3) the end point of the Quadratic Bezier
  19155. * @param nbPoints (integer) the wanted number of points in the curve
  19156. */
  19157. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  19158. /**
  19159. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  19160. * @param v0 (Vector3) the origin point of the Cubic Bezier
  19161. * @param v1 (Vector3) the first control point
  19162. * @param v2 (Vector3) the second control point
  19163. * @param v3 (Vector3) the end point of the Cubic Bezier
  19164. * @param nbPoints (integer) the wanted number of points in the curve
  19165. */
  19166. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  19167. /**
  19168. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  19169. * @param p1 (Vector3) the origin point of the Hermite Spline
  19170. * @param t1 (Vector3) the tangent vector at the origin point
  19171. * @param p2 (Vector3) the end point of the Hermite Spline
  19172. * @param t2 (Vector3) the tangent vector at the end point
  19173. * @param nbPoints (integer) the wanted number of points in the curve
  19174. */
  19175. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  19176. /**
  19177. * Returns a Curve3 object along a CatmullRom Spline curve :
  19178. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  19179. * @param nbPoints (integer) the wanted number of points between each curve control points
  19180. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  19181. */
  19182. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  19183. /**
  19184. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  19185. * A Curve3 is designed from a series of successive Vector3.
  19186. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  19187. */
  19188. constructor(points: Vector3[]);
  19189. /**
  19190. * Returns the Curve3 stored array of successive Vector3
  19191. */
  19192. getPoints(): Vector3[];
  19193. /**
  19194. * Returns the computed length (float) of the curve.
  19195. */
  19196. length(): number;
  19197. /**
  19198. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  19199. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  19200. * curveA and curveB keep unchanged.
  19201. */
  19202. continue(curve: Curve3): Curve3;
  19203. private _computeLength;
  19204. }
  19205. class PositionNormalVertex {
  19206. position: Vector3;
  19207. normal: Vector3;
  19208. constructor(position?: Vector3, normal?: Vector3);
  19209. clone(): PositionNormalVertex;
  19210. }
  19211. class PositionNormalTextureVertex {
  19212. position: Vector3;
  19213. normal: Vector3;
  19214. uv: Vector2;
  19215. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  19216. clone(): PositionNormalTextureVertex;
  19217. }
  19218. class Tmp {
  19219. static Color3: Color3[];
  19220. static Color4: Color4[];
  19221. static Vector2: Vector2[];
  19222. static Vector3: Vector3[];
  19223. static Vector4: Vector4[];
  19224. static Quaternion: Quaternion[];
  19225. static Matrix: Matrix[];
  19226. }
  19227. }
  19228. declare module BABYLON {
  19229. /**
  19230. * Class representing spherical polynomial coefficients to the 3rd degree
  19231. */
  19232. class SphericalPolynomial {
  19233. /**
  19234. * The x coefficients of the spherical polynomial
  19235. */
  19236. x: Vector3;
  19237. /**
  19238. * The y coefficients of the spherical polynomial
  19239. */
  19240. y: Vector3;
  19241. /**
  19242. * The z coefficients of the spherical polynomial
  19243. */
  19244. z: Vector3;
  19245. /**
  19246. * The xx coefficients of the spherical polynomial
  19247. */
  19248. xx: Vector3;
  19249. /**
  19250. * The yy coefficients of the spherical polynomial
  19251. */
  19252. yy: Vector3;
  19253. /**
  19254. * The zz coefficients of the spherical polynomial
  19255. */
  19256. zz: Vector3;
  19257. /**
  19258. * The xy coefficients of the spherical polynomial
  19259. */
  19260. xy: Vector3;
  19261. /**
  19262. * The yz coefficients of the spherical polynomial
  19263. */
  19264. yz: Vector3;
  19265. /**
  19266. * The zx coefficients of the spherical polynomial
  19267. */
  19268. zx: Vector3;
  19269. /**
  19270. * Adds an ambient color to the spherical polynomial
  19271. * @param color the color to add
  19272. */
  19273. addAmbient(color: Color3): void;
  19274. /**
  19275. * Scales the spherical polynomial by the given amount
  19276. * @param scale the amount to scale
  19277. */
  19278. scale(scale: number): void;
  19279. /**
  19280. * Gets the spherical polynomial from harmonics
  19281. * @param harmonics the spherical harmonics
  19282. * @returns the spherical polynomial
  19283. */
  19284. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  19285. /**
  19286. * Constructs a spherical polynomial from an array.
  19287. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  19288. * @returns the spherical polynomial
  19289. */
  19290. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  19291. }
  19292. /**
  19293. * Class representing spherical harmonics coefficients to the 3rd degree
  19294. */
  19295. class SphericalHarmonics {
  19296. /**
  19297. * The l0,0 coefficients of the spherical harmonics
  19298. */
  19299. l00: Vector3;
  19300. /**
  19301. * The l1,-1 coefficients of the spherical harmonics
  19302. */
  19303. l1_1: Vector3;
  19304. /**
  19305. * The l1,0 coefficients of the spherical harmonics
  19306. */
  19307. l10: Vector3;
  19308. /**
  19309. * The l1,1 coefficients of the spherical harmonics
  19310. */
  19311. l11: Vector3;
  19312. /**
  19313. * The l2,-2 coefficients of the spherical harmonics
  19314. */
  19315. l2_2: Vector3;
  19316. /**
  19317. * The l2,-1 coefficients of the spherical harmonics
  19318. */
  19319. l2_1: Vector3;
  19320. /**
  19321. * The l2,0 coefficients of the spherical harmonics
  19322. */
  19323. l20: Vector3;
  19324. /**
  19325. * The l2,1 coefficients of the spherical harmonics
  19326. */
  19327. l21: Vector3;
  19328. /**
  19329. * The l2,2 coefficients of the spherical harmonics
  19330. */
  19331. lL22: Vector3;
  19332. /**
  19333. * Adds a light to the spherical harmonics
  19334. * @param direction the direction of the light
  19335. * @param color the color of the light
  19336. * @param deltaSolidAngle the delta solid angle of the light
  19337. */
  19338. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  19339. /**
  19340. * Scales the spherical harmonics by the given amount
  19341. * @param scale the amount to scale
  19342. */
  19343. scale(scale: number): void;
  19344. /**
  19345. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  19346. *
  19347. * ```
  19348. * E_lm = A_l * L_lm
  19349. * ```
  19350. *
  19351. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  19352. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  19353. * the scaling factors are given in equation 9.
  19354. */
  19355. convertIncidentRadianceToIrradiance(): void;
  19356. /**
  19357. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  19358. *
  19359. * ```
  19360. * L = (1/pi) * E * rho
  19361. * ```
  19362. *
  19363. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  19364. */
  19365. convertIrradianceToLambertianRadiance(): void;
  19366. /**
  19367. * Gets the spherical harmonics from polynomial
  19368. * @param polynomial the spherical polynomial
  19369. * @returns the spherical harmonics
  19370. */
  19371. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  19372. /**
  19373. * Constructs a spherical harmonics from an array.
  19374. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  19375. * @returns the spherical harmonics
  19376. */
  19377. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  19378. }
  19379. }
  19380. declare module BABYLON {
  19381. /**
  19382. * Class used to store all common mesh properties
  19383. */
  19384. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  19385. /** No occlusion */
  19386. static OCCLUSION_TYPE_NONE: number;
  19387. /** Occlusion set to optimisitic */
  19388. static OCCLUSION_TYPE_OPTIMISTIC: number;
  19389. /** Occlusion set to strict */
  19390. static OCCLUSION_TYPE_STRICT: number;
  19391. /** Use an accurante occlusion algorithm */
  19392. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  19393. /** Use a conservative occlusion algorithm */
  19394. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  19395. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  19396. static readonly CULLINGSTRATEGY_STANDARD: number;
  19397. /** Culling strategy with bounding sphere only and then frustum culling */
  19398. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  19399. /**
  19400. * No billboard
  19401. */
  19402. static readonly BILLBOARDMODE_NONE: number;
  19403. /** Billboard on X axis */
  19404. static readonly BILLBOARDMODE_X: number;
  19405. /** Billboard on Y axis */
  19406. static readonly BILLBOARDMODE_Y: number;
  19407. /** Billboard on Z axis */
  19408. static readonly BILLBOARDMODE_Z: number;
  19409. /** Billboard on all axes */
  19410. static readonly BILLBOARDMODE_ALL: number;
  19411. private _facetPositions;
  19412. private _facetNormals;
  19413. private _facetPartitioning;
  19414. private _facetNb;
  19415. private _partitioningSubdivisions;
  19416. private _partitioningBBoxRatio;
  19417. private _facetDataEnabled;
  19418. private _facetParameters;
  19419. private _bbSize;
  19420. private _subDiv;
  19421. private _facetDepthSort;
  19422. private _facetDepthSortEnabled;
  19423. private _depthSortedIndices;
  19424. private _depthSortedFacets;
  19425. private _facetDepthSortFunction;
  19426. private _facetDepthSortFrom;
  19427. private _facetDepthSortOrigin;
  19428. private _invertedMatrix;
  19429. /** Gets ot sets the culling strategy to use to find visible meshes */
  19430. cullingStrategy: number;
  19431. /**
  19432. * Gets the number of facets in the mesh
  19433. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19434. */
  19435. readonly facetNb: number;
  19436. /**
  19437. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  19438. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19439. */
  19440. partitioningSubdivisions: number;
  19441. /**
  19442. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  19443. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  19444. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  19445. */
  19446. partitioningBBoxRatio: number;
  19447. /**
  19448. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  19449. * Works only for updatable meshes.
  19450. * Doesn't work with multi-materials
  19451. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19452. */
  19453. mustDepthSortFacets: boolean;
  19454. /**
  19455. * The location (Vector3) where the facet depth sort must be computed from.
  19456. * By default, the active camera position.
  19457. * Used only when facet depth sort is enabled
  19458. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  19459. */
  19460. facetDepthSortFrom: Vector3;
  19461. /**
  19462. * gets a boolean indicating if facetData is enabled
  19463. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  19464. */
  19465. readonly isFacetDataEnabled: boolean;
  19466. /** @hidden */
  19467. _updateNonUniformScalingState(value: boolean): boolean;
  19468. /**
  19469. * An event triggered when this mesh collides with another one
  19470. */
  19471. onCollideObservable: Observable<AbstractMesh>;
  19472. private _onCollideObserver;
  19473. /** Set a function to call when this mesh collides with another one */
  19474. onCollide: () => void;
  19475. /**
  19476. * An event triggered when the collision's position changes
  19477. */
  19478. onCollisionPositionChangeObservable: Observable<Vector3>;
  19479. private _onCollisionPositionChangeObserver;
  19480. /** Set a function to call when the collision's position changes */
  19481. onCollisionPositionChange: () => void;
  19482. /**
  19483. * An event triggered when material is changed
  19484. */
  19485. onMaterialChangedObservable: Observable<AbstractMesh>;
  19486. /**
  19487. * Gets or sets the orientation for POV movement & rotation
  19488. */
  19489. definedFacingForward: boolean;
  19490. /**
  19491. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  19492. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  19493. * * 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.
  19494. * @see http://doc.babylonjs.com/features/occlusionquery
  19495. */
  19496. occlusionQueryAlgorithmType: number;
  19497. /**
  19498. * 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:
  19499. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  19500. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  19501. * * 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.
  19502. * @see http://doc.babylonjs.com/features/occlusionquery
  19503. */
  19504. occlusionType: number;
  19505. /**
  19506. * 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.
  19507. * The default value is -1 which means don't break the query and wait till the result
  19508. * @see http://doc.babylonjs.com/features/occlusionquery
  19509. */
  19510. occlusionRetryCount: number;
  19511. /** @hidden */
  19512. _occlusionInternalRetryCounter: number;
  19513. /** @hidden */
  19514. _isOccluded: boolean;
  19515. /**
  19516. * 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
  19517. * @see http://doc.babylonjs.com/features/occlusionquery
  19518. */
  19519. isOccluded: boolean;
  19520. /** @hidden */
  19521. _isOcclusionQueryInProgress: boolean;
  19522. /**
  19523. * Flag to check the progress status of the query
  19524. * @see http://doc.babylonjs.com/features/occlusionquery
  19525. */
  19526. readonly isOcclusionQueryInProgress: boolean;
  19527. /** @hidden */
  19528. _occlusionQuery: Nullable<WebGLQuery>;
  19529. private _visibility;
  19530. /**
  19531. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19532. */
  19533. /**
  19534. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  19535. */
  19536. visibility: number;
  19537. /** Gets or sets the alpha index used to sort transparent meshes
  19538. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  19539. */
  19540. alphaIndex: number;
  19541. /**
  19542. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  19543. */
  19544. isVisible: boolean;
  19545. /**
  19546. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  19547. */
  19548. isPickable: boolean;
  19549. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  19550. showSubMeshesBoundingBox: boolean;
  19551. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  19552. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  19553. */
  19554. isBlocker: boolean;
  19555. /**
  19556. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  19557. */
  19558. enablePointerMoveEvents: boolean;
  19559. /**
  19560. * Specifies the rendering group id for this mesh (0 by default)
  19561. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  19562. */
  19563. renderingGroupId: number;
  19564. private _material;
  19565. /** Gets or sets current material */
  19566. material: Nullable<Material>;
  19567. private _receiveShadows;
  19568. /**
  19569. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  19570. * @see http://doc.babylonjs.com/babylon101/shadows
  19571. */
  19572. receiveShadows: boolean;
  19573. /** Defines color to use when rendering outline */
  19574. outlineColor: Color3;
  19575. /** Define width to use when rendering outline */
  19576. outlineWidth: number;
  19577. /** Defines color to use when rendering overlay */
  19578. overlayColor: Color3;
  19579. /** Defines alpha to use when rendering overlay */
  19580. overlayAlpha: number;
  19581. private _hasVertexAlpha;
  19582. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  19583. hasVertexAlpha: boolean;
  19584. private _useVertexColors;
  19585. /** 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) */
  19586. useVertexColors: boolean;
  19587. private _computeBonesUsingShaders;
  19588. /**
  19589. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  19590. */
  19591. computeBonesUsingShaders: boolean;
  19592. private _numBoneInfluencers;
  19593. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  19594. numBoneInfluencers: number;
  19595. private _applyFog;
  19596. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  19597. applyFog: boolean;
  19598. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  19599. useOctreeForRenderingSelection: boolean;
  19600. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  19601. useOctreeForPicking: boolean;
  19602. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  19603. useOctreeForCollisions: boolean;
  19604. private _layerMask;
  19605. /**
  19606. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  19607. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  19608. */
  19609. layerMask: number;
  19610. /**
  19611. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  19612. */
  19613. alwaysSelectAsActiveMesh: boolean;
  19614. /**
  19615. * Gets or sets the current action manager
  19616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  19617. */
  19618. actionManager: Nullable<ActionManager>;
  19619. /**
  19620. * Gets or sets impostor used for physic simulation
  19621. * @see http://doc.babylonjs.com/features/physics_engine
  19622. */
  19623. physicsImpostor: Nullable<PhysicsImpostor>;
  19624. private _checkCollisions;
  19625. private _collisionMask;
  19626. private _collisionGroup;
  19627. /**
  19628. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  19629. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19630. */
  19631. ellipsoid: Vector3;
  19632. /**
  19633. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  19634. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19635. */
  19636. ellipsoidOffset: Vector3;
  19637. private _collider;
  19638. private _oldPositionForCollisions;
  19639. private _diffPositionForCollisions;
  19640. /**
  19641. * Gets or sets a collision mask used to mask collisions (default is -1).
  19642. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19643. */
  19644. collisionMask: number;
  19645. /**
  19646. * Gets or sets the current collision group mask (-1 by default).
  19647. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19648. */
  19649. collisionGroup: number;
  19650. /**
  19651. * Defines edge width used when edgesRenderer is enabled
  19652. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19653. */
  19654. edgesWidth: number;
  19655. /**
  19656. * Defines edge color used when edgesRenderer is enabled
  19657. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19658. */
  19659. edgesColor: Color4;
  19660. /** @hidden */
  19661. _edgesRenderer: Nullable<IEdgesRenderer>;
  19662. private _collisionsTransformMatrix;
  19663. private _collisionsScalingMatrix;
  19664. /** @hidden */
  19665. _masterMesh: Nullable<AbstractMesh>;
  19666. /** @hidden */
  19667. _boundingInfo: Nullable<BoundingInfo>;
  19668. /** @hidden */
  19669. _renderId: number;
  19670. /**
  19671. * Gets or sets the list of subMeshes
  19672. * @see http://doc.babylonjs.com/how_to/multi_materials
  19673. */
  19674. subMeshes: SubMesh[];
  19675. /** @hidden */
  19676. _intersectionsInProgress: AbstractMesh[];
  19677. /** @hidden */
  19678. _unIndexed: boolean;
  19679. /** @hidden */
  19680. _lightSources: Light[];
  19681. /** @hidden */
  19682. readonly _positions: Nullable<Vector3[]>;
  19683. /** @hidden */
  19684. _waitingActions: any;
  19685. /** @hidden */
  19686. _waitingFreezeWorldMatrix: Nullable<boolean>;
  19687. private _skeleton;
  19688. /** @hidden */
  19689. _bonesTransformMatrices: Nullable<Float32Array>;
  19690. /**
  19691. * Gets or sets a skeleton to apply skining transformations
  19692. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19693. */
  19694. skeleton: Nullable<Skeleton>;
  19695. /**
  19696. * An event triggered when the mesh is rebuilt.
  19697. */
  19698. onRebuildObservable: Observable<AbstractMesh>;
  19699. /**
  19700. * Creates a new AbstractMesh
  19701. * @param name defines the name of the mesh
  19702. * @param scene defines the hosting scene
  19703. */
  19704. constructor(name: string, scene?: Nullable<Scene>);
  19705. /**
  19706. * Returns the string "AbstractMesh"
  19707. * @returns "AbstractMesh"
  19708. */
  19709. getClassName(): string;
  19710. /**
  19711. * Gets a string representation of the current mesh
  19712. * @param fullDetails defines a boolean indicating if full details must be included
  19713. * @returns a string representation of the current mesh
  19714. */
  19715. toString(fullDetails?: boolean): string;
  19716. /** @hidden */
  19717. _rebuild(): void;
  19718. /** @hidden */
  19719. _resyncLightSources(): void;
  19720. /** @hidden */
  19721. _resyncLighSource(light: Light): void;
  19722. /** @hidden */
  19723. _unBindEffect(): void;
  19724. /** @hidden */
  19725. _removeLightSource(light: Light): void;
  19726. private _markSubMeshesAsDirty;
  19727. /** @hidden */
  19728. _markSubMeshesAsLightDirty(): void;
  19729. /** @hidden */
  19730. _markSubMeshesAsAttributesDirty(): void;
  19731. /** @hidden */
  19732. _markSubMeshesAsMiscDirty(): void;
  19733. /**
  19734. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  19735. */
  19736. scaling: Vector3;
  19737. /**
  19738. * Returns true if the mesh is blocked. Implemented by child classes
  19739. */
  19740. readonly isBlocked: boolean;
  19741. /**
  19742. * Returns the mesh itself by default. Implemented by child classes
  19743. * @param camera defines the camera to use to pick the right LOD level
  19744. * @returns the currentAbstractMesh
  19745. */
  19746. getLOD(camera: Camera): Nullable<AbstractMesh>;
  19747. /**
  19748. * Returns 0 by default. Implemented by child classes
  19749. * @returns an integer
  19750. */
  19751. getTotalVertices(): number;
  19752. /**
  19753. * Returns null by default. Implemented by child classes
  19754. * @returns null
  19755. */
  19756. getIndices(): Nullable<IndicesArray>;
  19757. /**
  19758. * Returns the array of the requested vertex data kind. Implemented by child classes
  19759. * @param kind defines the vertex data kind to use
  19760. * @returns null
  19761. */
  19762. getVerticesData(kind: string): Nullable<FloatArray>;
  19763. /**
  19764. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19765. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19766. * Note that a new underlying VertexBuffer object is created each call.
  19767. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19768. * @param kind defines vertex data kind:
  19769. * * BABYLON.VertexBuffer.PositionKind
  19770. * * BABYLON.VertexBuffer.UVKind
  19771. * * BABYLON.VertexBuffer.UV2Kind
  19772. * * BABYLON.VertexBuffer.UV3Kind
  19773. * * BABYLON.VertexBuffer.UV4Kind
  19774. * * BABYLON.VertexBuffer.UV5Kind
  19775. * * BABYLON.VertexBuffer.UV6Kind
  19776. * * BABYLON.VertexBuffer.ColorKind
  19777. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19778. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19779. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19780. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19781. * @param data defines the data source
  19782. * @param updatable defines if the data must be flagged as updatable (or static)
  19783. * @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
  19784. * @returns the current mesh
  19785. */
  19786. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19787. /**
  19788. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19789. * If the mesh has no geometry, it is simply returned as it is.
  19790. * @param kind defines vertex data kind:
  19791. * * BABYLON.VertexBuffer.PositionKind
  19792. * * BABYLON.VertexBuffer.UVKind
  19793. * * BABYLON.VertexBuffer.UV2Kind
  19794. * * BABYLON.VertexBuffer.UV3Kind
  19795. * * BABYLON.VertexBuffer.UV4Kind
  19796. * * BABYLON.VertexBuffer.UV5Kind
  19797. * * BABYLON.VertexBuffer.UV6Kind
  19798. * * BABYLON.VertexBuffer.ColorKind
  19799. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19800. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19801. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19802. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19803. * @param data defines the data source
  19804. * @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
  19805. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  19806. * @returns the current mesh
  19807. */
  19808. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  19809. /**
  19810. * Sets the mesh indices,
  19811. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19812. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  19813. * @param totalVertices Defines the total number of vertices
  19814. * @returns the current mesh
  19815. */
  19816. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  19817. /**
  19818. * Gets a boolean indicating if specific vertex data is present
  19819. * @param kind defines the vertex data kind to use
  19820. * @returns true is data kind is present
  19821. */
  19822. isVerticesDataPresent(kind: string): boolean;
  19823. /**
  19824. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  19825. * @returns a BoundingInfo
  19826. */
  19827. getBoundingInfo(): BoundingInfo;
  19828. /**
  19829. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  19830. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  19831. * @returns the current mesh
  19832. */
  19833. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  19834. /**
  19835. * Overwrite the current bounding info
  19836. * @param boundingInfo defines the new bounding info
  19837. * @returns the current mesh
  19838. */
  19839. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  19840. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  19841. readonly useBones: boolean;
  19842. /** @hidden */
  19843. _preActivate(): void;
  19844. /** @hidden */
  19845. _preActivateForIntermediateRendering(renderId: number): void;
  19846. /** @hidden */
  19847. _activate(renderId: number): void;
  19848. /**
  19849. * Gets the current world matrix
  19850. * @returns a Matrix
  19851. */
  19852. getWorldMatrix(): Matrix;
  19853. /** @hidden */
  19854. _getWorldMatrixDeterminant(): number;
  19855. /**
  19856. * Perform relative position change from the point of view of behind the front of the mesh.
  19857. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19858. * Supports definition of mesh facing forward or backward
  19859. * @param amountRight defines the distance on the right axis
  19860. * @param amountUp defines the distance on the up axis
  19861. * @param amountForward defines the distance on the forward axis
  19862. * @returns the current mesh
  19863. */
  19864. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  19865. /**
  19866. * Calculate relative position change from the point of view of behind the front of the mesh.
  19867. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19868. * Supports definition of mesh facing forward or backward
  19869. * @param amountRight defines the distance on the right axis
  19870. * @param amountUp defines the distance on the up axis
  19871. * @param amountForward defines the distance on the forward axis
  19872. * @returns the new displacement vector
  19873. */
  19874. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  19875. /**
  19876. * Perform relative rotation change from the point of view of behind the front of the mesh.
  19877. * Supports definition of mesh facing forward or backward
  19878. * @param flipBack defines the flip
  19879. * @param twirlClockwise defines the twirl
  19880. * @param tiltRight defines the tilt
  19881. * @returns the current mesh
  19882. */
  19883. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  19884. /**
  19885. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  19886. * Supports definition of mesh facing forward or backward.
  19887. * @param flipBack defines the flip
  19888. * @param twirlClockwise defines the twirl
  19889. * @param tiltRight defines the tilt
  19890. * @returns the new rotation vector
  19891. */
  19892. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  19893. /**
  19894. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  19895. * @param includeDescendants Include bounding info from descendants as well (true by default)
  19896. * @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
  19897. * @returns the new bounding vectors
  19898. */
  19899. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  19900. min: Vector3;
  19901. max: Vector3;
  19902. };
  19903. /** @hidden */
  19904. _updateBoundingInfo(): AbstractMesh;
  19905. /** @hidden */
  19906. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  19907. /** @hidden */
  19908. protected _afterComputeWorldMatrix(): void;
  19909. /**
  19910. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19911. * A mesh is in the frustum if its bounding box intersects the frustum
  19912. * @param frustumPlanes defines the frustum to test
  19913. * @returns true if the mesh is in the frustum planes
  19914. */
  19915. isInFrustum(frustumPlanes: Plane[]): boolean;
  19916. /**
  19917. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  19918. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  19919. * @param frustumPlanes defines the frustum to test
  19920. * @returns true if the mesh is completely in the frustum planes
  19921. */
  19922. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  19923. /**
  19924. * True if the mesh intersects another mesh or a SolidParticle object
  19925. * @param mesh defines a target mesh or SolidParticle to test
  19926. * @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)
  19927. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  19928. * @returns true if there is an intersection
  19929. */
  19930. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  19931. /**
  19932. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  19933. * @param point defines the point to test
  19934. * @returns true if there is an intersection
  19935. */
  19936. intersectsPoint(point: Vector3): boolean;
  19937. /**
  19938. * Gets the current physics impostor
  19939. * @see http://doc.babylonjs.com/features/physics_engine
  19940. * @returns a physics impostor or null
  19941. */
  19942. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  19943. /**
  19944. * Gets the position of the current mesh in camera space
  19945. * @param camera defines the camera to use
  19946. * @returns a position
  19947. */
  19948. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  19949. /**
  19950. * Returns the distance from the mesh to the active camera
  19951. * @param camera defines the camera to use
  19952. * @returns the distance
  19953. */
  19954. getDistanceToCamera(camera?: Nullable<Camera>): number;
  19955. /**
  19956. * Apply a physic impulse to the mesh
  19957. * @param force defines the force to apply
  19958. * @param contactPoint defines where to apply the force
  19959. * @returns the current mesh
  19960. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19961. */
  19962. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  19963. /**
  19964. * Creates a physic joint between two meshes
  19965. * @param otherMesh defines the other mesh to use
  19966. * @param pivot1 defines the pivot to use on this mesh
  19967. * @param pivot2 defines the pivot to use on the other mesh
  19968. * @param options defines additional options (can be plugin dependent)
  19969. * @returns the current mesh
  19970. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  19971. */
  19972. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  19973. /**
  19974. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  19975. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19976. */
  19977. checkCollisions: boolean;
  19978. /**
  19979. * Gets Collider object used to compute collisions (not physics)
  19980. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19981. */
  19982. readonly collider: Collider;
  19983. /**
  19984. * Move the mesh using collision engine
  19985. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19986. * @param displacement defines the requested displacement vector
  19987. * @returns the current mesh
  19988. */
  19989. moveWithCollisions(displacement: Vector3): AbstractMesh;
  19990. private _onCollisionPositionChange;
  19991. /** @hidden */
  19992. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  19993. /** @hidden */
  19994. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  19995. /** @hidden */
  19996. _checkCollision(collider: Collider): AbstractMesh;
  19997. /** @hidden */
  19998. _generatePointsArray(): boolean;
  19999. /**
  20000. * Checks if the passed Ray intersects with the mesh
  20001. * @param ray defines the ray to use
  20002. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  20003. * @returns the picking info
  20004. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  20005. */
  20006. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  20007. /**
  20008. * Clones the current mesh
  20009. * @param name defines the mesh name
  20010. * @param newParent defines the new mesh parent
  20011. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  20012. * @returns the new mesh
  20013. */
  20014. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20015. /**
  20016. * Disposes all the submeshes of the current meshnp
  20017. * @returns the current mesh
  20018. */
  20019. releaseSubMeshes(): AbstractMesh;
  20020. /**
  20021. * Releases resources associated with this abstract mesh.
  20022. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20023. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20024. */
  20025. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20026. /**
  20027. * Adds the passed mesh as a child to the current mesh
  20028. * @param mesh defines the child mesh
  20029. * @returns the current mesh
  20030. */
  20031. addChild(mesh: AbstractMesh): AbstractMesh;
  20032. /**
  20033. * Removes the passed mesh from the current mesh children list
  20034. * @param mesh defines the child mesh
  20035. * @returns the current mesh
  20036. */
  20037. removeChild(mesh: AbstractMesh): AbstractMesh;
  20038. /** @hidden */
  20039. private _initFacetData;
  20040. /**
  20041. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  20042. * This method can be called within the render loop.
  20043. * 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
  20044. * @returns the current mesh
  20045. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20046. */
  20047. updateFacetData(): AbstractMesh;
  20048. /**
  20049. * Returns the facetLocalNormals array.
  20050. * The normals are expressed in the mesh local spac
  20051. * @returns an array of Vector3
  20052. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20053. */
  20054. getFacetLocalNormals(): Vector3[];
  20055. /**
  20056. * Returns the facetLocalPositions array.
  20057. * The facet positions are expressed in the mesh local space
  20058. * @returns an array of Vector3
  20059. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20060. */
  20061. getFacetLocalPositions(): Vector3[];
  20062. /**
  20063. * Returns the facetLocalPartioning array
  20064. * @returns an array of array of numbers
  20065. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20066. */
  20067. getFacetLocalPartitioning(): number[][];
  20068. /**
  20069. * Returns the i-th facet position in the world system.
  20070. * This method allocates a new Vector3 per call
  20071. * @param i defines the facet index
  20072. * @returns a new Vector3
  20073. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20074. */
  20075. getFacetPosition(i: number): Vector3;
  20076. /**
  20077. * Sets the reference Vector3 with the i-th facet position in the world system
  20078. * @param i defines the facet index
  20079. * @param ref defines the target vector
  20080. * @returns the current mesh
  20081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20082. */
  20083. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  20084. /**
  20085. * Returns the i-th facet normal in the world system.
  20086. * This method allocates a new Vector3 per call
  20087. * @param i defines the facet index
  20088. * @returns a new Vector3
  20089. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20090. */
  20091. getFacetNormal(i: number): Vector3;
  20092. /**
  20093. * Sets the reference Vector3 with the i-th facet normal in the world system
  20094. * @param i defines the facet index
  20095. * @param ref defines the target vector
  20096. * @returns the current mesh
  20097. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20098. */
  20099. getFacetNormalToRef(i: number, ref: Vector3): this;
  20100. /**
  20101. * 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)
  20102. * @param x defines x coordinate
  20103. * @param y defines y coordinate
  20104. * @param z defines z coordinate
  20105. * @returns the array of facet indexes
  20106. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20107. */
  20108. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  20109. /**
  20110. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  20111. * @param projected sets as the (x,y,z) world projection on the facet
  20112. * @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
  20113. * @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
  20114. * @param x defines x coordinate
  20115. * @param y defines y coordinate
  20116. * @param z defines z coordinate
  20117. * @returns the face index if found (or null instead)
  20118. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20119. */
  20120. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20121. /**
  20122. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  20123. * @param projected sets as the (x,y,z) local projection on the facet
  20124. * @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
  20125. * @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
  20126. * @param x defines x coordinate
  20127. * @param y defines y coordinate
  20128. * @param z defines z coordinate
  20129. * @returns the face index if found (or null instead)
  20130. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20131. */
  20132. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  20133. /**
  20134. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  20135. * @returns the parameters
  20136. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20137. */
  20138. getFacetDataParameters(): any;
  20139. /**
  20140. * Disables the feature FacetData and frees the related memory
  20141. * @returns the current mesh
  20142. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  20143. */
  20144. disableFacetData(): AbstractMesh;
  20145. /**
  20146. * Updates the AbstractMesh indices array
  20147. * @param indices defines the data source
  20148. * @returns the current mesh
  20149. */
  20150. updateIndices(indices: IndicesArray): AbstractMesh;
  20151. /**
  20152. * Creates new normals data for the mesh
  20153. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  20154. * @returns the current mesh
  20155. */
  20156. createNormals(updatable: boolean): AbstractMesh;
  20157. /**
  20158. * Align the mesh with a normal
  20159. * @param normal defines the normal to use
  20160. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  20161. * @returns the current mesh
  20162. */
  20163. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  20164. /** @hidden */
  20165. _checkOcclusionQuery(): void;
  20166. }
  20167. }
  20168. declare module BABYLON {
  20169. class Buffer {
  20170. private _engine;
  20171. private _buffer;
  20172. /** @hidden */
  20173. _data: Nullable<DataArray>;
  20174. private _updatable;
  20175. private _instanced;
  20176. /**
  20177. * Gets the byte stride.
  20178. */
  20179. readonly byteStride: number;
  20180. /**
  20181. * Constructor
  20182. * @param engine the engine
  20183. * @param data the data to use for this buffer
  20184. * @param updatable whether the data is updatable
  20185. * @param stride the stride (optional)
  20186. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  20187. * @param instanced whether the buffer is instanced (optional)
  20188. * @param useBytes set to true if the stride in in bytes (optional)
  20189. */
  20190. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  20191. /**
  20192. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  20193. * @param kind defines the vertex buffer kind (position, normal, etc.)
  20194. * @param offset defines offset in the buffer (0 by default)
  20195. * @param size defines the size in floats of attributes (position is 3 for instance)
  20196. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  20197. * @param instanced defines if the vertex buffer contains indexed data
  20198. * @param useBytes defines if the offset and stride are in bytes
  20199. * @returns the new vertex buffer
  20200. */
  20201. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  20202. isUpdatable(): boolean;
  20203. getData(): Nullable<DataArray>;
  20204. getBuffer(): Nullable<WebGLBuffer>;
  20205. /**
  20206. * Gets the stride in float32 units (i.e. byte stride / 4).
  20207. * May not be an integer if the byte stride is not divisible by 4.
  20208. * DEPRECATED. Use byteStride instead.
  20209. * @returns the stride in float32 units
  20210. */
  20211. getStrideSize(): number;
  20212. create(data?: Nullable<DataArray>): void;
  20213. /** @hidden */
  20214. _rebuild(): void;
  20215. update(data: DataArray): void;
  20216. /**
  20217. * Updates the data directly.
  20218. * @param data the new data
  20219. * @param offset the new offset
  20220. * @param vertexCount the vertex count (optional)
  20221. * @param useBytes set to true if the offset is in bytes
  20222. */
  20223. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  20224. dispose(): void;
  20225. }
  20226. }
  20227. declare module BABYLON {
  20228. class CSG {
  20229. private polygons;
  20230. matrix: Matrix;
  20231. position: Vector3;
  20232. rotation: Vector3;
  20233. rotationQuaternion: Nullable<Quaternion>;
  20234. scaling: Vector3;
  20235. static FromMesh(mesh: Mesh): CSG;
  20236. private static FromPolygons;
  20237. clone(): CSG;
  20238. union(csg: CSG): CSG;
  20239. unionInPlace(csg: CSG): void;
  20240. subtract(csg: CSG): CSG;
  20241. subtractInPlace(csg: CSG): void;
  20242. intersect(csg: CSG): CSG;
  20243. intersectInPlace(csg: CSG): void;
  20244. inverse(): CSG;
  20245. inverseInPlace(): void;
  20246. copyTransformAttributes(csg: CSG): CSG;
  20247. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  20248. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  20249. }
  20250. }
  20251. declare module BABYLON {
  20252. /**
  20253. * Class used to store geometry data (vertex buffers + index buffer)
  20254. */
  20255. class Geometry implements IGetSetVerticesData {
  20256. /**
  20257. * Gets or sets the unique ID of the geometry
  20258. */
  20259. id: string;
  20260. /**
  20261. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20262. */
  20263. delayLoadState: number;
  20264. /**
  20265. * Gets the file containing the data to load when running in delay load state
  20266. */
  20267. delayLoadingFile: Nullable<string>;
  20268. /**
  20269. * Callback called when the geometry is updated
  20270. */
  20271. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20272. private _scene;
  20273. private _engine;
  20274. private _meshes;
  20275. private _totalVertices;
  20276. /** @hidden */
  20277. _indices: IndicesArray;
  20278. /** @hidden */
  20279. _vertexBuffers: {
  20280. [key: string]: VertexBuffer;
  20281. };
  20282. private _isDisposed;
  20283. private _extend;
  20284. private _boundingBias;
  20285. /** @hidden */
  20286. _delayInfo: Array<string>;
  20287. private _indexBuffer;
  20288. private _indexBufferIsUpdatable;
  20289. /** @hidden */
  20290. _boundingInfo: Nullable<BoundingInfo>;
  20291. /** @hidden */
  20292. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20293. /** @hidden */
  20294. _softwareSkinningFrameId: number;
  20295. private _vertexArrayObjects;
  20296. private _updatable;
  20297. /** @hidden */
  20298. _positions: Nullable<Vector3[]>;
  20299. /**
  20300. * 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
  20301. */
  20302. /**
  20303. * 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
  20304. */
  20305. boundingBias: Vector2;
  20306. /**
  20307. * Static function used to attach a new empty geometry to a mesh
  20308. * @param mesh defines the mesh to attach the geometry to
  20309. * @returns the new {BABYLON.Geometry}
  20310. */
  20311. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20312. /**
  20313. * Creates a new geometry
  20314. * @param id defines the unique ID
  20315. * @param scene defines the hosting scene
  20316. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  20317. * @param updatable defines if geometry must be updatable (false by default)
  20318. * @param mesh defines the mesh that will be associated with the geometry
  20319. */
  20320. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20321. /**
  20322. * Gets the current extend of the geometry
  20323. */
  20324. readonly extend: {
  20325. minimum: Vector3;
  20326. maximum: Vector3;
  20327. };
  20328. /**
  20329. * Gets the hosting scene
  20330. * @returns the hosting {BABYLON.Scene}
  20331. */
  20332. getScene(): Scene;
  20333. /**
  20334. * Gets the hosting engine
  20335. * @returns the hosting {BABYLON.Engine}
  20336. */
  20337. getEngine(): Engine;
  20338. /**
  20339. * Defines if the geometry is ready to use
  20340. * @returns true if the geometry is ready to be used
  20341. */
  20342. isReady(): boolean;
  20343. /**
  20344. * Gets a value indicating that the geometry should not be serialized
  20345. */
  20346. readonly doNotSerialize: boolean;
  20347. /** @hidden */
  20348. _rebuild(): void;
  20349. /**
  20350. * Affects all geometry data in one call
  20351. * @param vertexData defines the geometry data
  20352. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20353. */
  20354. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20355. /**
  20356. * Set specific vertex data
  20357. * @param kind defines the data kind (Position, normal, etc...)
  20358. * @param data defines the vertex data to use
  20359. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20360. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20361. */
  20362. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20363. /**
  20364. * Removes a specific vertex data
  20365. * @param kind defines the data kind (Position, normal, etc...)
  20366. */
  20367. removeVerticesData(kind: string): void;
  20368. /**
  20369. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20370. * @param buffer defines the vertex buffer to use
  20371. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20372. */
  20373. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20374. /**
  20375. * Update a specific vertex buffer
  20376. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  20377. * It will do nothing if the buffer is not updatable
  20378. * @param kind defines the data kind (Position, normal, etc...)
  20379. * @param data defines the data to use
  20380. * @param offset defines the offset in the target buffer where to store the data
  20381. * @param useBytes set to true if the offset is in bytes
  20382. */
  20383. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20384. /**
  20385. * Update a specific vertex buffer
  20386. * This function will create a new buffer if the current one is not updatable
  20387. * @param kind defines the data kind (Position, normal, etc...)
  20388. * @param data defines the data to use
  20389. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20390. */
  20391. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20392. private _updateBoundingInfo;
  20393. /** @hidden */
  20394. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  20395. /**
  20396. * Gets total number of vertices
  20397. * @returns the total number of vertices
  20398. */
  20399. getTotalVertices(): number;
  20400. /**
  20401. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20402. * @param kind defines the data kind (Position, normal, etc...)
  20403. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20404. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20405. * @returns a float array containing vertex data
  20406. */
  20407. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20408. /**
  20409. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20410. * @param kind defines the data kind (Position, normal, etc...)
  20411. * @returns true if the vertex buffer with the specified kind is updatable
  20412. */
  20413. isVertexBufferUpdatable(kind: string): boolean;
  20414. /**
  20415. * Gets a specific vertex buffer
  20416. * @param kind defines the data kind (Position, normal, etc...)
  20417. * @returns a {BABYLON.VertexBuffer}
  20418. */
  20419. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20420. /**
  20421. * Returns all vertex buffers
  20422. * @return an object holding all vertex buffers indexed by kind
  20423. */
  20424. getVertexBuffers(): Nullable<{
  20425. [key: string]: VertexBuffer;
  20426. }>;
  20427. /**
  20428. * Gets a boolean indicating if specific vertex buffer is present
  20429. * @param kind defines the data kind (Position, normal, etc...)
  20430. * @returns true if data is present
  20431. */
  20432. isVerticesDataPresent(kind: string): boolean;
  20433. /**
  20434. * Gets a list of all attached data kinds (Position, normal, etc...)
  20435. * @returns a list of string containing all kinds
  20436. */
  20437. getVerticesDataKinds(): string[];
  20438. /**
  20439. * Update index buffer
  20440. * @param indices defines the indices to store in the index buffer
  20441. * @param offset defines the offset in the target buffer where to store the data
  20442. */
  20443. updateIndices(indices: IndicesArray, offset?: number): void;
  20444. /**
  20445. * Creates a new index buffer
  20446. * @param indices defines the indices to store in the index buffer
  20447. * @param totalVertices defines the total number of vertices (could be null)
  20448. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20449. */
  20450. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20451. /**
  20452. * Return the total number of indices
  20453. * @returns the total number of indices
  20454. */
  20455. getTotalIndices(): number;
  20456. /**
  20457. * Gets the index buffer array
  20458. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20459. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20460. * @returns the index buffer array
  20461. */
  20462. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20463. /**
  20464. * Gets the index buffer
  20465. * @return the index buffer
  20466. */
  20467. getIndexBuffer(): Nullable<WebGLBuffer>;
  20468. /** @hidden */
  20469. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20470. /**
  20471. * Release the associated resources for a specific mesh
  20472. * @param mesh defines the source mesh
  20473. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20474. */
  20475. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20476. /**
  20477. * Apply current geometry to a given mesh
  20478. * @param mesh defines the mesh to apply geometry to
  20479. */
  20480. applyToMesh(mesh: Mesh): void;
  20481. private _updateExtend;
  20482. private _applyToMesh;
  20483. private notifyUpdate;
  20484. /**
  20485. * Load the geometry if it was flagged as delay loaded
  20486. * @param scene defines the hosting scene
  20487. * @param onLoaded defines a callback called when the geometry is loaded
  20488. */
  20489. load(scene: Scene, onLoaded?: () => void): void;
  20490. private _queueLoad;
  20491. /**
  20492. * Invert the geometry to move from a right handed system to a left handed one.
  20493. */
  20494. toLeftHanded(): void;
  20495. /** @hidden */
  20496. _resetPointsArrayCache(): void;
  20497. /** @hidden */
  20498. _generatePointsArray(): boolean;
  20499. /**
  20500. * Gets a value indicating if the geometry is disposed
  20501. * @returns true if the geometry was disposed
  20502. */
  20503. isDisposed(): boolean;
  20504. private _disposeVertexArrayObjects;
  20505. /**
  20506. * Free all associated resources
  20507. */
  20508. dispose(): void;
  20509. /**
  20510. * Clone the current geometry into a new geometry
  20511. * @param id defines the unique ID of the new geometry
  20512. * @returns a new geometry object
  20513. */
  20514. copy(id: string): Geometry;
  20515. /**
  20516. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20517. * @return a JSON representation of the current geometry data (without the vertices data)
  20518. */
  20519. serialize(): any;
  20520. private toNumberArray;
  20521. /**
  20522. * Serialize all vertices data into a JSON oject
  20523. * @returns a JSON representation of the current geometry data
  20524. */
  20525. serializeVerticeData(): any;
  20526. /**
  20527. * Extracts a clone of a mesh geometry
  20528. * @param mesh defines the source mesh
  20529. * @param id defines the unique ID of the new geometry object
  20530. * @returns the new geometry object
  20531. */
  20532. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20533. /**
  20534. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20535. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20536. * Be aware Math.random() could cause collisions, but:
  20537. * "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"
  20538. * @returns a string containing a new GUID
  20539. */
  20540. static RandomId(): string;
  20541. /** @hidden */
  20542. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  20543. private static _CleanMatricesWeights;
  20544. /**
  20545. * Create a new geometry from persisted data (Using .babylon file format)
  20546. * @param parsedVertexData defines the persisted data
  20547. * @param scene defines the hosting scene
  20548. * @param rootUrl defines the root url to use to load assets (like delayed data)
  20549. * @returns the new geometry object
  20550. */
  20551. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  20552. }
  20553. /**
  20554. * Abstract class used to provide common services for all typed geometries
  20555. * @hidden
  20556. */
  20557. class _PrimitiveGeometry extends Geometry {
  20558. private _canBeRegenerated;
  20559. private _beingRegenerated;
  20560. /**
  20561. * Creates a new typed geometry
  20562. * @param id defines the unique ID of the geometry
  20563. * @param scene defines the hosting scene
  20564. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20565. * @param mesh defines the hosting mesh (can be null)
  20566. */
  20567. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20568. /**
  20569. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  20570. * @returns true if the geometry can be regenerated
  20571. */
  20572. canBeRegenerated(): boolean;
  20573. /**
  20574. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  20575. */
  20576. regenerate(): void;
  20577. /**
  20578. * Clone the geometry
  20579. * @param id defines the unique ID of the new geometry
  20580. * @returns the new geometry
  20581. */
  20582. asNewGeometry(id: string): Geometry;
  20583. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20584. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  20585. /** @hidden */
  20586. _regenerateVertexData(): VertexData;
  20587. copy(id: string): Geometry;
  20588. serialize(): any;
  20589. }
  20590. /**
  20591. * Creates a ribbon geometry
  20592. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  20593. */
  20594. class RibbonGeometry extends _PrimitiveGeometry {
  20595. /**
  20596. * Defines the array of paths to use
  20597. */
  20598. pathArray: Vector3[][];
  20599. /**
  20600. * Defines if the last and first points of each path in your pathArray must be joined
  20601. */
  20602. closeArray: boolean;
  20603. /**
  20604. * Defines if the last and first points of each path in your pathArray must be joined
  20605. */
  20606. closePath: boolean;
  20607. /**
  20608. * Defines the offset between points
  20609. */
  20610. offset: number;
  20611. /**
  20612. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20613. */
  20614. side: number;
  20615. /**
  20616. * Creates a ribbon geometry
  20617. * @param id defines the unique ID of the geometry
  20618. * @param scene defines the hosting scene
  20619. * @param pathArray defines the array of paths to use
  20620. * @param closeArray defines if the last path and the first path must be joined
  20621. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  20622. * @param offset defines the offset between points
  20623. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20624. * @param mesh defines the hosting mesh (can be null)
  20625. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20626. */
  20627. constructor(id: string, scene: Scene,
  20628. /**
  20629. * Defines the array of paths to use
  20630. */
  20631. pathArray: Vector3[][],
  20632. /**
  20633. * Defines if the last and first points of each path in your pathArray must be joined
  20634. */
  20635. closeArray: boolean,
  20636. /**
  20637. * Defines if the last and first points of each path in your pathArray must be joined
  20638. */
  20639. closePath: boolean,
  20640. /**
  20641. * Defines the offset between points
  20642. */
  20643. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  20644. /**
  20645. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20646. */
  20647. side?: number);
  20648. /** @hidden */
  20649. _regenerateVertexData(): VertexData;
  20650. copy(id: string): Geometry;
  20651. }
  20652. /**
  20653. * Creates a box geometry
  20654. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  20655. */
  20656. class BoxGeometry extends _PrimitiveGeometry {
  20657. /**
  20658. * Defines the zise of the box (width, height and depth are the same)
  20659. */
  20660. size: number;
  20661. /**
  20662. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20663. */
  20664. side: number;
  20665. /**
  20666. * Creates a box geometry
  20667. * @param id defines the unique ID of the geometry
  20668. * @param scene defines the hosting scene
  20669. * @param size defines the zise of the box (width, height and depth are the same)
  20670. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20671. * @param mesh defines the hosting mesh (can be null)
  20672. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20673. */
  20674. constructor(id: string, scene: Scene,
  20675. /**
  20676. * Defines the zise of the box (width, height and depth are the same)
  20677. */
  20678. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20679. /**
  20680. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20681. */
  20682. side?: number);
  20683. /** @hidden */
  20684. _regenerateVertexData(): VertexData;
  20685. copy(id: string): Geometry;
  20686. serialize(): any;
  20687. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  20688. }
  20689. /**
  20690. * Creates a sphere geometry
  20691. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  20692. */
  20693. class SphereGeometry extends _PrimitiveGeometry {
  20694. /**
  20695. * Defines the number of segments to use to create the sphere
  20696. */
  20697. segments: number;
  20698. /**
  20699. * Defines the diameter of the sphere
  20700. */
  20701. diameter: number;
  20702. /**
  20703. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20704. */
  20705. side: number;
  20706. /**
  20707. * Create a new sphere geometry
  20708. * @param id defines the unique ID of the geometry
  20709. * @param scene defines the hosting scene
  20710. * @param segments defines the number of segments to use to create the sphere
  20711. * @param diameter defines the diameter of the sphere
  20712. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20713. * @param mesh defines the hosting mesh (can be null)
  20714. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20715. */
  20716. constructor(id: string, scene: Scene,
  20717. /**
  20718. * Defines the number of segments to use to create the sphere
  20719. */
  20720. segments: number,
  20721. /**
  20722. * Defines the diameter of the sphere
  20723. */
  20724. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20725. /**
  20726. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20727. */
  20728. side?: number);
  20729. /** @hidden */
  20730. _regenerateVertexData(): VertexData;
  20731. copy(id: string): Geometry;
  20732. serialize(): any;
  20733. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  20734. }
  20735. /**
  20736. * Creates a disc geometry
  20737. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  20738. */
  20739. class DiscGeometry extends _PrimitiveGeometry {
  20740. /**
  20741. * Defines the radius of the disc
  20742. */
  20743. radius: number;
  20744. /**
  20745. * Defines the tesselation factor to apply to the disc
  20746. */
  20747. tessellation: number;
  20748. /**
  20749. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20750. */
  20751. side: number;
  20752. /**
  20753. * Creates a new disc geometry
  20754. * @param id defines the unique ID of the geometry
  20755. * @param scene defines the hosting scene
  20756. * @param radius defines the radius of the disc
  20757. * @param tessellation defines the tesselation factor to apply to the disc
  20758. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20759. * @param mesh defines the hosting mesh (can be null)
  20760. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20761. */
  20762. constructor(id: string, scene: Scene,
  20763. /**
  20764. * Defines the radius of the disc
  20765. */
  20766. radius: number,
  20767. /**
  20768. * Defines the tesselation factor to apply to the disc
  20769. */
  20770. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20771. /**
  20772. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20773. */
  20774. side?: number);
  20775. /** @hidden */
  20776. _regenerateVertexData(): VertexData;
  20777. copy(id: string): Geometry;
  20778. }
  20779. /**
  20780. * Creates a new cylinder geometry
  20781. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  20782. */
  20783. class CylinderGeometry extends _PrimitiveGeometry {
  20784. /**
  20785. * Defines the height of the cylinder
  20786. */
  20787. height: number;
  20788. /**
  20789. * Defines the diameter of the cylinder's top cap
  20790. */
  20791. diameterTop: number;
  20792. /**
  20793. * Defines the diameter of the cylinder's bottom cap
  20794. */
  20795. diameterBottom: number;
  20796. /**
  20797. * Defines the tessellation factor to apply to the cylinder
  20798. */
  20799. tessellation: number;
  20800. /**
  20801. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20802. */
  20803. subdivisions: number;
  20804. /**
  20805. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20806. */
  20807. side: number;
  20808. /**
  20809. * Creates a new cylinder geometry
  20810. * @param id defines the unique ID of the geometry
  20811. * @param scene defines the hosting scene
  20812. * @param height defines the height of the cylinder
  20813. * @param diameterTop defines the diameter of the cylinder's top cap
  20814. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  20815. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  20816. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  20817. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20818. * @param mesh defines the hosting mesh (can be null)
  20819. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20820. */
  20821. constructor(id: string, scene: Scene,
  20822. /**
  20823. * Defines the height of the cylinder
  20824. */
  20825. height: number,
  20826. /**
  20827. * Defines the diameter of the cylinder's top cap
  20828. */
  20829. diameterTop: number,
  20830. /**
  20831. * Defines the diameter of the cylinder's bottom cap
  20832. */
  20833. diameterBottom: number,
  20834. /**
  20835. * Defines the tessellation factor to apply to the cylinder
  20836. */
  20837. tessellation: number,
  20838. /**
  20839. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20840. */
  20841. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20842. /**
  20843. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20844. */
  20845. side?: number);
  20846. /** @hidden */
  20847. _regenerateVertexData(): VertexData;
  20848. copy(id: string): Geometry;
  20849. serialize(): any;
  20850. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  20851. }
  20852. /**
  20853. * Creates a new torus geometry
  20854. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  20855. */
  20856. class TorusGeometry extends _PrimitiveGeometry {
  20857. /**
  20858. * Defines the diameter of the torus
  20859. */
  20860. diameter: number;
  20861. /**
  20862. * Defines the thickness of the torus (ie. internal diameter)
  20863. */
  20864. thickness: number;
  20865. /**
  20866. * Defines the tesselation factor to apply to the torus
  20867. */
  20868. tessellation: number;
  20869. /**
  20870. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20871. */
  20872. side: number;
  20873. /**
  20874. * Creates a new torus geometry
  20875. * @param id defines the unique ID of the geometry
  20876. * @param scene defines the hosting scene
  20877. * @param diameter defines the diameter of the torus
  20878. * @param thickness defines the thickness of the torus (ie. internal diameter)
  20879. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  20880. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20881. * @param mesh defines the hosting mesh (can be null)
  20882. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20883. */
  20884. constructor(id: string, scene: Scene,
  20885. /**
  20886. * Defines the diameter of the torus
  20887. */
  20888. diameter: number,
  20889. /**
  20890. * Defines the thickness of the torus (ie. internal diameter)
  20891. */
  20892. thickness: number,
  20893. /**
  20894. * Defines the tesselation factor to apply to the torus
  20895. */
  20896. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20897. /**
  20898. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20899. */
  20900. side?: number);
  20901. /** @hidden */
  20902. _regenerateVertexData(): VertexData;
  20903. copy(id: string): Geometry;
  20904. serialize(): any;
  20905. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  20906. }
  20907. /**
  20908. * Creates a new ground geometry
  20909. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  20910. */
  20911. class GroundGeometry extends _PrimitiveGeometry {
  20912. /**
  20913. * Defines the width of the ground
  20914. */
  20915. width: number;
  20916. /**
  20917. * Defines the height of the ground
  20918. */
  20919. height: number;
  20920. /**
  20921. * Defines the subdivisions to apply to the ground
  20922. */
  20923. subdivisions: number;
  20924. /**
  20925. * Creates a new ground geometry
  20926. * @param id defines the unique ID of the geometry
  20927. * @param scene defines the hosting scene
  20928. * @param width defines the width of the ground
  20929. * @param height defines the height of the ground
  20930. * @param subdivisions defines the subdivisions to apply to the ground
  20931. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20932. * @param mesh defines the hosting mesh (can be null)
  20933. */
  20934. constructor(id: string, scene: Scene,
  20935. /**
  20936. * Defines the width of the ground
  20937. */
  20938. width: number,
  20939. /**
  20940. * Defines the height of the ground
  20941. */
  20942. height: number,
  20943. /**
  20944. * Defines the subdivisions to apply to the ground
  20945. */
  20946. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20947. /** @hidden */
  20948. _regenerateVertexData(): VertexData;
  20949. copy(id: string): Geometry;
  20950. serialize(): any;
  20951. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  20952. }
  20953. /**
  20954. * Creates a tiled ground geometry
  20955. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  20956. */
  20957. class TiledGroundGeometry extends _PrimitiveGeometry {
  20958. /**
  20959. * Defines the minimum value on X axis
  20960. */
  20961. xmin: number;
  20962. /**
  20963. * Defines the minimum value on Z axis
  20964. */
  20965. zmin: number;
  20966. /**
  20967. * Defines the maximum value on X axis
  20968. */
  20969. xmax: number;
  20970. /**
  20971. * Defines the maximum value on Z axis
  20972. */
  20973. zmax: number;
  20974. /**
  20975. * Defines the subdivisions to apply to the ground
  20976. */
  20977. subdivisions: {
  20978. w: number;
  20979. h: number;
  20980. };
  20981. /**
  20982. * Defines the precision to use when computing the tiles
  20983. */
  20984. precision: {
  20985. w: number;
  20986. h: number;
  20987. };
  20988. /**
  20989. * Creates a tiled ground geometry
  20990. * @param id defines the unique ID of the geometry
  20991. * @param scene defines the hosting scene
  20992. * @param xmin defines the minimum value on X axis
  20993. * @param zmin defines the minimum value on Z axis
  20994. * @param xmax defines the maximum value on X axis
  20995. * @param zmax defines the maximum value on Z axis
  20996. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  20997. * @param precision defines the precision to use when computing the tiles
  20998. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20999. * @param mesh defines the hosting mesh (can be null)
  21000. */
  21001. constructor(id: string, scene: Scene,
  21002. /**
  21003. * Defines the minimum value on X axis
  21004. */
  21005. xmin: number,
  21006. /**
  21007. * Defines the minimum value on Z axis
  21008. */
  21009. zmin: number,
  21010. /**
  21011. * Defines the maximum value on X axis
  21012. */
  21013. xmax: number,
  21014. /**
  21015. * Defines the maximum value on Z axis
  21016. */
  21017. zmax: number,
  21018. /**
  21019. * Defines the subdivisions to apply to the ground
  21020. */
  21021. subdivisions: {
  21022. w: number;
  21023. h: number;
  21024. },
  21025. /**
  21026. * Defines the precision to use when computing the tiles
  21027. */
  21028. precision: {
  21029. w: number;
  21030. h: number;
  21031. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  21032. /** @hidden */
  21033. _regenerateVertexData(): VertexData;
  21034. copy(id: string): Geometry;
  21035. }
  21036. /**
  21037. * Creates a plane geometry
  21038. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  21039. */
  21040. class PlaneGeometry extends _PrimitiveGeometry {
  21041. /**
  21042. * Defines the size of the plane (width === height)
  21043. */
  21044. size: number;
  21045. /**
  21046. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21047. */
  21048. side: number;
  21049. /**
  21050. * Creates a plane geometry
  21051. * @param id defines the unique ID of the geometry
  21052. * @param scene defines the hosting scene
  21053. * @param size defines the size of the plane (width === height)
  21054. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21055. * @param mesh defines the hosting mesh (can be null)
  21056. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21057. */
  21058. constructor(id: string, scene: Scene,
  21059. /**
  21060. * Defines the size of the plane (width === height)
  21061. */
  21062. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21063. /**
  21064. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21065. */
  21066. side?: number);
  21067. /** @hidden */
  21068. _regenerateVertexData(): VertexData;
  21069. copy(id: string): Geometry;
  21070. serialize(): any;
  21071. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  21072. }
  21073. /**
  21074. * Creates a torus knot geometry
  21075. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  21076. */
  21077. class TorusKnotGeometry extends _PrimitiveGeometry {
  21078. /**
  21079. * Defines the radius of the torus knot
  21080. */
  21081. radius: number;
  21082. /**
  21083. * Defines the thickness of the torus knot tube
  21084. */
  21085. tube: number;
  21086. /**
  21087. * Defines the number of radial segments
  21088. */
  21089. radialSegments: number;
  21090. /**
  21091. * Defines the number of tubular segments
  21092. */
  21093. tubularSegments: number;
  21094. /**
  21095. * Defines the first number of windings
  21096. */
  21097. p: number;
  21098. /**
  21099. * Defines the second number of windings
  21100. */
  21101. q: number;
  21102. /**
  21103. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21104. */
  21105. side: number;
  21106. /**
  21107. * Creates a torus knot geometry
  21108. * @param id defines the unique ID of the geometry
  21109. * @param scene defines the hosting scene
  21110. * @param radius defines the radius of the torus knot
  21111. * @param tube defines the thickness of the torus knot tube
  21112. * @param radialSegments defines the number of radial segments
  21113. * @param tubularSegments defines the number of tubular segments
  21114. * @param p defines the first number of windings
  21115. * @param q defines the second number of windings
  21116. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21117. * @param mesh defines the hosting mesh (can be null)
  21118. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21119. */
  21120. constructor(id: string, scene: Scene,
  21121. /**
  21122. * Defines the radius of the torus knot
  21123. */
  21124. radius: number,
  21125. /**
  21126. * Defines the thickness of the torus knot tube
  21127. */
  21128. tube: number,
  21129. /**
  21130. * Defines the number of radial segments
  21131. */
  21132. radialSegments: number,
  21133. /**
  21134. * Defines the number of tubular segments
  21135. */
  21136. tubularSegments: number,
  21137. /**
  21138. * Defines the first number of windings
  21139. */
  21140. p: number,
  21141. /**
  21142. * Defines the second number of windings
  21143. */
  21144. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21145. /**
  21146. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  21147. */
  21148. side?: number);
  21149. /** @hidden */
  21150. _regenerateVertexData(): VertexData;
  21151. copy(id: string): Geometry;
  21152. serialize(): any;
  21153. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  21154. }
  21155. }
  21156. declare module BABYLON {
  21157. class GroundMesh extends Mesh {
  21158. generateOctree: boolean;
  21159. private _heightQuads;
  21160. /** @hidden */
  21161. _subdivisionsX: number;
  21162. /** @hidden */
  21163. _subdivisionsY: number;
  21164. /** @hidden */
  21165. _width: number;
  21166. /** @hidden */
  21167. _height: number;
  21168. /** @hidden */
  21169. _minX: number;
  21170. /** @hidden */
  21171. _maxX: number;
  21172. /** @hidden */
  21173. _minZ: number;
  21174. /** @hidden */
  21175. _maxZ: number;
  21176. constructor(name: string, scene: Scene);
  21177. getClassName(): string;
  21178. readonly subdivisions: number;
  21179. readonly subdivisionsX: number;
  21180. readonly subdivisionsY: number;
  21181. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21182. /**
  21183. * Returns a height (y) value in the Worl system :
  21184. * the ground altitude at the coordinates (x, z) expressed in the World system.
  21185. * Returns the ground y position if (x, z) are outside the ground surface.
  21186. */
  21187. getHeightAtCoordinates(x: number, z: number): number;
  21188. /**
  21189. * Returns a normalized vector (Vector3) orthogonal to the ground
  21190. * at the ground coordinates (x, z) expressed in the World system.
  21191. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  21192. */
  21193. getNormalAtCoordinates(x: number, z: number): Vector3;
  21194. /**
  21195. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  21196. * at the ground coordinates (x, z) expressed in the World system.
  21197. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  21198. * Returns the GroundMesh.
  21199. */
  21200. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  21201. /**
  21202. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  21203. * if the ground has been updated.
  21204. * This can be used in the render loop.
  21205. * Returns the GroundMesh.
  21206. */
  21207. updateCoordinateHeights(): GroundMesh;
  21208. private _getFacetAt;
  21209. private _initHeightQuads;
  21210. private _computeHeightQuads;
  21211. serialize(serializationObject: any): void;
  21212. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  21213. }
  21214. }
  21215. declare module BABYLON {
  21216. /**
  21217. * Creates an instance based on a source mesh.
  21218. */
  21219. class InstancedMesh extends AbstractMesh {
  21220. private _sourceMesh;
  21221. private _currentLOD;
  21222. constructor(name: string, source: Mesh);
  21223. /**
  21224. * Returns the string "InstancedMesh".
  21225. */
  21226. getClassName(): string;
  21227. readonly receiveShadows: boolean;
  21228. readonly material: Nullable<Material>;
  21229. readonly visibility: number;
  21230. readonly skeleton: Nullable<Skeleton>;
  21231. renderingGroupId: number;
  21232. /**
  21233. * Returns the total number of vertices (integer).
  21234. */
  21235. getTotalVertices(): number;
  21236. readonly sourceMesh: Mesh;
  21237. /**
  21238. * Is this node ready to be used/rendered
  21239. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21240. * @return {boolean} is it ready
  21241. */
  21242. isReady(completeCheck?: boolean): boolean;
  21243. /**
  21244. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  21245. */
  21246. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  21247. /**
  21248. * Sets the vertex data of the mesh geometry for the requested `kind`.
  21249. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  21250. * The `data` are either a numeric array either a Float32Array.
  21251. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  21252. * 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).
  21253. * Note that a new underlying VertexBuffer object is created each call.
  21254. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  21255. *
  21256. * Possible `kind` values :
  21257. * - BABYLON.VertexBuffer.PositionKind
  21258. * - BABYLON.VertexBuffer.UVKind
  21259. * - BABYLON.VertexBuffer.UV2Kind
  21260. * - BABYLON.VertexBuffer.UV3Kind
  21261. * - BABYLON.VertexBuffer.UV4Kind
  21262. * - BABYLON.VertexBuffer.UV5Kind
  21263. * - BABYLON.VertexBuffer.UV6Kind
  21264. * - BABYLON.VertexBuffer.ColorKind
  21265. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21266. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21267. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21268. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21269. *
  21270. * Returns the Mesh.
  21271. */
  21272. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21273. /**
  21274. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  21275. * If the mesh has no geometry, it is simply returned as it is.
  21276. * The `data` are either a numeric array either a Float32Array.
  21277. * No new underlying VertexBuffer object is created.
  21278. * 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.
  21279. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  21280. *
  21281. * Possible `kind` values :
  21282. * - BABYLON.VertexBuffer.PositionKind
  21283. * - BABYLON.VertexBuffer.UVKind
  21284. * - BABYLON.VertexBuffer.UV2Kind
  21285. * - BABYLON.VertexBuffer.UV3Kind
  21286. * - BABYLON.VertexBuffer.UV4Kind
  21287. * - BABYLON.VertexBuffer.UV5Kind
  21288. * - BABYLON.VertexBuffer.UV6Kind
  21289. * - BABYLON.VertexBuffer.ColorKind
  21290. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21291. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21292. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21293. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21294. *
  21295. * Returns the Mesh.
  21296. */
  21297. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21298. /**
  21299. * Sets the mesh indices.
  21300. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  21301. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  21302. * This method creates a new index buffer each call.
  21303. * Returns the Mesh.
  21304. */
  21305. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  21306. /**
  21307. * Boolean : True if the mesh owns the requested kind of data.
  21308. */
  21309. isVerticesDataPresent(kind: string): boolean;
  21310. /**
  21311. * Returns an array of indices (IndicesArray).
  21312. */
  21313. getIndices(): Nullable<IndicesArray>;
  21314. readonly _positions: Nullable<Vector3[]>;
  21315. /**
  21316. * Sets a new updated BoundingInfo to the mesh.
  21317. * Returns the mesh.
  21318. */
  21319. refreshBoundingInfo(): InstancedMesh;
  21320. /** @hidden */
  21321. _preActivate(): InstancedMesh;
  21322. /** @hidden */
  21323. _activate(renderId: number): InstancedMesh;
  21324. /**
  21325. * Returns the current associated LOD AbstractMesh.
  21326. */
  21327. getLOD(camera: Camera): AbstractMesh;
  21328. /** @hidden */
  21329. _syncSubMeshes(): InstancedMesh;
  21330. /** @hidden */
  21331. _generatePointsArray(): boolean;
  21332. /**
  21333. * Creates a new InstancedMesh from the current mesh.
  21334. * - name (string) : the cloned mesh name
  21335. * - newParent (optional Node) : the optional Node to parent the clone to.
  21336. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  21337. *
  21338. * Returns the clone.
  21339. */
  21340. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  21341. /**
  21342. * Disposes the InstancedMesh.
  21343. * Returns nothing.
  21344. */
  21345. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21346. }
  21347. }
  21348. declare module BABYLON {
  21349. class LinesMesh extends Mesh {
  21350. useVertexColor?: boolean | undefined;
  21351. useVertexAlpha?: boolean | undefined;
  21352. color: Color3;
  21353. alpha: number;
  21354. /**
  21355. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21356. * This margin is expressed in world space coordinates, so its value may vary.
  21357. * Default value is 0.1
  21358. * @returns the intersection Threshold value.
  21359. */
  21360. /**
  21361. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  21362. * This margin is expressed in world space coordinates, so its value may vary.
  21363. * @param value the new threshold to apply
  21364. */
  21365. intersectionThreshold: number;
  21366. private _intersectionThreshold;
  21367. private _colorShader;
  21368. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  21369. /**
  21370. * Returns the string "LineMesh"
  21371. */
  21372. getClassName(): string;
  21373. /**
  21374. * @hidden
  21375. */
  21376. /**
  21377. * @hidden
  21378. */
  21379. material: Material;
  21380. /**
  21381. * @hidden
  21382. */
  21383. readonly checkCollisions: boolean;
  21384. createInstance(name: string): InstancedMesh;
  21385. /** @hidden */
  21386. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  21387. /** @hidden */
  21388. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  21389. dispose(doNotRecurse?: boolean): void;
  21390. /**
  21391. * Returns a new LineMesh object cloned from the current one.
  21392. */
  21393. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  21394. }
  21395. }
  21396. declare module BABYLON {
  21397. /**
  21398. * @hidden
  21399. **/
  21400. class _InstancesBatch {
  21401. mustReturn: boolean;
  21402. visibleInstances: Nullable<InstancedMesh[]>[];
  21403. renderSelf: boolean[];
  21404. }
  21405. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21406. static _FRONTSIDE: number;
  21407. static _BACKSIDE: number;
  21408. static _DOUBLESIDE: number;
  21409. static _DEFAULTSIDE: number;
  21410. static _NO_CAP: number;
  21411. static _CAP_START: number;
  21412. static _CAP_END: number;
  21413. static _CAP_ALL: number;
  21414. /**
  21415. * Mesh side orientation : usually the external or front surface
  21416. */
  21417. static readonly FRONTSIDE: number;
  21418. /**
  21419. * Mesh side orientation : usually the internal or back surface
  21420. */
  21421. static readonly BACKSIDE: number;
  21422. /**
  21423. * Mesh side orientation : both internal and external or front and back surfaces
  21424. */
  21425. static readonly DOUBLESIDE: number;
  21426. /**
  21427. * Mesh side orientation : by default, `FRONTSIDE`
  21428. */
  21429. static readonly DEFAULTSIDE: number;
  21430. /**
  21431. * Mesh cap setting : no cap
  21432. */
  21433. static readonly NO_CAP: number;
  21434. /**
  21435. * Mesh cap setting : one cap at the beginning of the mesh
  21436. */
  21437. static readonly CAP_START: number;
  21438. /**
  21439. * Mesh cap setting : one cap at the end of the mesh
  21440. */
  21441. static readonly CAP_END: number;
  21442. /**
  21443. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21444. */
  21445. static readonly CAP_ALL: number;
  21446. private _onBeforeRenderObservable;
  21447. private _onAfterRenderObservable;
  21448. private _onBeforeDrawObservable;
  21449. /**
  21450. * An event triggered before rendering the mesh
  21451. */
  21452. readonly onBeforeRenderObservable: Observable<Mesh>;
  21453. /**
  21454. * An event triggered after rendering the mesh
  21455. */
  21456. readonly onAfterRenderObservable: Observable<Mesh>;
  21457. /**
  21458. * An event triggered before drawing the mesh
  21459. */
  21460. readonly onBeforeDrawObservable: Observable<Mesh>;
  21461. private _onBeforeDrawObserver;
  21462. onBeforeDraw: () => void;
  21463. delayLoadState: number;
  21464. instances: InstancedMesh[];
  21465. delayLoadingFile: string;
  21466. /** @hidden */
  21467. _binaryInfo: any;
  21468. private _LODLevels;
  21469. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21470. private _morphTargetManager;
  21471. morphTargetManager: Nullable<MorphTargetManager>;
  21472. /** @hidden */
  21473. _geometry: Nullable<Geometry>;
  21474. /** @hidden */
  21475. _delayInfo: Array<string>;
  21476. /** @hidden */
  21477. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21478. /** @hidden */
  21479. _visibleInstances: any;
  21480. private _renderIdForInstances;
  21481. private _batchCache;
  21482. private _instancesBufferSize;
  21483. private _instancesBuffer;
  21484. private _instancesData;
  21485. private _overridenInstanceCount;
  21486. private _effectiveMaterial;
  21487. /** @hidden */
  21488. _shouldGenerateFlatShading: boolean;
  21489. private _preActivateId;
  21490. /** @hidden */
  21491. _originalBuilderSideOrientation: number;
  21492. overrideMaterialSideOrientation: Nullable<number>;
  21493. private _areNormalsFrozen;
  21494. private _sourcePositions;
  21495. private _sourceNormals;
  21496. private _source;
  21497. readonly source: Nullable<Mesh>;
  21498. isUnIndexed: boolean;
  21499. /**
  21500. * @constructor
  21501. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  21502. * @param {Scene} scene The scene to add this mesh to.
  21503. * @param {Node} parent The parent of this mesh, if it has one
  21504. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  21505. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21506. * When false, achieved by calling a clone(), also passing False.
  21507. * This will make creation of children, recursive.
  21508. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21509. */
  21510. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21511. /**
  21512. * Returns the string "Mesh".
  21513. */
  21514. getClassName(): string;
  21515. /**
  21516. * Returns a string.
  21517. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  21518. */
  21519. toString(fullDetails?: boolean): string;
  21520. /** @hidden */
  21521. _unBindEffect(): void;
  21522. /**
  21523. * True if the mesh has some Levels Of Details (LOD).
  21524. * Returns a boolean.
  21525. */
  21526. readonly hasLODLevels: boolean;
  21527. /**
  21528. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  21529. * @returns an array of {BABYLON.MeshLODLevel}
  21530. */
  21531. getLODLevels(): MeshLODLevel[];
  21532. private _sortLODLevels;
  21533. /**
  21534. * Add a mesh as LOD level triggered at the given distance.
  21535. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21536. * @param distance The distance from the center of the object to show this level
  21537. * @param mesh The mesh to be added as LOD level (can be null)
  21538. * @return This mesh (for chaining)
  21539. */
  21540. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21541. /**
  21542. * Returns the LOD level mesh at the passed distance or null if not found.
  21543. * It is related to the method `addLODLevel(distance, mesh)`.
  21544. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21545. * Returns an object Mesh or `null`.
  21546. */
  21547. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21548. /**
  21549. * Remove a mesh from the LOD array
  21550. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21551. * @param {Mesh} mesh The mesh to be removed.
  21552. * @return {Mesh} This mesh (for chaining)
  21553. */
  21554. removeLODLevel(mesh: Mesh): Mesh;
  21555. /**
  21556. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21557. * tuto : http://doc.babylonjs.com/how_to/how_to_use_lod
  21558. */
  21559. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21560. /**
  21561. * Returns the mesh internal Geometry object.
  21562. */
  21563. readonly geometry: Nullable<Geometry>;
  21564. /**
  21565. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21566. */
  21567. getTotalVertices(): number;
  21568. /**
  21569. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  21570. * 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.
  21571. * You can force the copy with forceCopy === true
  21572. * Returns null if the mesh has no geometry or no vertex buffer.
  21573. * Possible `kind` values :
  21574. * - BABYLON.VertexBuffer.PositionKind
  21575. * - BABYLON.VertexBuffer.UVKind
  21576. * - BABYLON.VertexBuffer.UV2Kind
  21577. * - BABYLON.VertexBuffer.UV3Kind
  21578. * - BABYLON.VertexBuffer.UV4Kind
  21579. * - BABYLON.VertexBuffer.UV5Kind
  21580. * - BABYLON.VertexBuffer.UV6Kind
  21581. * - BABYLON.VertexBuffer.ColorKind
  21582. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21583. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21584. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21585. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21586. */
  21587. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21588. /**
  21589. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  21590. * Returns `null` if the mesh has no geometry.
  21591. * Possible `kind` values :
  21592. * - BABYLON.VertexBuffer.PositionKind
  21593. * - BABYLON.VertexBuffer.UVKind
  21594. * - BABYLON.VertexBuffer.UV2Kind
  21595. * - BABYLON.VertexBuffer.UV3Kind
  21596. * - BABYLON.VertexBuffer.UV4Kind
  21597. * - BABYLON.VertexBuffer.UV5Kind
  21598. * - BABYLON.VertexBuffer.UV6Kind
  21599. * - BABYLON.VertexBuffer.ColorKind
  21600. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21601. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21602. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21603. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21604. */
  21605. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21606. isVerticesDataPresent(kind: string): boolean;
  21607. /**
  21608. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21609. * Possible `kind` values :
  21610. * - BABYLON.VertexBuffer.PositionKind
  21611. * - BABYLON.VertexBuffer.UVKind
  21612. * - BABYLON.VertexBuffer.UV2Kind
  21613. * - BABYLON.VertexBuffer.UV3Kind
  21614. * - BABYLON.VertexBuffer.UV4Kind
  21615. * - BABYLON.VertexBuffer.UV5Kind
  21616. * - BABYLON.VertexBuffer.UV6Kind
  21617. * - BABYLON.VertexBuffer.ColorKind
  21618. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21619. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21620. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21621. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21622. */
  21623. isVertexBufferUpdatable(kind: string): boolean;
  21624. /**
  21625. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  21626. * Possible `kind` values :
  21627. * - BABYLON.VertexBuffer.PositionKind
  21628. * - BABYLON.VertexBuffer.UVKind
  21629. * - BABYLON.VertexBuffer.UV2Kind
  21630. * - BABYLON.VertexBuffer.UV3Kind
  21631. * - BABYLON.VertexBuffer.UV4Kind
  21632. * - BABYLON.VertexBuffer.UV5Kind
  21633. * - BABYLON.VertexBuffer.UV6Kind
  21634. * - BABYLON.VertexBuffer.ColorKind
  21635. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21636. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21637. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21638. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21639. */
  21640. getVerticesDataKinds(): string[];
  21641. /**
  21642. * Returns a positive integer : the total number of indices in this mesh geometry.
  21643. * Returns zero if the mesh has no geometry.
  21644. */
  21645. getTotalIndices(): number;
  21646. /**
  21647. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21648. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  21649. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21650. * @returns the indices array or an empty array if the mesh has no geometry
  21651. */
  21652. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21653. readonly isBlocked: boolean;
  21654. /**
  21655. * Determine if the current mesh is ready to be rendered
  21656. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21657. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21658. * @returns true if all associated assets are ready (material, textures, shaders)
  21659. */
  21660. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21661. /**
  21662. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  21663. * This property is pertinent only for updatable parametric shapes.
  21664. */
  21665. readonly areNormalsFrozen: boolean;
  21666. /**
  21667. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21668. * It has no effect at all on other shapes.
  21669. * It prevents the mesh normals from being recomputed on next `positions` array update.
  21670. * Returns the Mesh.
  21671. */
  21672. freezeNormals(): Mesh;
  21673. /**
  21674. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21675. * It has no effect at all on other shapes.
  21676. * It reactivates the mesh normals computation if it was previously frozen.
  21677. * Returns the Mesh.
  21678. */
  21679. unfreezeNormals(): Mesh;
  21680. /**
  21681. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21682. */
  21683. overridenInstanceCount: number;
  21684. /** @hidden */
  21685. _preActivate(): Mesh;
  21686. /** @hidden */
  21687. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21688. /** @hidden */
  21689. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21690. /**
  21691. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21692. * This means the mesh underlying bounding box and sphere are recomputed.
  21693. * Returns the Mesh.
  21694. */
  21695. refreshBoundingInfo(): Mesh;
  21696. /** @hidden */
  21697. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  21698. private _getPositionData;
  21699. /** @hidden */
  21700. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21701. subdivide(count: number): void;
  21702. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21703. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21704. /**
  21705. * Sets the mesh VertexBuffer.
  21706. * Returns the Mesh.
  21707. */
  21708. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21709. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21710. /**
  21711. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21712. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21713. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  21714. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  21715. * Returns the Mesh.
  21716. */
  21717. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21718. /**
  21719. * Creates a un-shared specific occurence of the geometry for the mesh.
  21720. * Returns the Mesh.
  21721. */
  21722. makeGeometryUnique(): Mesh;
  21723. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21724. /**
  21725. * Update the current index buffer
  21726. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  21727. * Returns the Mesh.
  21728. */
  21729. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  21730. /**
  21731. * Invert the geometry to move from a right handed system to a left handed one.
  21732. * Returns the Mesh.
  21733. */
  21734. toLeftHanded(): Mesh;
  21735. /** @hidden */
  21736. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21737. /** @hidden */
  21738. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  21739. /**
  21740. * Registers for this mesh a javascript function called just before the rendering process.
  21741. * This function is passed the current mesh.
  21742. * Return the Mesh.
  21743. */
  21744. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21745. /**
  21746. * Disposes a previously registered javascript function called before the rendering.
  21747. * This function is passed the current mesh.
  21748. * Returns the Mesh.
  21749. */
  21750. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21751. /**
  21752. * Registers for this mesh a javascript function called just after the rendering is complete.
  21753. * This function is passed the current mesh.
  21754. * Returns the Mesh.
  21755. */
  21756. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21757. /**
  21758. * Disposes a previously registered javascript function called after the rendering.
  21759. * This function is passed the current mesh.
  21760. * Return the Mesh.
  21761. */
  21762. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21763. /** @hidden */
  21764. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21765. /** @hidden */
  21766. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21767. /** @hidden */
  21768. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21769. /**
  21770. * 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
  21771. * @param subMesh defines the subMesh to render
  21772. * @param enableAlphaMode defines if alpha mode can be changed
  21773. * @returns the current mesh
  21774. */
  21775. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21776. private _onBeforeDraw;
  21777. /**
  21778. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter.
  21779. */
  21780. getEmittedParticleSystems(): IParticleSystem[];
  21781. /**
  21782. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter.
  21783. */
  21784. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  21785. /**
  21786. * Normalize matrix weights so that all vertices have a total weight set to 1
  21787. */
  21788. cleanMatrixWeights(): void;
  21789. /** @hidden */
  21790. _checkDelayState(): Mesh;
  21791. private _queueLoad;
  21792. /**
  21793. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21794. * A mesh is in the frustum if its bounding box intersects the frustum
  21795. * @param frustumPlanes defines the frustum to test
  21796. * @returns true if the mesh is in the frustum planes
  21797. */
  21798. isInFrustum(frustumPlanes: Plane[]): boolean;
  21799. /**
  21800. * Sets the mesh material by the material or multiMaterial `id` property.
  21801. * The material `id` is a string identifying the material or the multiMaterial.
  21802. * This method returns the Mesh.
  21803. */
  21804. setMaterialByID(id: string): Mesh;
  21805. /**
  21806. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21807. */
  21808. getAnimatables(): IAnimatable[];
  21809. /**
  21810. * Modifies the mesh geometry according to the passed transformation matrix.
  21811. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21812. * The mesh normals are modified using the same transformation.
  21813. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  21814. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21815. * Returns the Mesh.
  21816. */
  21817. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21818. /**
  21819. * Modifies the mesh geometry according to its own current World Matrix.
  21820. * The mesh World Matrix is then reset.
  21821. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21822. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  21823. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21824. * Returns the Mesh.
  21825. */
  21826. bakeCurrentTransformIntoVertices(): Mesh;
  21827. readonly _positions: Nullable<Vector3[]>;
  21828. /** @hidden */
  21829. _resetPointsArrayCache(): Mesh;
  21830. /** @hidden */
  21831. _generatePointsArray(): boolean;
  21832. /**
  21833. * Returns a new Mesh object generated from the current mesh properties.
  21834. * This method must not get confused with createInstance().
  21835. * The parameter `name` is a string, the name given to the new mesh.
  21836. * The optional parameter `newParent` can be any Node object (default `null`).
  21837. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  21838. * 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.
  21839. */
  21840. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21841. /**
  21842. * Releases resources associated with this mesh.
  21843. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21844. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21845. */
  21846. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21847. /**
  21848. * Modifies the mesh geometry according to a displacement map.
  21849. * 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.
  21850. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21851. * This method returns nothing.
  21852. * @param url is a string, the URL from the image file is to be downloaded.
  21853. * @param minHeight is the lower limit of the displacement.
  21854. * @param maxHeight is the upper limit of the displacement.
  21855. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  21856. * @param uvOffset is an optional vector2 used to offset UV.
  21857. * @param uvScale is an optional vector2 used to scale UV.
  21858. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  21859. * @returns the Mesh.
  21860. */
  21861. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21862. /**
  21863. * Modifies the mesh geometry according to a displacementMap buffer.
  21864. * 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.
  21865. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21866. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21867. * @param heightMapWidth is the width of the buffer image.
  21868. * @param heightMapHeight is the height of the buffer image.
  21869. * @param minHeight is the lower limit of the displacement.
  21870. * @param maxHeight is the upper limit of the displacement.
  21871. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  21872. * @param uvOffset is an optional vector2 used to offset UV.
  21873. * @param uvScale is an optional vector2 used to scale UV.
  21874. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  21875. * @returns the Mesh.
  21876. */
  21877. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21878. /**
  21879. * Modify the mesh to get a flat shading rendering.
  21880. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21881. * This method returns the Mesh.
  21882. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21883. */
  21884. convertToFlatShadedMesh(): Mesh;
  21885. /**
  21886. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21887. * In other words, more vertices, no more indices and a single bigger VBO.
  21888. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21889. * Returns the Mesh.
  21890. */
  21891. convertToUnIndexedMesh(): Mesh;
  21892. /**
  21893. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  21894. * This method returns the Mesh.
  21895. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21896. */
  21897. flipFaces(flipNormals?: boolean): Mesh;
  21898. /**
  21899. * Creates a new InstancedMesh object from the mesh model.
  21900. * An instance shares the same properties and the same material than its model.
  21901. * Please make sure to call mesh.makeGeometryUnique() if you are calling createInstance on a previously cloned mesh.
  21902. * Only these properties of each instance can then be set individually :
  21903. * - position
  21904. * - rotation
  21905. * - rotationQuaternion
  21906. * - setPivotMatrix
  21907. * - scaling
  21908. *
  21909. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21910. * Warning : this method is not supported for Line mesh and LineSystem
  21911. */
  21912. createInstance(name: string): InstancedMesh;
  21913. /**
  21914. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21915. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21916. * This method returns the Mesh.
  21917. */
  21918. synchronizeInstances(): Mesh;
  21919. /**
  21920. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21921. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21922. * This should be used together with the simplification to avoid disappearing triangles.
  21923. * Returns the Mesh.
  21924. * @param successCallback an optional success callback to be called after the optimization finished.
  21925. */
  21926. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21927. serialize(serializationObject: any): void;
  21928. /** @hidden */
  21929. _syncGeometryWithMorphTargetManager(): void;
  21930. /**
  21931. * Returns a new Mesh object parsed from the source provided.
  21932. * The parameter `parsedMesh` is the source.
  21933. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  21934. */
  21935. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21936. /**
  21937. * Creates a ribbon mesh.
  21938. * Please consider using the same method from the MeshBuilder class instead.
  21939. * 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.
  21940. *
  21941. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21942. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21943. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  21944. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  21945. * 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.
  21946. * 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.
  21947. * 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
  21948. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21949. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21950. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21951. */
  21952. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21953. /**
  21954. * Creates a plane polygonal mesh. By default, this is a disc.
  21955. * Please consider using the same method from the MeshBuilder class instead.
  21956. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  21957. * 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.
  21958. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21959. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21960. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21961. */
  21962. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21963. /**
  21964. * Creates a box mesh.
  21965. * Please consider using the same method from the MeshBuilder class instead.
  21966. * The parameter `size` sets the size (float) of each box side (default 1).
  21967. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21968. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21969. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21970. */
  21971. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21972. /**
  21973. * Creates a sphere mesh.
  21974. * Please consider using the same method from the MeshBuilder class instead.
  21975. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  21976. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  21977. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21978. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21979. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21980. */
  21981. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21982. /**
  21983. * Creates a cylinder or a cone mesh.
  21984. * Please consider using the same method from the MeshBuilder class instead.
  21985. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21986. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21987. * 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.
  21988. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21989. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21990. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21991. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21992. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21993. */
  21994. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21995. /**
  21996. * Creates a torus mesh.
  21997. * Please consider using the same method from the MeshBuilder class instead.
  21998. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  21999. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  22000. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  22001. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22002. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22003. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22004. */
  22005. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22006. /**
  22007. * Creates a torus knot mesh.
  22008. * Please consider using the same method from the MeshBuilder class instead.
  22009. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  22010. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  22011. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  22012. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  22013. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22014. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22015. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22016. */
  22017. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22018. /**
  22019. * Creates a line mesh.
  22020. * Please consider using the same method from the MeshBuilder class instead.
  22021. * 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.
  22022. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  22023. * The parameter `points` is an array successive Vector3.
  22024. * 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
  22025. * When updating an instance, remember that only point positions can change, not the number of points.
  22026. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22027. */
  22028. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22029. /**
  22030. * Creates a dashed line mesh.
  22031. * Please consider using the same method from the MeshBuilder class instead.
  22032. * 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.
  22033. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  22034. * The parameter `points` is an array successive Vector3.
  22035. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  22036. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  22037. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  22038. * 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
  22039. * When updating an instance, remember that only point positions can change, not the number of points.
  22040. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22041. */
  22042. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22043. /**
  22044. * Creates a polygon mesh.
  22045. * Please consider using the same method from the MeshBuilder class instead.
  22046. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22047. * 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.
  22048. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22049. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22050. * Remember you can only change the shape positions, not their number when updating a polygon.
  22051. */
  22052. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  22053. /**
  22054. * Creates an extruded polygon mesh, with depth in the Y direction.
  22055. * Please consider using the same method from the MeshBuilder class instead.
  22056. */
  22057. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  22058. /**
  22059. * Creates an extruded shape mesh.
  22060. * 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.
  22061. * Please consider using the same method from the MeshBuilder class instead.
  22062. *
  22063. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22064. * 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
  22065. * extruded along the Z axis.
  22066. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22067. * 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.
  22068. * The parameter `scale` (float, default 1) is the value to scale the shape.
  22069. * 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
  22070. * 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
  22071. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22072. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22073. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22074. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22075. */
  22076. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22077. /**
  22078. * Creates an custom extruded shape mesh.
  22079. * 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.
  22080. * Please consider using the same method from the MeshBuilder class instead.
  22081. *
  22082. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22083. * 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
  22084. * extruded along the Z axis.
  22085. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22086. * 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
  22087. * and the distance of this point from the begining of the path :
  22088. * ```javascript
  22089. * var rotationFunction = function(i, distance) {
  22090. * // do things
  22091. * return rotationValue; }
  22092. * ```
  22093. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  22094. * 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
  22095. * and the distance of this point from the begining of the path :
  22096. * ```javascript
  22097. * var scaleFunction = function(i, distance) {
  22098. * // do things
  22099. * return scaleValue;}
  22100. * ```
  22101. * It must returns a float value that will be the scale value applied to the shape on each path point.
  22102. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  22103. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  22104. * 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
  22105. * 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
  22106. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22107. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22108. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22109. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22110. */
  22111. 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;
  22112. /**
  22113. * Creates lathe mesh.
  22114. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22115. * Please consider using the same method from the MeshBuilder class instead.
  22116. * 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
  22117. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  22118. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  22119. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  22120. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22121. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22122. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22123. */
  22124. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22125. /**
  22126. * Creates a plane mesh.
  22127. * Please consider using the same method from the MeshBuilder class instead.
  22128. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  22129. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22130. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22131. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22132. */
  22133. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22134. /**
  22135. * Creates a ground mesh.
  22136. * Please consider using the same method from the MeshBuilder class instead.
  22137. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  22138. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  22139. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22140. */
  22141. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22142. /**
  22143. * Creates a tiled ground mesh.
  22144. * Please consider using the same method from the MeshBuilder class instead.
  22145. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  22146. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  22147. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  22148. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  22149. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  22150. * numbers of subdivisions on the ground width and height of each tile.
  22151. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22152. */
  22153. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22154. w: number;
  22155. h: number;
  22156. }, precision: {
  22157. w: number;
  22158. h: number;
  22159. }, scene: Scene, updatable?: boolean): Mesh;
  22160. /**
  22161. * Creates a ground mesh from a height map.
  22162. * tuto : http://doc.babylonjs.com/babylon101/height_map
  22163. * Please consider using the same method from the MeshBuilder class instead.
  22164. * @param url sets the URL of the height map image resource.
  22165. * @param width (positive float, default 10) set the ground width size.
  22166. * @param height (positive float, default 10) set the ground height size.
  22167. * @param subdivisions (positive integer, default 1) sets the number of subdivision per side.
  22168. * @param minHeight (float, default 0) is the minimum altitude on the ground.
  22169. * @param maxHeight (float, default 1) is the maximum altitude on the ground.
  22170. * @param onReady is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  22171. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible).
  22172. * This function is passed the newly built mesh :
  22173. * ```javascript
  22174. * function(mesh) { // do things
  22175. * return; }
  22176. * ```
  22177. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22178. */
  22179. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  22180. /**
  22181. * Creates a tube mesh.
  22182. * 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.
  22183. * Please consider using the same method from the MeshBuilder class instead.
  22184. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  22185. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  22186. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  22187. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  22188. * 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.
  22189. * It must return a radius value (positive float) :
  22190. * ```javascript
  22191. * var radiusFunction = function(i, distance) {
  22192. * // do things
  22193. * return radius; }
  22194. * ```
  22195. * 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
  22196. * 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
  22197. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22198. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22199. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22200. */
  22201. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22202. (i: number, distance: number): number;
  22203. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22204. /**
  22205. * Creates a polyhedron mesh.
  22206. * Please consider using the same method from the MeshBuilder class instead.
  22207. * 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
  22208. * to choose the wanted type.
  22209. * The parameter `size` (positive float, default 1) sets the polygon size.
  22210. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  22211. * 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`.
  22212. * 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
  22213. * 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)`).
  22214. * 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
  22215. * 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.
  22216. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22217. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22218. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22219. */
  22220. static CreatePolyhedron(name: string, options: {
  22221. type?: number;
  22222. size?: number;
  22223. sizeX?: number;
  22224. sizeY?: number;
  22225. sizeZ?: number;
  22226. custom?: any;
  22227. faceUV?: Vector4[];
  22228. faceColors?: Color4[];
  22229. updatable?: boolean;
  22230. sideOrientation?: number;
  22231. }, scene: Scene): Mesh;
  22232. /**
  22233. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  22234. * Please consider using the same method from the MeshBuilder class instead.
  22235. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  22236. * 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`).
  22237. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  22238. * 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.
  22239. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22240. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22241. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22242. */
  22243. static CreateIcoSphere(name: string, options: {
  22244. radius?: number;
  22245. flat?: boolean;
  22246. subdivisions?: number;
  22247. sideOrientation?: number;
  22248. updatable?: boolean;
  22249. }, scene: Scene): Mesh;
  22250. /**
  22251. * Creates a decal mesh.
  22252. * Please consider using the same method from the MeshBuilder class instead.
  22253. * 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.
  22254. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  22255. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  22256. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  22257. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  22258. */
  22259. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22260. /**
  22261. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22262. */
  22263. setPositionsForCPUSkinning(): Float32Array;
  22264. /**
  22265. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22266. */
  22267. setNormalsForCPUSkinning(): Float32Array;
  22268. /**
  22269. * Updates the vertex buffer by applying transformation from the bones.
  22270. * Returns the Mesh.
  22271. *
  22272. * @param {skeleton} skeleton to apply
  22273. */
  22274. applySkeleton(skeleton: Skeleton): Mesh;
  22275. /**
  22276. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  22277. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  22278. */
  22279. static MinMax(meshes: AbstractMesh[]): {
  22280. min: Vector3;
  22281. max: Vector3;
  22282. };
  22283. /**
  22284. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  22285. */
  22286. static Center(meshesOrMinMaxVector: {
  22287. min: Vector3;
  22288. max: Vector3;
  22289. } | AbstractMesh[]): Vector3;
  22290. /**
  22291. * Merge the array of meshes into a single mesh for performance reasons.
  22292. * @param meshes - The vertices source. They should all be of the same material. Entries can empty
  22293. * @param disposeSource - When true (default), dispose of the vertices from the source meshes
  22294. * @param allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  22295. * @param meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22296. * @param subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  22297. */
  22298. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  22299. }
  22300. }
  22301. declare module BABYLON {
  22302. /**
  22303. * Define an interface for all classes that will get and set the data on vertices
  22304. */
  22305. interface IGetSetVerticesData {
  22306. isVerticesDataPresent(kind: string): boolean;
  22307. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22308. /**
  22309. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22310. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  22311. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22312. * @returns the indices array or an empty array if the mesh has no geometry
  22313. */
  22314. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22315. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22316. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22317. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22318. }
  22319. /**
  22320. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22321. */
  22322. class VertexData {
  22323. /**
  22324. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22325. */
  22326. positions: Nullable<FloatArray>;
  22327. /**
  22328. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22329. */
  22330. normals: Nullable<FloatArray>;
  22331. /**
  22332. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22333. */
  22334. tangents: Nullable<FloatArray>;
  22335. /**
  22336. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22337. */
  22338. uvs: Nullable<FloatArray>;
  22339. /**
  22340. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22341. */
  22342. uvs2: Nullable<FloatArray>;
  22343. /**
  22344. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22345. */
  22346. uvs3: Nullable<FloatArray>;
  22347. /**
  22348. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22349. */
  22350. uvs4: Nullable<FloatArray>;
  22351. /**
  22352. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22353. */
  22354. uvs5: Nullable<FloatArray>;
  22355. /**
  22356. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22357. */
  22358. uvs6: Nullable<FloatArray>;
  22359. /**
  22360. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22361. */
  22362. colors: Nullable<FloatArray>;
  22363. /**
  22364. * 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).
  22365. */
  22366. matricesIndices: Nullable<FloatArray>;
  22367. /**
  22368. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22369. */
  22370. matricesWeights: Nullable<FloatArray>;
  22371. /**
  22372. * An array extending the number of possible indices
  22373. */
  22374. matricesIndicesExtra: Nullable<FloatArray>;
  22375. /**
  22376. * An array extending the number of possible weights when the number of indices is extended
  22377. */
  22378. matricesWeightsExtra: Nullable<FloatArray>;
  22379. /**
  22380. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22381. */
  22382. indices: Nullable<IndicesArray>;
  22383. /**
  22384. * Uses the passed data array to set the set the values for the specified kind of data
  22385. * @param data a linear array of floating numbers
  22386. * @param kind the type of data that is being set, eg positions, colors etc
  22387. */
  22388. set(data: FloatArray, kind: string): void;
  22389. /**
  22390. * Associates the vertexData to the passed Mesh.
  22391. * Sets it as updatable or not (default `false`)
  22392. * @param mesh the mesh the vertexData is applied to
  22393. * @param updatable when used and having the value true allows new data to update the vertexData
  22394. * @returns the VertexData
  22395. */
  22396. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22397. /**
  22398. * Associates the vertexData to the passed Geometry.
  22399. * Sets it as updatable or not (default `false`)
  22400. * @param geometry the geometry the vertexData is applied to
  22401. * @param updatable when used and having the value true allows new data to update the vertexData
  22402. * @returns VertexData
  22403. */
  22404. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22405. /**
  22406. * Updates the associated mesh
  22407. * @param mesh the mesh to be updated
  22408. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22409. * @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
  22410. * @returns VertexData
  22411. */
  22412. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22413. /**
  22414. * Updates the associated geometry
  22415. * @param geometry the geometry to be updated
  22416. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22417. * @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
  22418. * @returns VertexData.
  22419. */
  22420. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  22421. private _applyTo;
  22422. private _update;
  22423. /**
  22424. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22425. * @param matrix the transforming matrix
  22426. * @returns the VertexData
  22427. */
  22428. transform(matrix: Matrix): VertexData;
  22429. /**
  22430. * Merges the passed VertexData into the current one
  22431. * @param other the VertexData to be merged into the current one
  22432. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22433. * @returns the modified VertexData
  22434. */
  22435. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22436. private _mergeElement;
  22437. private _validate;
  22438. /**
  22439. * Serializes the VertexData
  22440. * @returns a serialized object
  22441. */
  22442. serialize(): any;
  22443. /**
  22444. * Extracts the vertexData from a mesh
  22445. * @param mesh the mesh from which to extract the VertexData
  22446. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22447. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22448. * @returns the object VertexData associated to the passed mesh
  22449. */
  22450. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22451. /**
  22452. * Extracts the vertexData from the geometry
  22453. * @param geometry the geometry from which to extract the VertexData
  22454. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22455. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22456. * @returns the object VertexData associated to the passed mesh
  22457. */
  22458. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22459. private static _ExtractFrom;
  22460. /**
  22461. * Creates the VertexData for a Ribbon
  22462. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22463. * * pathArray array of paths, each of which an array of successive Vector3
  22464. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22465. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22466. * * 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
  22467. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22468. * * 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)
  22469. * * 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)
  22470. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22471. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22472. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22473. * @returns the VertexData of the ribbon
  22474. */
  22475. static CreateRibbon(options: {
  22476. pathArray: Vector3[][];
  22477. closeArray?: boolean;
  22478. closePath?: boolean;
  22479. offset?: number;
  22480. sideOrientation?: number;
  22481. frontUVs?: Vector4;
  22482. backUVs?: Vector4;
  22483. invertUV?: boolean;
  22484. uvs?: Vector2[];
  22485. colors?: Color4[];
  22486. }): VertexData;
  22487. /**
  22488. * Creates the VertexData for a box
  22489. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22490. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22491. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22492. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22493. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22494. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22495. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22496. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22497. * * 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)
  22498. * * 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)
  22499. * @returns the VertexData of the box
  22500. */
  22501. static CreateBox(options: {
  22502. size?: number;
  22503. width?: number;
  22504. height?: number;
  22505. depth?: number;
  22506. faceUV?: Vector4[];
  22507. faceColors?: Color4[];
  22508. sideOrientation?: number;
  22509. frontUVs?: Vector4;
  22510. backUVs?: Vector4;
  22511. }): VertexData;
  22512. /**
  22513. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22514. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22515. * * segments sets the number of horizontal strips optional, default 32
  22516. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22517. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22518. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22519. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22520. * * 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
  22521. * * 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
  22522. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22523. * * 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)
  22524. * * 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)
  22525. * @returns the VertexData of the ellipsoid
  22526. */
  22527. static CreateSphere(options: {
  22528. segments?: number;
  22529. diameter?: number;
  22530. diameterX?: number;
  22531. diameterY?: number;
  22532. diameterZ?: number;
  22533. arc?: number;
  22534. slice?: number;
  22535. sideOrientation?: number;
  22536. frontUVs?: Vector4;
  22537. backUVs?: Vector4;
  22538. }): VertexData;
  22539. /**
  22540. * Creates the VertexData for a cylinder, cone or prism
  22541. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22542. * * height sets the height (y direction) of the cylinder, optional, default 2
  22543. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22544. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22545. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22546. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22547. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22548. * * 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
  22549. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22550. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22551. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22552. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22553. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22554. * * 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)
  22555. * * 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)
  22556. * @returns the VertexData of the cylinder, cone or prism
  22557. */
  22558. static CreateCylinder(options: {
  22559. height?: number;
  22560. diameterTop?: number;
  22561. diameterBottom?: number;
  22562. diameter?: number;
  22563. tessellation?: number;
  22564. subdivisions?: number;
  22565. arc?: number;
  22566. faceColors?: Color4[];
  22567. faceUV?: Vector4[];
  22568. hasRings?: boolean;
  22569. enclose?: boolean;
  22570. sideOrientation?: number;
  22571. frontUVs?: Vector4;
  22572. backUVs?: Vector4;
  22573. }): VertexData;
  22574. /**
  22575. * Creates the VertexData for a torus
  22576. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22577. * * diameter the diameter of the torus, optional default 1
  22578. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22579. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22580. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22581. * * 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)
  22582. * * 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)
  22583. * @returns the VertexData of the torus
  22584. */
  22585. static CreateTorus(options: {
  22586. diameter?: number;
  22587. thickness?: number;
  22588. tessellation?: number;
  22589. sideOrientation?: number;
  22590. frontUVs?: Vector4;
  22591. backUVs?: Vector4;
  22592. }): VertexData;
  22593. /**
  22594. * Creates the VertexData of the LineSystem
  22595. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22596. * - lines an array of lines, each line being an array of successive Vector3
  22597. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22598. * @returns the VertexData of the LineSystem
  22599. */
  22600. static CreateLineSystem(options: {
  22601. lines: Vector3[][];
  22602. colors?: Nullable<Color4[][]>;
  22603. }): VertexData;
  22604. /**
  22605. * Create the VertexData for a DashedLines
  22606. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22607. * - points an array successive Vector3
  22608. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22609. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22610. * - dashNb the intended total number of dashes, optional, default 200
  22611. * @returns the VertexData for the DashedLines
  22612. */
  22613. static CreateDashedLines(options: {
  22614. points: Vector3[];
  22615. dashSize?: number;
  22616. gapSize?: number;
  22617. dashNb?: number;
  22618. }): VertexData;
  22619. /**
  22620. * Creates the VertexData for a Ground
  22621. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22622. * - width the width (x direction) of the ground, optional, default 1
  22623. * - height the height (z direction) of the ground, optional, default 1
  22624. * - subdivisions the number of subdivisions per side, optional, default 1
  22625. * @returns the VertexData of the Ground
  22626. */
  22627. static CreateGround(options: {
  22628. width?: number;
  22629. height?: number;
  22630. subdivisions?: number;
  22631. subdivisionsX?: number;
  22632. subdivisionsY?: number;
  22633. }): VertexData;
  22634. /**
  22635. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22636. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22637. * * xmin the ground minimum X coordinate, optional, default -1
  22638. * * zmin the ground minimum Z coordinate, optional, default -1
  22639. * * xmax the ground maximum X coordinate, optional, default 1
  22640. * * zmax the ground maximum Z coordinate, optional, default 1
  22641. * * 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}
  22642. * * 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}
  22643. * @returns the VertexData of the TiledGround
  22644. */
  22645. static CreateTiledGround(options: {
  22646. xmin: number;
  22647. zmin: number;
  22648. xmax: number;
  22649. zmax: number;
  22650. subdivisions?: {
  22651. w: number;
  22652. h: number;
  22653. };
  22654. precision?: {
  22655. w: number;
  22656. h: number;
  22657. };
  22658. }): VertexData;
  22659. /**
  22660. * Creates the VertexData of the Ground designed from a heightmap
  22661. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22662. * * width the width (x direction) of the ground
  22663. * * height the height (z direction) of the ground
  22664. * * subdivisions the number of subdivisions per side
  22665. * * minHeight the minimum altitude on the ground, optional, default 0
  22666. * * maxHeight the maximum altitude on the ground, optional default 1
  22667. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22668. * * buffer the array holding the image color data
  22669. * * bufferWidth the width of image
  22670. * * bufferHeight the height of image
  22671. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22672. * @returns the VertexData of the Ground designed from a heightmap
  22673. */
  22674. static CreateGroundFromHeightMap(options: {
  22675. width: number;
  22676. height: number;
  22677. subdivisions: number;
  22678. minHeight: number;
  22679. maxHeight: number;
  22680. colorFilter: Color3;
  22681. buffer: Uint8Array;
  22682. bufferWidth: number;
  22683. bufferHeight: number;
  22684. alphaFilter: number;
  22685. }): VertexData;
  22686. /**
  22687. * Creates the VertexData for a Plane
  22688. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22689. * * size sets the width and height of the plane to the value of size, optional default 1
  22690. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22691. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22692. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22693. * * 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)
  22694. * * 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)
  22695. * @returns the VertexData of the box
  22696. */
  22697. static CreatePlane(options: {
  22698. size?: number;
  22699. width?: number;
  22700. height?: number;
  22701. sideOrientation?: number;
  22702. frontUVs?: Vector4;
  22703. backUVs?: Vector4;
  22704. }): VertexData;
  22705. /**
  22706. * Creates the VertexData of the Disc or regular Polygon
  22707. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22708. * * radius the radius of the disc, optional default 0.5
  22709. * * tessellation the number of polygon sides, optional, default 64
  22710. * * 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
  22711. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22712. * * 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)
  22713. * * 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)
  22714. * @returns the VertexData of the box
  22715. */
  22716. static CreateDisc(options: {
  22717. radius?: number;
  22718. tessellation?: number;
  22719. arc?: number;
  22720. sideOrientation?: number;
  22721. frontUVs?: Vector4;
  22722. backUVs?: Vector4;
  22723. }): VertexData;
  22724. /**
  22725. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22726. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22727. * @param polygon a mesh built from polygonTriangulation.build()
  22728. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22729. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22730. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22731. * @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)
  22732. * @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)
  22733. * @returns the VertexData of the Polygon
  22734. */
  22735. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22736. /**
  22737. * Creates the VertexData of the IcoSphere
  22738. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22739. * * radius the radius of the IcoSphere, optional default 1
  22740. * * radiusX allows stretching in the x direction, optional, default radius
  22741. * * radiusY allows stretching in the y direction, optional, default radius
  22742. * * radiusZ allows stretching in the z direction, optional, default radius
  22743. * * flat when true creates a flat shaded mesh, optional, default true
  22744. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22745. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22746. * * 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)
  22747. * * 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)
  22748. * @returns the VertexData of the IcoSphere
  22749. */
  22750. static CreateIcoSphere(options: {
  22751. radius?: number;
  22752. radiusX?: number;
  22753. radiusY?: number;
  22754. radiusZ?: number;
  22755. flat?: boolean;
  22756. subdivisions?: number;
  22757. sideOrientation?: number;
  22758. frontUVs?: Vector4;
  22759. backUVs?: Vector4;
  22760. }): VertexData;
  22761. /**
  22762. * Creates the VertexData for a Polyhedron
  22763. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22764. * * type provided types are:
  22765. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22766. * * 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)
  22767. * * size the size of the IcoSphere, optional default 1
  22768. * * sizeX allows stretching in the x direction, optional, default size
  22769. * * sizeY allows stretching in the y direction, optional, default size
  22770. * * sizeZ allows stretching in the z direction, optional, default size
  22771. * * 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
  22772. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22773. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22774. * * flat when true creates a flat shaded mesh, optional, default true
  22775. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22776. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22777. * * 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)
  22778. * * 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)
  22779. * @returns the VertexData of the Polyhedron
  22780. */
  22781. static CreatePolyhedron(options: {
  22782. type?: number;
  22783. size?: number;
  22784. sizeX?: number;
  22785. sizeY?: number;
  22786. sizeZ?: number;
  22787. custom?: any;
  22788. faceUV?: Vector4[];
  22789. faceColors?: Color4[];
  22790. flat?: boolean;
  22791. sideOrientation?: number;
  22792. frontUVs?: Vector4;
  22793. backUVs?: Vector4;
  22794. }): VertexData;
  22795. /**
  22796. * Creates the VertexData for a TorusKnot
  22797. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22798. * * radius the radius of the torus knot, optional, default 2
  22799. * * tube the thickness of the tube, optional, default 0.5
  22800. * * radialSegments the number of sides on each tube segments, optional, default 32
  22801. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22802. * * p the number of windings around the z axis, optional, default 2
  22803. * * q the number of windings around the x axis, optional, default 3
  22804. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22805. * * 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)
  22806. * * 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)
  22807. * @returns the VertexData of the Torus Knot
  22808. */
  22809. static CreateTorusKnot(options: {
  22810. radius?: number;
  22811. tube?: number;
  22812. radialSegments?: number;
  22813. tubularSegments?: number;
  22814. p?: number;
  22815. q?: number;
  22816. sideOrientation?: number;
  22817. frontUVs?: Vector4;
  22818. backUVs?: Vector4;
  22819. }): VertexData;
  22820. /**
  22821. * Compute normals for given positions and indices
  22822. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22823. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22824. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22825. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22826. * * facetNormals : optional array of facet normals (vector3)
  22827. * * facetPositions : optional array of facet positions (vector3)
  22828. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22829. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22830. * * bInfo : optional bounding info, required for facetPartitioning computation
  22831. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22832. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22833. * * useRightHandedSystem: optional boolean to for right handed system computation
  22834. * * depthSort : optional boolean to enable the facet depth sort computation
  22835. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22836. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22837. */
  22838. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22839. facetNormals?: any;
  22840. facetPositions?: any;
  22841. facetPartitioning?: any;
  22842. ratio?: number;
  22843. bInfo?: any;
  22844. bbSize?: Vector3;
  22845. subDiv?: any;
  22846. useRightHandedSystem?: boolean;
  22847. depthSort?: boolean;
  22848. distanceTo?: Vector3;
  22849. depthSortedFacets?: any;
  22850. }): void;
  22851. private static _ComputeSides;
  22852. /**
  22853. * Applies VertexData created from the imported parameters to the geometry
  22854. * @param parsedVertexData the parsed data from an imported file
  22855. * @param geometry the geometry to apply the VertexData to
  22856. */
  22857. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22858. }
  22859. }
  22860. declare module BABYLON {
  22861. /**
  22862. * Class containing static functions to help procedurally build meshes
  22863. */
  22864. class MeshBuilder {
  22865. private static updateSideOrientation;
  22866. /**
  22867. * Creates a box mesh
  22868. * * The parameter `size` sets the size (float) of each box side (default 1)
  22869. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  22870. * * 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)
  22871. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22873. * * 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
  22874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22875. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  22876. * @param name defines the name of the mesh
  22877. * @param options defines the options used to create the mesh
  22878. * @param scene defines the hosting scene
  22879. * @returns the box mesh
  22880. */
  22881. static CreateBox(name: string, options: {
  22882. size?: number;
  22883. width?: number;
  22884. height?: number;
  22885. depth?: number;
  22886. faceUV?: Vector4[];
  22887. faceColors?: Color4[];
  22888. sideOrientation?: number;
  22889. frontUVs?: Vector4;
  22890. backUVs?: Vector4;
  22891. updatable?: boolean;
  22892. }, scene?: Nullable<Scene>): Mesh;
  22893. /**
  22894. * Creates a sphere mesh
  22895. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  22896. * * 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`)
  22897. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  22898. * * 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
  22899. * * 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)
  22900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22901. * * 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
  22902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22903. * @param name defines the name of the mesh
  22904. * @param options defines the options used to create the mesh
  22905. * @param scene defines the hosting scene
  22906. * @returns the sphere mesh
  22907. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  22908. */
  22909. static CreateSphere(name: string, options: {
  22910. segments?: number;
  22911. diameter?: number;
  22912. diameterX?: number;
  22913. diameterY?: number;
  22914. diameterZ?: number;
  22915. arc?: number;
  22916. slice?: number;
  22917. sideOrientation?: number;
  22918. frontUVs?: Vector4;
  22919. backUVs?: Vector4;
  22920. updatable?: boolean;
  22921. }, scene: any): Mesh;
  22922. /**
  22923. * Creates a plane polygonal mesh. By default, this is a disc
  22924. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22925. * * 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
  22926. * * 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
  22927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22928. * * 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
  22929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22930. * @param name defines the name of the mesh
  22931. * @param options defines the options used to create the mesh
  22932. * @param scene defines the hosting scene
  22933. * @returns the plane polygonal mesh
  22934. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22935. */
  22936. static CreateDisc(name: string, options: {
  22937. radius?: number;
  22938. tessellation?: number;
  22939. arc?: number;
  22940. updatable?: boolean;
  22941. sideOrientation?: number;
  22942. frontUVs?: Vector4;
  22943. backUVs?: Vector4;
  22944. }, scene?: Nullable<Scene>): Mesh;
  22945. /**
  22946. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22947. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22948. * * 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`)
  22949. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22950. * * 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
  22951. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22952. * * 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
  22953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22954. * @param name defines the name of the mesh
  22955. * @param options defines the options used to create the mesh
  22956. * @param scene defines the hosting scene
  22957. * @returns the icosahedron mesh
  22958. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22959. */
  22960. static CreateIcoSphere(name: string, options: {
  22961. radius?: number;
  22962. radiusX?: number;
  22963. radiusY?: number;
  22964. radiusZ?: number;
  22965. flat?: boolean;
  22966. subdivisions?: number;
  22967. sideOrientation?: number;
  22968. frontUVs?: Vector4;
  22969. backUVs?: Vector4;
  22970. updatable?: boolean;
  22971. }, scene: Scene): Mesh;
  22972. /**
  22973. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22974. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  22975. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  22976. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  22977. * * 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
  22978. * * 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
  22979. * * 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
  22980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22981. * * 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
  22982. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22983. * * 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
  22984. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  22985. * * 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
  22986. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  22987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22988. * @param name defines the name of the mesh
  22989. * @param options defines the options used to create the mesh
  22990. * @param scene defines the hosting scene
  22991. * @returns the ribbon mesh
  22992. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  22993. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22994. */
  22995. static CreateRibbon(name: string, options: {
  22996. pathArray: Vector3[][];
  22997. closeArray?: boolean;
  22998. closePath?: boolean;
  22999. offset?: number;
  23000. updatable?: boolean;
  23001. sideOrientation?: number;
  23002. frontUVs?: Vector4;
  23003. backUVs?: Vector4;
  23004. instance?: Mesh;
  23005. invertUV?: boolean;
  23006. uvs?: Vector2[];
  23007. colors?: Color4[];
  23008. }, scene?: Nullable<Scene>): Mesh;
  23009. /**
  23010. * Creates a cylinder or a cone mesh
  23011. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  23012. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  23013. * * 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.
  23014. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  23015. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  23016. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  23017. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  23018. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  23019. * * 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).
  23020. * * 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
  23021. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  23022. * * 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
  23023. * * 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.
  23024. * * If `enclose` is false, a ring surface is one element.
  23025. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  23026. * * 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
  23027. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23028. * * 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
  23029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23030. * @param name defines the name of the mesh
  23031. * @param options defines the options used to create the mesh
  23032. * @param scene defines the hosting scene
  23033. * @returns the cylinder mesh
  23034. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  23035. */
  23036. static CreateCylinder(name: string, options: {
  23037. height?: number;
  23038. diameterTop?: number;
  23039. diameterBottom?: number;
  23040. diameter?: number;
  23041. tessellation?: number;
  23042. subdivisions?: number;
  23043. arc?: number;
  23044. faceColors?: Color4[];
  23045. faceUV?: Vector4[];
  23046. updatable?: boolean;
  23047. hasRings?: boolean;
  23048. enclose?: boolean;
  23049. sideOrientation?: number;
  23050. frontUVs?: Vector4;
  23051. backUVs?: Vector4;
  23052. }, scene: any): Mesh;
  23053. /**
  23054. * Creates a torus mesh
  23055. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  23056. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  23057. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  23058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23059. * * 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
  23060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23061. * @param name defines the name of the mesh
  23062. * @param options defines the options used to create the mesh
  23063. * @param scene defines the hosting scene
  23064. * @returns the torus mesh
  23065. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  23066. */
  23067. static CreateTorus(name: string, options: {
  23068. diameter?: number;
  23069. thickness?: number;
  23070. tessellation?: number;
  23071. updatable?: boolean;
  23072. sideOrientation?: number;
  23073. frontUVs?: Vector4;
  23074. backUVs?: Vector4;
  23075. }, scene: any): Mesh;
  23076. /**
  23077. * Creates a torus knot mesh
  23078. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  23079. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  23080. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  23081. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  23082. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23083. * * 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
  23084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23085. * @param name defines the name of the mesh
  23086. * @param options defines the options used to create the mesh
  23087. * @param scene defines the hosting scene
  23088. * @returns the torus knot mesh
  23089. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  23090. */
  23091. static CreateTorusKnot(name: string, options: {
  23092. radius?: number;
  23093. tube?: number;
  23094. radialSegments?: number;
  23095. tubularSegments?: number;
  23096. p?: number;
  23097. q?: number;
  23098. updatable?: boolean;
  23099. sideOrientation?: number;
  23100. frontUVs?: Vector4;
  23101. backUVs?: Vector4;
  23102. }, scene: any): Mesh;
  23103. /**
  23104. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  23105. * * 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
  23106. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  23107. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  23108. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  23109. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  23110. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  23111. * * 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
  23112. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  23113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23114. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  23115. * @param name defines the name of the new line system
  23116. * @param options defines the options used to create the line system
  23117. * @param scene defines the hosting scene
  23118. * @returns a new line system mesh
  23119. */
  23120. static CreateLineSystem(name: string, options: {
  23121. lines: Vector3[][];
  23122. updatable?: boolean;
  23123. instance?: Nullable<LinesMesh>;
  23124. colors?: Nullable<Color4[][]>;
  23125. useVertexAlpha?: boolean;
  23126. }, scene: Nullable<Scene>): LinesMesh;
  23127. /**
  23128. * Creates a line mesh
  23129. * 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
  23130. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23131. * * The parameter `points` is an array successive Vector3
  23132. * * 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
  23133. * * The optional parameter `colors` is an array of successive Color4, one per line point
  23134. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  23135. * * When updating an instance, remember that only point positions can change, not the number of points
  23136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23137. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  23138. * @param name defines the name of the new line system
  23139. * @param options defines the options used to create the line system
  23140. * @param scene defines the hosting scene
  23141. * @returns a new line mesh
  23142. */
  23143. static CreateLines(name: string, options: {
  23144. points: Vector3[];
  23145. updatable?: boolean;
  23146. instance?: Nullable<LinesMesh>;
  23147. colors?: Color4[];
  23148. useVertexAlpha?: boolean;
  23149. }, scene?: Nullable<Scene>): LinesMesh;
  23150. /**
  23151. * Creates a dashed line mesh
  23152. * * 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
  23153. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23154. * * The parameter `points` is an array successive Vector3
  23155. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  23156. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  23157. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  23158. * * 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
  23159. * * When updating an instance, remember that only point positions can change, not the number of points
  23160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23161. * @param name defines the name of the mesh
  23162. * @param options defines the options used to create the mesh
  23163. * @param scene defines the hosting scene
  23164. * @returns the dashed line mesh
  23165. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  23166. */
  23167. static CreateDashedLines(name: string, options: {
  23168. points: Vector3[];
  23169. dashSize?: number;
  23170. gapSize?: number;
  23171. dashNb?: number;
  23172. updatable?: boolean;
  23173. instance?: LinesMesh;
  23174. }, scene?: Nullable<Scene>): LinesMesh;
  23175. /**
  23176. * 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.
  23177. * * 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.
  23178. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23179. * * 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.
  23180. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  23181. * * 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
  23182. * * 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
  23183. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  23184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23185. * * 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
  23186. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  23187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23188. * @param name defines the name of the mesh
  23189. * @param options defines the options used to create the mesh
  23190. * @param scene defines the hosting scene
  23191. * @returns the extruded shape mesh
  23192. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23193. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23194. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23195. */
  23196. static ExtrudeShape(name: string, options: {
  23197. shape: Vector3[];
  23198. path: Vector3[];
  23199. scale?: number;
  23200. rotation?: number;
  23201. cap?: number;
  23202. updatable?: boolean;
  23203. sideOrientation?: number;
  23204. frontUVs?: Vector4;
  23205. backUVs?: Vector4;
  23206. instance?: Mesh;
  23207. invertUV?: boolean;
  23208. }, scene?: Nullable<Scene>): Mesh;
  23209. /**
  23210. * Creates an custom extruded shape mesh.
  23211. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  23212. * * 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.
  23213. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23214. * * 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
  23215. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  23216. * * 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
  23217. * * It must returns a float value that will be the scale value applied to the shape on each path point
  23218. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  23219. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  23220. * * 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
  23221. * * 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
  23222. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  23223. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23224. * * 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
  23225. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23227. * @param name defines the name of the mesh
  23228. * @param options defines the options used to create the mesh
  23229. * @param scene defines the hosting scene
  23230. * @returns the custom extruded shape mesh
  23231. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  23232. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23233. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23234. */
  23235. static ExtrudeShapeCustom(name: string, options: {
  23236. shape: Vector3[];
  23237. path: Vector3[];
  23238. scaleFunction?: any;
  23239. rotationFunction?: any;
  23240. ribbonCloseArray?: boolean;
  23241. ribbonClosePath?: boolean;
  23242. cap?: number;
  23243. updatable?: boolean;
  23244. sideOrientation?: number;
  23245. frontUVs?: Vector4;
  23246. backUVs?: Vector4;
  23247. instance?: Mesh;
  23248. invertUV?: boolean;
  23249. }, scene: Scene): Mesh;
  23250. /**
  23251. * Creates lathe mesh.
  23252. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  23253. * * 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
  23254. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  23255. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  23256. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  23257. * * 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
  23258. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  23259. * * 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
  23260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23261. * * 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
  23262. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23264. * @param name defines the name of the mesh
  23265. * @param options defines the options used to create the mesh
  23266. * @param scene defines the hosting scene
  23267. * @returns the lathe mesh
  23268. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  23269. */
  23270. static CreateLathe(name: string, options: {
  23271. shape: Vector3[];
  23272. radius?: number;
  23273. tessellation?: number;
  23274. clip?: number;
  23275. arc?: number;
  23276. closed?: boolean;
  23277. updatable?: boolean;
  23278. sideOrientation?: number;
  23279. frontUVs?: Vector4;
  23280. backUVs?: Vector4;
  23281. cap?: number;
  23282. invertUV?: boolean;
  23283. }, scene: Scene): Mesh;
  23284. /**
  23285. * Creates a plane mesh
  23286. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  23287. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  23288. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  23289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23290. * * 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
  23291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23292. * @param name defines the name of the mesh
  23293. * @param options defines the options used to create the mesh
  23294. * @param scene defines the hosting scene
  23295. * @returns the plane mesh
  23296. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23297. */
  23298. static CreatePlane(name: string, options: {
  23299. size?: number;
  23300. width?: number;
  23301. height?: number;
  23302. sideOrientation?: number;
  23303. frontUVs?: Vector4;
  23304. backUVs?: Vector4;
  23305. updatable?: boolean;
  23306. sourcePlane?: Plane;
  23307. }, scene: Scene): Mesh;
  23308. /**
  23309. * Creates a ground mesh
  23310. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  23311. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  23312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23313. * @param name defines the name of the mesh
  23314. * @param options defines the options used to create the mesh
  23315. * @param scene defines the hosting scene
  23316. * @returns the ground mesh
  23317. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  23318. */
  23319. static CreateGround(name: string, options: {
  23320. width?: number;
  23321. height?: number;
  23322. subdivisions?: number;
  23323. subdivisionsX?: number;
  23324. subdivisionsY?: number;
  23325. updatable?: boolean;
  23326. }, scene: any): Mesh;
  23327. /**
  23328. * Creates a tiled ground mesh
  23329. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  23330. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  23331. * * 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
  23332. * * 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
  23333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23334. * @param name defines the name of the mesh
  23335. * @param options defines the options used to create the mesh
  23336. * @param scene defines the hosting scene
  23337. * @returns the tiled ground mesh
  23338. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  23339. */
  23340. static CreateTiledGround(name: string, options: {
  23341. xmin: number;
  23342. zmin: number;
  23343. xmax: number;
  23344. zmax: number;
  23345. subdivisions?: {
  23346. w: number;
  23347. h: number;
  23348. };
  23349. precision?: {
  23350. w: number;
  23351. h: number;
  23352. };
  23353. updatable?: boolean;
  23354. }, scene: Scene): Mesh;
  23355. /**
  23356. * Creates a ground mesh from a height map
  23357. * * The parameter `url` sets the URL of the height map image resource.
  23358. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  23359. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  23360. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  23361. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  23362. * * 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.
  23363. * * 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).
  23364. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  23365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23366. * @param name defines the name of the mesh
  23367. * @param url defines the url to the height map
  23368. * @param options defines the options used to create the mesh
  23369. * @param scene defines the hosting scene
  23370. * @returns the ground mesh
  23371. * @see http://doc.babylonjs.com/babylon101/height_map
  23372. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  23373. */
  23374. static CreateGroundFromHeightMap(name: string, url: string, options: {
  23375. width?: number;
  23376. height?: number;
  23377. subdivisions?: number;
  23378. minHeight?: number;
  23379. maxHeight?: number;
  23380. colorFilter?: Color3;
  23381. alphaFilter?: number;
  23382. updatable?: boolean;
  23383. onReady?: (mesh: GroundMesh) => void;
  23384. }, scene: Scene): GroundMesh;
  23385. /**
  23386. * Creates a polygon mesh
  23387. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  23388. * * 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
  23389. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23391. * * 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)
  23392. * * Remember you can only change the shape positions, not their number when updating a polygon
  23393. * @param name defines the name of the mesh
  23394. * @param options defines the options used to create the mesh
  23395. * @param scene defines the hosting scene
  23396. * @returns the polygon mesh
  23397. */
  23398. static CreatePolygon(name: string, options: {
  23399. shape: Vector3[];
  23400. holes?: Vector3[][];
  23401. depth?: number;
  23402. faceUV?: Vector4[];
  23403. faceColors?: Color4[];
  23404. updatable?: boolean;
  23405. sideOrientation?: number;
  23406. frontUVs?: Vector4;
  23407. backUVs?: Vector4;
  23408. }, scene: Scene): Mesh;
  23409. /**
  23410. * Creates an extruded polygon mesh, with depth in the Y direction.
  23411. * * 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)
  23412. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  23413. * @param name defines the name of the mesh
  23414. * @param options defines the options used to create the mesh
  23415. * @param scene defines the hosting scene
  23416. * @returns the polygon mesh
  23417. */
  23418. static ExtrudePolygon(name: string, options: {
  23419. shape: Vector3[];
  23420. holes?: Vector3[][];
  23421. depth?: number;
  23422. faceUV?: Vector4[];
  23423. faceColors?: Color4[];
  23424. updatable?: boolean;
  23425. sideOrientation?: number;
  23426. frontUVs?: Vector4;
  23427. backUVs?: Vector4;
  23428. }, scene: Scene): Mesh;
  23429. /**
  23430. * Creates a tube mesh.
  23431. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23432. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  23433. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  23434. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  23435. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  23436. * * 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)
  23437. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  23438. * * 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
  23439. * * 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
  23440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23441. * * 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
  23442. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23444. * @param name defines the name of the mesh
  23445. * @param options defines the options used to create the mesh
  23446. * @param scene defines the hosting scene
  23447. * @returns the tube mesh
  23448. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  23449. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  23450. */
  23451. static CreateTube(name: string, options: {
  23452. path: Vector3[];
  23453. radius?: number;
  23454. tessellation?: number;
  23455. radiusFunction?: {
  23456. (i: number, distance: number): number;
  23457. };
  23458. cap?: number;
  23459. arc?: number;
  23460. updatable?: boolean;
  23461. sideOrientation?: number;
  23462. frontUVs?: Vector4;
  23463. backUVs?: Vector4;
  23464. instance?: Mesh;
  23465. invertUV?: boolean;
  23466. }, scene: Scene): Mesh;
  23467. /**
  23468. * Creates a polyhedron mesh
  23469. * * 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
  23470. * * The parameter `size` (positive float, default 1) sets the polygon size
  23471. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  23472. * * 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`
  23473. * * 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
  23474. * * 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)`)
  23475. * * 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
  23476. * * 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
  23477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23478. * * 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
  23479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23480. * @param name defines the name of the mesh
  23481. * @param options defines the options used to create the mesh
  23482. * @param scene defines the hosting scene
  23483. * @returns the polyhedron mesh
  23484. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  23485. */
  23486. static CreatePolyhedron(name: string, options: {
  23487. type?: number;
  23488. size?: number;
  23489. sizeX?: number;
  23490. sizeY?: number;
  23491. sizeZ?: number;
  23492. custom?: any;
  23493. faceUV?: Vector4[];
  23494. faceColors?: Color4[];
  23495. flat?: boolean;
  23496. updatable?: boolean;
  23497. sideOrientation?: number;
  23498. frontUVs?: Vector4;
  23499. backUVs?: Vector4;
  23500. }, scene: Scene): Mesh;
  23501. /**
  23502. * Creates a decal mesh.
  23503. * 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
  23504. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  23505. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  23506. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  23507. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  23508. * @param name defines the name of the mesh
  23509. * @param sourceMesh defines the mesh where the decal must be applied
  23510. * @param options defines the options used to create the mesh
  23511. * @param scene defines the hosting scene
  23512. * @returns the decal mesh
  23513. * @see http://doc.babylonjs.com/how_to/decals
  23514. */
  23515. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  23516. position?: Vector3;
  23517. normal?: Vector3;
  23518. size?: Vector3;
  23519. angle?: number;
  23520. }): Mesh;
  23521. private static _ExtrudeShapeGeneric;
  23522. }
  23523. }
  23524. declare module BABYLON {
  23525. class MeshLODLevel {
  23526. distance: number;
  23527. mesh: Nullable<Mesh>;
  23528. constructor(distance: number, mesh: Nullable<Mesh>);
  23529. }
  23530. }
  23531. declare module BABYLON {
  23532. /**
  23533. * A simplifier interface for future simplification implementations.
  23534. */
  23535. interface ISimplifier {
  23536. /**
  23537. * Simplification of a given mesh according to the given settings.
  23538. * Since this requires computation, it is assumed that the function runs async.
  23539. * @param settings The settings of the simplification, including quality and distance
  23540. * @param successCallback A callback that will be called after the mesh was simplified.
  23541. * @param errorCallback in case of an error, this callback will be called. optional.
  23542. */
  23543. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  23544. }
  23545. /**
  23546. * Expected simplification settings.
  23547. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  23548. */
  23549. interface ISimplificationSettings {
  23550. quality: number;
  23551. distance: number;
  23552. optimizeMesh?: boolean;
  23553. }
  23554. class SimplificationSettings implements ISimplificationSettings {
  23555. quality: number;
  23556. distance: number;
  23557. optimizeMesh?: boolean | undefined;
  23558. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  23559. }
  23560. interface ISimplificationTask {
  23561. settings: Array<ISimplificationSettings>;
  23562. simplificationType: SimplificationType;
  23563. mesh: Mesh;
  23564. successCallback?: () => void;
  23565. parallelProcessing: boolean;
  23566. }
  23567. class SimplificationQueue {
  23568. private _simplificationArray;
  23569. running: boolean;
  23570. constructor();
  23571. addTask(task: ISimplificationTask): void;
  23572. executeNext(): void;
  23573. runSimplification(task: ISimplificationTask): void;
  23574. private getSimplifier;
  23575. }
  23576. /**
  23577. * The implemented types of simplification
  23578. * At the moment only Quadratic Error Decimation is implemented
  23579. */
  23580. enum SimplificationType {
  23581. /** Quadratic error decimation */
  23582. QUADRATIC = 0
  23583. }
  23584. class DecimationTriangle {
  23585. vertices: Array<DecimationVertex>;
  23586. normal: Vector3;
  23587. error: Array<number>;
  23588. deleted: boolean;
  23589. isDirty: boolean;
  23590. borderFactor: number;
  23591. deletePending: boolean;
  23592. originalOffset: number;
  23593. constructor(vertices: Array<DecimationVertex>);
  23594. }
  23595. class DecimationVertex {
  23596. position: Vector3;
  23597. id: number;
  23598. q: QuadraticMatrix;
  23599. isBorder: boolean;
  23600. triangleStart: number;
  23601. triangleCount: number;
  23602. originalOffsets: Array<number>;
  23603. constructor(position: Vector3, id: number);
  23604. updatePosition(newPosition: Vector3): void;
  23605. }
  23606. class QuadraticMatrix {
  23607. data: Array<number>;
  23608. constructor(data?: Array<number>);
  23609. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  23610. addInPlace(matrix: QuadraticMatrix): void;
  23611. addArrayInPlace(data: Array<number>): void;
  23612. add(matrix: QuadraticMatrix): QuadraticMatrix;
  23613. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  23614. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  23615. }
  23616. class Reference {
  23617. vertexId: number;
  23618. triangleId: number;
  23619. constructor(vertexId: number, triangleId: number);
  23620. }
  23621. /**
  23622. * An implementation of the Quadratic Error simplification algorithm.
  23623. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  23624. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  23625. * @author RaananW
  23626. */
  23627. class QuadraticErrorSimplification implements ISimplifier {
  23628. private _mesh;
  23629. private triangles;
  23630. private vertices;
  23631. private references;
  23632. private _reconstructedMesh;
  23633. syncIterations: number;
  23634. aggressiveness: number;
  23635. decimationIterations: number;
  23636. boundingBoxEpsilon: number;
  23637. constructor(_mesh: Mesh);
  23638. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  23639. private runDecimation;
  23640. private initWithMesh;
  23641. private init;
  23642. private reconstructMesh;
  23643. private initDecimatedMesh;
  23644. private isFlipped;
  23645. private updateTriangles;
  23646. private identifyBorder;
  23647. private updateMesh;
  23648. private vertexError;
  23649. private calculateError;
  23650. }
  23651. }
  23652. declare module BABYLON {
  23653. interface Scene {
  23654. /** @hidden (Backing field) */
  23655. _simplificationQueue: SimplificationQueue;
  23656. /**
  23657. * Gets or sets the simplification queue attached to the scene
  23658. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  23659. */
  23660. simplificationQueue: SimplificationQueue;
  23661. }
  23662. interface Mesh {
  23663. /**
  23664. * Simplify the mesh according to the given array of settings.
  23665. * Function will return immediately and will simplify async. It returns the Mesh.
  23666. * @param settings a collection of simplification settings.
  23667. * @param parallelProcessing should all levels calculate parallel or one after the other.
  23668. * @param type the type of simplification to run.
  23669. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  23670. */
  23671. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  23672. }
  23673. /**
  23674. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  23675. * created in a scene
  23676. */
  23677. class SimplicationQueueSceneComponent implements ISceneComponent {
  23678. /**
  23679. * The component name helpfull to identify the component in the list of scene components.
  23680. */
  23681. readonly name: string;
  23682. /**
  23683. * The scene the component belongs to.
  23684. */
  23685. scene: Scene;
  23686. /**
  23687. * Creates a new instance of the component for the given scene
  23688. * @param scene Defines the scene to register the component in
  23689. */
  23690. constructor(scene: Scene);
  23691. /**
  23692. * Registers the component in a given scene
  23693. */
  23694. register(): void;
  23695. /**
  23696. * Rebuilds the elements related to this component in case of
  23697. * context lost for instance.
  23698. */
  23699. rebuild(): void;
  23700. /**
  23701. * Disposes the component and the associated ressources
  23702. */
  23703. dispose(): void;
  23704. private _beforeCameraUpdate;
  23705. }
  23706. }
  23707. declare module BABYLON {
  23708. class Polygon {
  23709. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  23710. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  23711. static Parse(input: string): Vector2[];
  23712. static StartingAt(x: number, y: number): Path2;
  23713. }
  23714. class PolygonMeshBuilder {
  23715. private _points;
  23716. private _outlinepoints;
  23717. private _holes;
  23718. private _name;
  23719. private _scene;
  23720. private _epoints;
  23721. private _eholes;
  23722. private _addToepoint;
  23723. constructor(name: string, contours: Path2, scene: Scene);
  23724. constructor(name: string, contours: Vector2[], scene: Scene);
  23725. addHole(hole: Vector2[]): PolygonMeshBuilder;
  23726. build(updatable?: boolean, depth?: number): Mesh;
  23727. private addSide;
  23728. }
  23729. }
  23730. declare module BABYLON {
  23731. class BaseSubMesh {
  23732. /** @hidden */
  23733. _materialDefines: Nullable<MaterialDefines>;
  23734. /** @hidden */
  23735. _materialEffect: Nullable<Effect>;
  23736. readonly effect: Nullable<Effect>;
  23737. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23738. }
  23739. class SubMesh extends BaseSubMesh implements ICullable {
  23740. materialIndex: number;
  23741. verticesStart: number;
  23742. verticesCount: number;
  23743. indexStart: number;
  23744. indexCount: number;
  23745. linesIndexCount: number;
  23746. private _mesh;
  23747. private _renderingMesh;
  23748. private _boundingInfo;
  23749. private _linesIndexBuffer;
  23750. /** @hidden */
  23751. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23752. /** @hidden */
  23753. _trianglePlanes: Plane[];
  23754. /** @hidden */
  23755. _lastColliderTransformMatrix: Matrix;
  23756. /** @hidden */
  23757. _renderId: number;
  23758. /** @hidden */
  23759. _alphaIndex: number;
  23760. /** @hidden */
  23761. _distanceToCamera: number;
  23762. /** @hidden */
  23763. _id: number;
  23764. private _currentMaterial;
  23765. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23766. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23767. readonly IsGlobal: boolean;
  23768. /**
  23769. * Returns the submesh BoudingInfo object.
  23770. */
  23771. getBoundingInfo(): BoundingInfo;
  23772. /**
  23773. * Sets the submesh BoundingInfo.
  23774. * Return the SubMesh.
  23775. */
  23776. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23777. /**
  23778. * Returns the mesh of the current submesh.
  23779. */
  23780. getMesh(): AbstractMesh;
  23781. /**
  23782. * Returns the rendering mesh of the submesh.
  23783. */
  23784. getRenderingMesh(): Mesh;
  23785. /**
  23786. * Returns the submesh material.
  23787. */
  23788. getMaterial(): Nullable<Material>;
  23789. /**
  23790. * Sets a new updated BoundingInfo object to the submesh.
  23791. * Returns the SubMesh.
  23792. */
  23793. refreshBoundingInfo(): SubMesh;
  23794. /** @hidden */
  23795. _checkCollision(collider: Collider): boolean;
  23796. /**
  23797. * Updates the submesh BoundingInfo.
  23798. * Returns the Submesh.
  23799. */
  23800. updateBoundingInfo(world: Matrix): SubMesh;
  23801. /**
  23802. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23803. * Boolean returned.
  23804. */
  23805. isInFrustum(frustumPlanes: Plane[]): boolean;
  23806. /**
  23807. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  23808. * Boolean returned.
  23809. */
  23810. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23811. /**
  23812. * Renders the submesh.
  23813. * Returns it.
  23814. */
  23815. render(enableAlphaMode: boolean): SubMesh;
  23816. /**
  23817. * Returns a new Index Buffer.
  23818. * Type returned : WebGLBuffer.
  23819. */
  23820. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  23821. /**
  23822. * True is the passed Ray intersects the submesh bounding box.
  23823. * Boolean returned.
  23824. */
  23825. canIntersects(ray: Ray): boolean;
  23826. /**
  23827. * Returns an object IntersectionInfo.
  23828. */
  23829. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  23830. /** @hidden */
  23831. _rebuild(): void;
  23832. /**
  23833. * Creates a new Submesh from the passed Mesh.
  23834. */
  23835. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23836. /**
  23837. * Disposes the Submesh.
  23838. * Returns nothing.
  23839. */
  23840. dispose(): void;
  23841. /**
  23842. * Creates a new Submesh from the passed parameters :
  23843. * - materialIndex (integer) : the index of the main mesh material.
  23844. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  23845. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  23846. * - mesh (Mesh) : the main mesh to create the submesh from.
  23847. * - renderingMesh (optional Mesh) : rendering mesh.
  23848. */
  23849. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23850. }
  23851. }
  23852. declare module BABYLON {
  23853. class TransformNode extends Node {
  23854. static BILLBOARDMODE_NONE: number;
  23855. static BILLBOARDMODE_X: number;
  23856. static BILLBOARDMODE_Y: number;
  23857. static BILLBOARDMODE_Z: number;
  23858. static BILLBOARDMODE_ALL: number;
  23859. private _forward;
  23860. private _forwardInverted;
  23861. private _up;
  23862. private _right;
  23863. private _rightInverted;
  23864. private _position;
  23865. private _rotation;
  23866. private _rotationQuaternion;
  23867. protected _scaling: Vector3;
  23868. protected _isDirty: boolean;
  23869. private _transformToBoneReferal;
  23870. /**
  23871. * Set the billboard mode. Default is 0.
  23872. *
  23873. * | Value | Type | Description |
  23874. * | --- | --- | --- |
  23875. * | 0 | BILLBOARDMODE_NONE | |
  23876. * | 1 | BILLBOARDMODE_X | |
  23877. * | 2 | BILLBOARDMODE_Y | |
  23878. * | 4 | BILLBOARDMODE_Z | |
  23879. * | 7 | BILLBOARDMODE_ALL | |
  23880. *
  23881. */
  23882. billboardMode: number;
  23883. scalingDeterminant: number;
  23884. infiniteDistance: boolean;
  23885. /**
  23886. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  23887. * By default the system will update normals to compensate
  23888. */
  23889. ignoreNonUniformScaling: boolean;
  23890. /** @hidden */
  23891. _poseMatrix: Matrix;
  23892. private _localWorld;
  23893. private _absolutePosition;
  23894. private _pivotMatrix;
  23895. private _pivotMatrixInverse;
  23896. private _postMultiplyPivotMatrix;
  23897. protected _isWorldMatrixFrozen: boolean;
  23898. /**
  23899. * An event triggered after the world matrix is updated
  23900. */
  23901. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  23902. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  23903. /**
  23904. * Gets a string identifying the name of the class
  23905. * @returns "TransformNode" string
  23906. */
  23907. getClassName(): string;
  23908. /**
  23909. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  23910. */
  23911. position: Vector3;
  23912. /**
  23913. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  23914. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  23915. */
  23916. rotation: Vector3;
  23917. /**
  23918. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  23919. */
  23920. scaling: Vector3;
  23921. /**
  23922. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  23923. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  23924. */
  23925. rotationQuaternion: Nullable<Quaternion>;
  23926. /**
  23927. * The forward direction of that transform in world space.
  23928. */
  23929. readonly forward: Vector3;
  23930. /**
  23931. * The up direction of that transform in world space.
  23932. */
  23933. readonly up: Vector3;
  23934. /**
  23935. * The right direction of that transform in world space.
  23936. */
  23937. readonly right: Vector3;
  23938. /**
  23939. * Copies the parameter passed Matrix into the mesh Pose matrix.
  23940. * Returns the TransformNode.
  23941. */
  23942. updatePoseMatrix(matrix: Matrix): TransformNode;
  23943. /**
  23944. * Returns the mesh Pose matrix.
  23945. * Returned object : Matrix
  23946. */
  23947. getPoseMatrix(): Matrix;
  23948. /** @hidden */
  23949. _isSynchronized(): boolean;
  23950. /** @hidden */
  23951. _initCache(): void;
  23952. markAsDirty(property: string): TransformNode;
  23953. /**
  23954. * Returns the current mesh absolute position.
  23955. * Returns a Vector3.
  23956. */
  23957. readonly absolutePosition: Vector3;
  23958. /**
  23959. * Sets a new matrix to apply before all other transformation
  23960. * @param matrix defines the transform matrix
  23961. * @returns the current TransformNode
  23962. */
  23963. setPreTransformMatrix(matrix: Matrix): TransformNode;
  23964. /**
  23965. * Sets a new pivot matrix to the current node
  23966. * @param matrix defines the new pivot matrix to use
  23967. * @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
  23968. * @returns the current TransformNode
  23969. */
  23970. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  23971. /**
  23972. * Returns the mesh pivot matrix.
  23973. * Default : Identity.
  23974. * A Matrix is returned.
  23975. */
  23976. getPivotMatrix(): Matrix;
  23977. /**
  23978. * Prevents the World matrix to be computed any longer.
  23979. * Returns the TransformNode.
  23980. */
  23981. freezeWorldMatrix(): TransformNode;
  23982. /**
  23983. * Allows back the World matrix computation.
  23984. * Returns the TransformNode.
  23985. */
  23986. unfreezeWorldMatrix(): this;
  23987. /**
  23988. * True if the World matrix has been frozen.
  23989. * Returns a boolean.
  23990. */
  23991. readonly isWorldMatrixFrozen: boolean;
  23992. /**
  23993. * Retuns the mesh absolute position in the World.
  23994. * Returns a Vector3.
  23995. */
  23996. getAbsolutePosition(): Vector3;
  23997. /**
  23998. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  23999. * Returns the TransformNode.
  24000. */
  24001. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24002. /**
  24003. * Sets the mesh position in its local space.
  24004. * Returns the TransformNode.
  24005. */
  24006. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  24007. /**
  24008. * Returns the mesh position in the local space from the current World matrix values.
  24009. * Returns a new Vector3.
  24010. */
  24011. getPositionExpressedInLocalSpace(): Vector3;
  24012. /**
  24013. * Translates the mesh along the passed Vector3 in its local space.
  24014. * Returns the TransformNode.
  24015. */
  24016. locallyTranslate(vector3: Vector3): TransformNode;
  24017. private static _lookAtVectorCache;
  24018. /**
  24019. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  24020. * @param targetPoint the position (must be in same space as current mesh) to look at
  24021. * @param yawCor optional yaw (y-axis) correction in radians
  24022. * @param pitchCor optional pitch (x-axis) correction in radians
  24023. * @param rollCor optional roll (z-axis) correction in radians
  24024. * @param space the choosen space of the target
  24025. * @returns the TransformNode.
  24026. */
  24027. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  24028. /**
  24029. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  24030. * This Vector3 is expressed in the World space.
  24031. */
  24032. getDirection(localAxis: Vector3): Vector3;
  24033. /**
  24034. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  24035. * localAxis is expressed in the mesh local space.
  24036. * result is computed in the Wordl space from the mesh World matrix.
  24037. * Returns the TransformNode.
  24038. */
  24039. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  24040. /**
  24041. * Sets a new pivot point to the current node
  24042. * @param point defines the new pivot point to use
  24043. * @param space defines if the point is in world or local space (local by default)
  24044. * @returns the current TransformNode
  24045. */
  24046. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  24047. /**
  24048. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  24049. */
  24050. getPivotPoint(): Vector3;
  24051. /**
  24052. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  24053. * Returns the TransformNode.
  24054. */
  24055. getPivotPointToRef(result: Vector3): TransformNode;
  24056. /**
  24057. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  24058. */
  24059. getAbsolutePivotPoint(): Vector3;
  24060. /**
  24061. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  24062. * Returns the TransformNode.
  24063. */
  24064. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  24065. /**
  24066. * Defines the passed node as the parent of the current node.
  24067. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  24068. * Returns the TransformNode.
  24069. */
  24070. setParent(node: Nullable<Node>): TransformNode;
  24071. private _nonUniformScaling;
  24072. readonly nonUniformScaling: boolean;
  24073. /** @hidden */
  24074. _updateNonUniformScalingState(value: boolean): boolean;
  24075. /**
  24076. * Attach the current TransformNode to another TransformNode associated with a bone
  24077. * @param bone Bone affecting the TransformNode
  24078. * @param affectedTransformNode TransformNode associated with the bone
  24079. */
  24080. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  24081. detachFromBone(): TransformNode;
  24082. private static _rotationAxisCache;
  24083. /**
  24084. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  24085. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  24086. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  24087. * The passed axis is also normalized.
  24088. * Returns the TransformNode.
  24089. */
  24090. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24091. /**
  24092. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  24093. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  24094. * The passed axis is also normalized.
  24095. * Returns the TransformNode.
  24096. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  24097. */
  24098. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  24099. /**
  24100. * Translates the mesh along the axis vector for the passed distance in the given space.
  24101. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  24102. * Returns the TransformNode.
  24103. */
  24104. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24105. /**
  24106. * Adds a rotation step to the mesh current rotation.
  24107. * x, y, z are Euler angles expressed in radians.
  24108. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  24109. * This means this rotation is made in the mesh local space only.
  24110. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  24111. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  24112. * ```javascript
  24113. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  24114. * ```
  24115. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  24116. * 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.
  24117. * Returns the TransformNode.
  24118. */
  24119. addRotation(x: number, y: number, z: number): TransformNode;
  24120. /**
  24121. * Computes the world matrix of the node
  24122. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24123. * @returns the world matrix
  24124. */
  24125. computeWorldMatrix(force?: boolean): Matrix;
  24126. protected _afterComputeWorldMatrix(): void;
  24127. /**
  24128. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  24129. * @param func: callback function to add
  24130. *
  24131. * Returns the TransformNode.
  24132. */
  24133. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  24134. /**
  24135. * Removes a registered callback function.
  24136. * Returns the TransformNode.
  24137. */
  24138. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  24139. /**
  24140. * Clone the current transform node
  24141. * Returns the new transform node
  24142. * @param name Name of the new clone
  24143. * @param newParent New parent for the clone
  24144. * @param doNotCloneChildren Do not clone children hierarchy
  24145. */
  24146. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  24147. serialize(currentSerializationObject?: any): any;
  24148. /**
  24149. * Returns a new TransformNode object parsed from the source provided.
  24150. * The parameter `parsedMesh` is the source.
  24151. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  24152. */
  24153. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  24154. /**
  24155. * Releases resources associated with this transform node.
  24156. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24157. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24158. */
  24159. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24160. }
  24161. }
  24162. declare module BABYLON {
  24163. class VertexBuffer {
  24164. /** @hidden */
  24165. _buffer: Buffer;
  24166. private _kind;
  24167. private _size;
  24168. private _ownsBuffer;
  24169. private _instanced;
  24170. private _instanceDivisor;
  24171. /**
  24172. * The byte type.
  24173. */
  24174. static readonly BYTE: number;
  24175. /**
  24176. * The unsigned byte type.
  24177. */
  24178. static readonly UNSIGNED_BYTE: number;
  24179. /**
  24180. * The short type.
  24181. */
  24182. static readonly SHORT: number;
  24183. /**
  24184. * The unsigned short type.
  24185. */
  24186. static readonly UNSIGNED_SHORT: number;
  24187. /**
  24188. * The integer type.
  24189. */
  24190. static readonly INT: number;
  24191. /**
  24192. * The unsigned integer type.
  24193. */
  24194. static readonly UNSIGNED_INT: number;
  24195. /**
  24196. * The float type.
  24197. */
  24198. static readonly FLOAT: number;
  24199. /**
  24200. * Gets or sets the instance divisor when in instanced mode
  24201. */
  24202. instanceDivisor: number;
  24203. /**
  24204. * Gets the byte stride.
  24205. */
  24206. readonly byteStride: number;
  24207. /**
  24208. * Gets the byte offset.
  24209. */
  24210. readonly byteOffset: number;
  24211. /**
  24212. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  24213. */
  24214. readonly normalized: boolean;
  24215. /**
  24216. * Gets the data type of each component in the array.
  24217. */
  24218. readonly type: number;
  24219. /**
  24220. * Constructor
  24221. * @param engine the engine
  24222. * @param data the data to use for this vertex buffer
  24223. * @param kind the vertex buffer kind
  24224. * @param updatable whether the data is updatable
  24225. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24226. * @param stride the stride (optional)
  24227. * @param instanced whether the buffer is instanced (optional)
  24228. * @param offset the offset of the data (optional)
  24229. * @param size the number of components (optional)
  24230. * @param type the type of the component (optional)
  24231. * @param normalized whether the data contains normalized data (optional)
  24232. * @param useBytes set to true if stride and offset are in bytes (optional)
  24233. */
  24234. 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);
  24235. /** @hidden */
  24236. _rebuild(): void;
  24237. /**
  24238. * Returns the kind of the VertexBuffer (string).
  24239. */
  24240. getKind(): string;
  24241. /**
  24242. * Boolean : is the VertexBuffer updatable ?
  24243. */
  24244. isUpdatable(): boolean;
  24245. /**
  24246. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  24247. */
  24248. getData(): Nullable<DataArray>;
  24249. /**
  24250. * Returns the WebGLBuffer associated to the VertexBuffer.
  24251. */
  24252. getBuffer(): Nullable<WebGLBuffer>;
  24253. /**
  24254. * Returns the stride as a multiple of the type byte length.
  24255. * DEPRECATED. Use byteStride instead.
  24256. */
  24257. getStrideSize(): number;
  24258. /**
  24259. * Returns the offset as a multiple of the type byte length.
  24260. * DEPRECATED. Use byteOffset instead.
  24261. */
  24262. getOffset(): number;
  24263. /**
  24264. * Returns the number of components per vertex attribute (integer).
  24265. */
  24266. getSize(): number;
  24267. /**
  24268. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  24269. */
  24270. getIsInstanced(): boolean;
  24271. /**
  24272. * Returns the instancing divisor, zero for non-instanced (integer).
  24273. */
  24274. getInstanceDivisor(): number;
  24275. /**
  24276. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  24277. * Returns the created WebGLBuffer.
  24278. */
  24279. create(data?: DataArray): void;
  24280. /**
  24281. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24282. * This function will create a new buffer if the current one is not updatable
  24283. * Returns the updated WebGLBuffer.
  24284. */
  24285. update(data: DataArray): void;
  24286. /**
  24287. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  24288. * Returns the directly updated WebGLBuffer.
  24289. * @param data the new data
  24290. * @param offset the new offset
  24291. * @param useBytes set to true if the offset is in bytes
  24292. */
  24293. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  24294. /**
  24295. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  24296. */
  24297. dispose(): void;
  24298. /**
  24299. * Enumerates each value of this vertex buffer as numbers.
  24300. * @param count the number of values to enumerate
  24301. * @param callback the callback function called for each value
  24302. */
  24303. forEach(count: number, callback: (value: number, index: number) => void): void;
  24304. private static _PositionKind;
  24305. private static _NormalKind;
  24306. private static _TangentKind;
  24307. private static _UVKind;
  24308. private static _UV2Kind;
  24309. private static _UV3Kind;
  24310. private static _UV4Kind;
  24311. private static _UV5Kind;
  24312. private static _UV6Kind;
  24313. private static _ColorKind;
  24314. private static _MatricesIndicesKind;
  24315. private static _MatricesWeightsKind;
  24316. private static _MatricesIndicesExtraKind;
  24317. private static _MatricesWeightsExtraKind;
  24318. static readonly PositionKind: string;
  24319. static readonly NormalKind: string;
  24320. static readonly TangentKind: string;
  24321. static readonly UVKind: string;
  24322. static readonly UV2Kind: string;
  24323. static readonly UV3Kind: string;
  24324. static readonly UV4Kind: string;
  24325. static readonly UV5Kind: string;
  24326. static readonly UV6Kind: string;
  24327. static readonly ColorKind: string;
  24328. static readonly MatricesIndicesKind: string;
  24329. static readonly MatricesWeightsKind: string;
  24330. static readonly MatricesIndicesExtraKind: string;
  24331. static readonly MatricesWeightsExtraKind: string;
  24332. /**
  24333. * Deduces the stride given a kind.
  24334. * @param kind The kind string to deduce
  24335. * @returns The deduced stride
  24336. */
  24337. static DeduceStride(kind: string): number;
  24338. /**
  24339. * Gets the byte length of the given type.
  24340. * @param type the type
  24341. * @returns the number of bytes
  24342. */
  24343. static GetTypeByteLength(type: number): number;
  24344. /**
  24345. * Enumerates each value of the given parameters as numbers.
  24346. * @param data the data to enumerate
  24347. * @param byteOffset the byte offset of the data
  24348. * @param byteStride the byte stride of the data
  24349. * @param componentCount the number of components per element
  24350. * @param componentType the type of the component
  24351. * @param count the total number of components
  24352. * @param normalized whether the data is normalized
  24353. * @param callback the callback function called for each value
  24354. */
  24355. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  24356. private static _GetFloatValue;
  24357. }
  24358. }
  24359. declare module BABYLON {
  24360. /**
  24361. * Defines a target to use with MorphTargetManager
  24362. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24363. */
  24364. class MorphTarget implements IAnimatable {
  24365. /** defines the name of the target */
  24366. name: string;
  24367. /**
  24368. * Gets or sets the list of animations
  24369. */
  24370. animations: Animation[];
  24371. private _scene;
  24372. private _positions;
  24373. private _normals;
  24374. private _tangents;
  24375. private _influence;
  24376. /**
  24377. * Observable raised when the influence changes
  24378. */
  24379. onInfluenceChanged: Observable<boolean>;
  24380. /**
  24381. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  24382. */
  24383. influence: number;
  24384. private _animationPropertiesOverride;
  24385. /**
  24386. * Gets or sets the animation properties override
  24387. */
  24388. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24389. /**
  24390. * Creates a new MorphTarget
  24391. * @param name defines the name of the target
  24392. * @param influence defines the influence to use
  24393. */
  24394. constructor(
  24395. /** defines the name of the target */
  24396. name: string, influence?: number, scene?: Nullable<Scene>);
  24397. /**
  24398. * Gets a boolean defining if the target contains position data
  24399. */
  24400. readonly hasPositions: boolean;
  24401. /**
  24402. * Gets a boolean defining if the target contains normal data
  24403. */
  24404. readonly hasNormals: boolean;
  24405. /**
  24406. * Gets a boolean defining if the target contains tangent data
  24407. */
  24408. readonly hasTangents: boolean;
  24409. /**
  24410. * Affects position data to this target
  24411. * @param data defines the position data to use
  24412. */
  24413. setPositions(data: Nullable<FloatArray>): void;
  24414. /**
  24415. * Gets the position data stored in this target
  24416. * @returns a FloatArray containing the position data (or null if not present)
  24417. */
  24418. getPositions(): Nullable<FloatArray>;
  24419. /**
  24420. * Affects normal data to this target
  24421. * @param data defines the normal data to use
  24422. */
  24423. setNormals(data: Nullable<FloatArray>): void;
  24424. /**
  24425. * Gets the normal data stored in this target
  24426. * @returns a FloatArray containing the normal data (or null if not present)
  24427. */
  24428. getNormals(): Nullable<FloatArray>;
  24429. /**
  24430. * Affects tangent data to this target
  24431. * @param data defines the tangent data to use
  24432. */
  24433. setTangents(data: Nullable<FloatArray>): void;
  24434. /**
  24435. * Gets the tangent data stored in this target
  24436. * @returns a FloatArray containing the tangent data (or null if not present)
  24437. */
  24438. getTangents(): Nullable<FloatArray>;
  24439. /**
  24440. * Serializes the current target into a Serialization object
  24441. * @returns the serialized object
  24442. */
  24443. serialize(): any;
  24444. /**
  24445. * Creates a new target from serialized data
  24446. * @param serializationObject defines the serialized data to use
  24447. * @returns a new MorphTarget
  24448. */
  24449. static Parse(serializationObject: any): MorphTarget;
  24450. /**
  24451. * Creates a MorphTarget from mesh data
  24452. * @param mesh defines the source mesh
  24453. * @param name defines the name to use for the new target
  24454. * @param influence defines the influence to attach to the target
  24455. * @returns a new MorphTarget
  24456. */
  24457. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  24458. }
  24459. }
  24460. declare module BABYLON {
  24461. /**
  24462. * This class is used to deform meshes using morphing between different targets
  24463. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24464. */
  24465. class MorphTargetManager {
  24466. private _targets;
  24467. private _targetObservable;
  24468. private _activeTargets;
  24469. private _scene;
  24470. private _influences;
  24471. private _supportsNormals;
  24472. private _supportsTangents;
  24473. private _vertexCount;
  24474. private _uniqueId;
  24475. private _tempInfluences;
  24476. /**
  24477. * Creates a new MorphTargetManager
  24478. * @param scene defines the current scene
  24479. */
  24480. constructor(scene?: Nullable<Scene>);
  24481. /**
  24482. * Gets the unique ID of this manager
  24483. */
  24484. readonly uniqueId: number;
  24485. /**
  24486. * Gets the number of vertices handled by this manager
  24487. */
  24488. readonly vertexCount: number;
  24489. /**
  24490. * Gets a boolean indicating if this manager supports morphing of normals
  24491. */
  24492. readonly supportsNormals: boolean;
  24493. /**
  24494. * Gets a boolean indicating if this manager supports morphing of tangents
  24495. */
  24496. readonly supportsTangents: boolean;
  24497. /**
  24498. * Gets the number of targets stored in this manager
  24499. */
  24500. readonly numTargets: number;
  24501. /**
  24502. * Gets the number of influencers (ie. the number of targets with influences > 0)
  24503. */
  24504. readonly numInfluencers: number;
  24505. /**
  24506. * Gets the list of influences (one per target)
  24507. */
  24508. readonly influences: Float32Array;
  24509. /**
  24510. * Gets the active target at specified index. An active target is a target with an influence > 0
  24511. * @param index defines the index to check
  24512. * @returns the requested target
  24513. */
  24514. getActiveTarget(index: number): MorphTarget;
  24515. /**
  24516. * Gets the target at specified index
  24517. * @param index defines the index to check
  24518. * @returns the requested target
  24519. */
  24520. getTarget(index: number): MorphTarget;
  24521. /**
  24522. * Add a new target to this manager
  24523. * @param target defines the target to add
  24524. */
  24525. addTarget(target: MorphTarget): void;
  24526. /**
  24527. * Removes a target from the manager
  24528. * @param target defines the target to remove
  24529. */
  24530. removeTarget(target: MorphTarget): void;
  24531. /**
  24532. * Serializes the current manager into a Serialization object
  24533. * @returns the serialized object
  24534. */
  24535. serialize(): any;
  24536. private _syncActiveTargets;
  24537. /**
  24538. * Syncrhonize the targets with all the meshes using this morph target manager
  24539. */
  24540. synchronize(): void;
  24541. /**
  24542. * Creates a new MorphTargetManager from serialized data
  24543. * @param serializationObject defines the serialized data
  24544. * @param scene defines the hosting scene
  24545. * @returns the new MorphTargetManager
  24546. */
  24547. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24548. }
  24549. }
  24550. declare module BABYLON {
  24551. /**
  24552. * This represents the base class for particle system in Babylon.
  24553. * 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.
  24554. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  24555. * @example https://doc.babylonjs.com/babylon101/particles
  24556. */
  24557. class BaseParticleSystem {
  24558. /**
  24559. * Source color is added to the destination color without alpha affecting the result
  24560. */
  24561. static BLENDMODE_ONEONE: number;
  24562. /**
  24563. * Blend current color and particle color using particle’s alpha
  24564. */
  24565. static BLENDMODE_STANDARD: number;
  24566. /**
  24567. * Add current color and particle color multiplied by particle’s alpha
  24568. */
  24569. static BLENDMODE_ADD: number;
  24570. /**
  24571. * Multiply current color with particle color
  24572. */
  24573. static BLENDMODE_MULTIPLY: number;
  24574. /**
  24575. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  24576. */
  24577. static BLENDMODE_MULTIPLYADD: number;
  24578. /**
  24579. * List of animations used by the particle system.
  24580. */
  24581. animations: Animation[];
  24582. /**
  24583. * The id of the Particle system.
  24584. */
  24585. id: string;
  24586. /**
  24587. * The friendly name of the Particle system.
  24588. */
  24589. name: string;
  24590. /**
  24591. * The rendering group used by the Particle system to chose when to render.
  24592. */
  24593. renderingGroupId: number;
  24594. /**
  24595. * The emitter represents the Mesh or position we are attaching the particle system to.
  24596. */
  24597. emitter: Nullable<AbstractMesh | Vector3>;
  24598. /**
  24599. * The maximum number of particles to emit per frame
  24600. */
  24601. emitRate: number;
  24602. /**
  24603. * If you want to launch only a few particles at once, that can be done, as well.
  24604. */
  24605. manualEmitCount: number;
  24606. /**
  24607. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  24608. */
  24609. updateSpeed: number;
  24610. /**
  24611. * The amount of time the particle system is running (depends of the overall update speed).
  24612. */
  24613. targetStopDuration: number;
  24614. /**
  24615. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  24616. */
  24617. disposeOnStop: boolean;
  24618. /**
  24619. * Minimum power of emitting particles.
  24620. */
  24621. minEmitPower: number;
  24622. /**
  24623. * Maximum power of emitting particles.
  24624. */
  24625. maxEmitPower: number;
  24626. /**
  24627. * Minimum life time of emitting particles.
  24628. */
  24629. minLifeTime: number;
  24630. /**
  24631. * Maximum life time of emitting particles.
  24632. */
  24633. maxLifeTime: number;
  24634. /**
  24635. * Minimum Size of emitting particles.
  24636. */
  24637. minSize: number;
  24638. /**
  24639. * Maximum Size of emitting particles.
  24640. */
  24641. maxSize: number;
  24642. /**
  24643. * Minimum scale of emitting particles on X axis.
  24644. */
  24645. minScaleX: number;
  24646. /**
  24647. * Maximum scale of emitting particles on X axis.
  24648. */
  24649. maxScaleX: number;
  24650. /**
  24651. * Minimum scale of emitting particles on Y axis.
  24652. */
  24653. minScaleY: number;
  24654. /**
  24655. * Maximum scale of emitting particles on Y axis.
  24656. */
  24657. maxScaleY: number;
  24658. /**
  24659. * Gets or sets the minimal initial rotation in radians.
  24660. */
  24661. minInitialRotation: number;
  24662. /**
  24663. * Gets or sets the maximal initial rotation in radians.
  24664. */
  24665. maxInitialRotation: number;
  24666. /**
  24667. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  24668. */
  24669. minAngularSpeed: number;
  24670. /**
  24671. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  24672. */
  24673. maxAngularSpeed: number;
  24674. /**
  24675. * The texture used to render each particle. (this can be a spritesheet)
  24676. */
  24677. particleTexture: Nullable<Texture>;
  24678. /**
  24679. * The layer mask we are rendering the particles through.
  24680. */
  24681. layerMask: number;
  24682. /**
  24683. * This can help using your own shader to render the particle system.
  24684. * The according effect will be created
  24685. */
  24686. customShader: any;
  24687. /**
  24688. * By default particle system starts as soon as they are created. This prevents the
  24689. * automatic start to happen and let you decide when to start emitting particles.
  24690. */
  24691. preventAutoStart: boolean;
  24692. /**
  24693. * Gets or sets a texture used to add random noise to particle positions
  24694. */
  24695. noiseTexture: Nullable<BaseTexture>;
  24696. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  24697. noiseStrength: Vector3;
  24698. /**
  24699. * Callback triggered when the particle animation is ending.
  24700. */
  24701. onAnimationEnd: Nullable<() => void>;
  24702. /**
  24703. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  24704. */
  24705. blendMode: number;
  24706. /**
  24707. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  24708. * to override the particles.
  24709. */
  24710. forceDepthWrite: boolean;
  24711. /** 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 */
  24712. preWarmCycles: number;
  24713. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  24714. preWarmStepOffset: number;
  24715. /**
  24716. * 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)
  24717. */
  24718. spriteCellChangeSpeed: number;
  24719. /**
  24720. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  24721. */
  24722. startSpriteCellID: number;
  24723. /**
  24724. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  24725. */
  24726. endSpriteCellID: number;
  24727. /**
  24728. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  24729. */
  24730. spriteCellWidth: number;
  24731. /**
  24732. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  24733. */
  24734. spriteCellHeight: number;
  24735. /**
  24736. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  24737. */
  24738. spriteRandomStartCell: boolean;
  24739. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  24740. translationPivot: Vector2;
  24741. /** @hidden */
  24742. protected _isAnimationSheetEnabled: boolean;
  24743. /**
  24744. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  24745. */
  24746. isAnimationSheetEnabled: boolean;
  24747. /**
  24748. * Get hosting scene
  24749. * @returns the scene
  24750. */
  24751. getScene(): Scene;
  24752. /**
  24753. * You can use gravity if you want to give an orientation to your particles.
  24754. */
  24755. gravity: Vector3;
  24756. protected _colorGradients: Nullable<Array<ColorGradient>>;
  24757. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  24758. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  24759. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  24760. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  24761. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  24762. protected _dragGradients: Nullable<Array<FactorGradient>>;
  24763. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  24764. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  24765. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  24766. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  24767. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  24768. /**
  24769. * Gets the current list of drag gradients.
  24770. * You must use addDragGradient and removeDragGradient to udpate this list
  24771. * @returns the list of drag gradients
  24772. */
  24773. getDragGradients(): Nullable<Array<FactorGradient>>;
  24774. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  24775. limitVelocityDamping: number;
  24776. /**
  24777. * Gets the current list of limit velocity gradients.
  24778. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  24779. * @returns the list of limit velocity gradients
  24780. */
  24781. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  24782. /**
  24783. * Gets the current list of color gradients.
  24784. * You must use addColorGradient and removeColorGradient to udpate this list
  24785. * @returns the list of color gradients
  24786. */
  24787. getColorGradients(): Nullable<Array<ColorGradient>>;
  24788. /**
  24789. * Gets the current list of size gradients.
  24790. * You must use addSizeGradient and removeSizeGradient to udpate this list
  24791. * @returns the list of size gradients
  24792. */
  24793. getSizeGradients(): Nullable<Array<FactorGradient>>;
  24794. /**
  24795. * Gets the current list of color remap gradients.
  24796. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  24797. * @returns the list of color remap gradients
  24798. */
  24799. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  24800. /**
  24801. * Gets the current list of alpha remap gradients.
  24802. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  24803. * @returns the list of alpha remap gradients
  24804. */
  24805. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  24806. /**
  24807. * Gets the current list of life time gradients.
  24808. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  24809. * @returns the list of life time gradients
  24810. */
  24811. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  24812. /**
  24813. * Gets the current list of angular speed gradients.
  24814. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  24815. * @returns the list of angular speed gradients
  24816. */
  24817. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  24818. /**
  24819. * Gets the current list of velocity gradients.
  24820. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  24821. * @returns the list of velocity gradients
  24822. */
  24823. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  24824. /**
  24825. * Gets the current list of start size gradients.
  24826. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  24827. * @returns the list of start size gradients
  24828. */
  24829. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  24830. /**
  24831. * Gets the current list of emit rate gradients.
  24832. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  24833. * @returns the list of emit rate gradients
  24834. */
  24835. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  24836. /**
  24837. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24838. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24839. */
  24840. direction1: Vector3;
  24841. /**
  24842. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24843. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24844. */
  24845. direction2: Vector3;
  24846. /**
  24847. * 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.
  24848. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24849. */
  24850. minEmitBox: Vector3;
  24851. /**
  24852. * 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.
  24853. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24854. */
  24855. maxEmitBox: Vector3;
  24856. /**
  24857. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  24858. */
  24859. color1: Color4;
  24860. /**
  24861. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  24862. */
  24863. color2: Color4;
  24864. /**
  24865. * Color the particle will have at the end of its lifetime
  24866. */
  24867. colorDead: Color4;
  24868. /**
  24869. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  24870. */
  24871. textureMask: Color4;
  24872. /**
  24873. * The particle emitter type defines the emitter used by the particle system.
  24874. * It can be for example box, sphere, or cone...
  24875. */
  24876. particleEmitterType: IParticleEmitterType;
  24877. /**
  24878. * Gets or sets the billboard mode to use when isBillboardBased = true.
  24879. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  24880. */
  24881. billboardMode: number;
  24882. protected _isBillboardBased: boolean;
  24883. /**
  24884. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  24885. */
  24886. isBillboardBased: boolean;
  24887. /**
  24888. * The scene the particle system belongs to.
  24889. */
  24890. protected _scene: Scene;
  24891. /**
  24892. * Local cache of defines for image processing.
  24893. */
  24894. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  24895. /**
  24896. * Default configuration related to image processing available in the standard Material.
  24897. */
  24898. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24899. /**
  24900. * Gets the image processing configuration used either in this material.
  24901. */
  24902. /**
  24903. * Sets the Default image processing configuration used either in the this material.
  24904. *
  24905. * If sets to null, the scene one is in use.
  24906. */
  24907. imageProcessingConfiguration: ImageProcessingConfiguration;
  24908. /**
  24909. * Attaches a new image processing configuration to the Standard Material.
  24910. * @param configuration
  24911. */
  24912. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  24913. /** @hidden */
  24914. protected _reset(): void;
  24915. /** @hidden */
  24916. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  24917. /**
  24918. * Instantiates a particle system.
  24919. * 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.
  24920. * @param name The name of the particle system
  24921. */
  24922. constructor(name: string);
  24923. /**
  24924. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  24925. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  24926. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  24927. * @returns the emitter
  24928. */
  24929. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  24930. /**
  24931. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  24932. * @param radius The radius of the hemisphere to emit from
  24933. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  24934. * @returns the emitter
  24935. */
  24936. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  24937. /**
  24938. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  24939. * @param radius The radius of the sphere to emit from
  24940. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  24941. * @returns the emitter
  24942. */
  24943. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  24944. /**
  24945. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  24946. * @param radius The radius of the sphere to emit from
  24947. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  24948. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  24949. * @returns the emitter
  24950. */
  24951. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  24952. /**
  24953. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  24954. * @param radius The radius of the emission cylinder
  24955. * @param height The height of the emission cylinder
  24956. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  24957. * @param directionRandomizer How much to randomize the particle direction [0-1]
  24958. * @returns the emitter
  24959. */
  24960. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  24961. /**
  24962. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  24963. * @param radius The radius of the cylinder to emit from
  24964. * @param height The height of the emission cylinder
  24965. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  24966. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  24967. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  24968. * @returns the emitter
  24969. */
  24970. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  24971. /**
  24972. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  24973. * @param radius The radius of the cone to emit from
  24974. * @param angle The base angle of the cone
  24975. * @returns the emitter
  24976. */
  24977. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  24978. /**
  24979. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  24980. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  24981. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  24982. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  24983. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  24984. * @returns the emitter
  24985. */
  24986. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  24987. }
  24988. }
  24989. declare module BABYLON {
  24990. /**
  24991. * This represents a GPU particle system in Babylon
  24992. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  24993. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  24994. */
  24995. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  24996. /**
  24997. * The layer mask we are rendering the particles through.
  24998. */
  24999. layerMask: number;
  25000. private _capacity;
  25001. private _activeCount;
  25002. private _currentActiveCount;
  25003. private _accumulatedCount;
  25004. private _renderEffect;
  25005. private _updateEffect;
  25006. private _buffer0;
  25007. private _buffer1;
  25008. private _spriteBuffer;
  25009. private _updateVAO;
  25010. private _renderVAO;
  25011. private _targetIndex;
  25012. private _sourceBuffer;
  25013. private _targetBuffer;
  25014. private _engine;
  25015. private _currentRenderId;
  25016. private _started;
  25017. private _stopped;
  25018. private _timeDelta;
  25019. private _randomTexture;
  25020. private _randomTexture2;
  25021. private _attributesStrideSize;
  25022. private _updateEffectOptions;
  25023. private _randomTextureSize;
  25024. private _actualFrame;
  25025. private readonly _rawTextureWidth;
  25026. /**
  25027. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  25028. */
  25029. static readonly IsSupported: boolean;
  25030. /**
  25031. * An event triggered when the system is disposed.
  25032. */
  25033. onDisposeObservable: Observable<GPUParticleSystem>;
  25034. /**
  25035. * Gets the maximum number of particles active at the same time.
  25036. * @returns The max number of active particles.
  25037. */
  25038. getCapacity(): number;
  25039. /**
  25040. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  25041. * to override the particles.
  25042. */
  25043. forceDepthWrite: boolean;
  25044. /**
  25045. * Gets or set the number of active particles
  25046. */
  25047. activeParticleCount: number;
  25048. private _preWarmDone;
  25049. /**
  25050. * Is this system ready to be used/rendered
  25051. * @return true if the system is ready
  25052. */
  25053. isReady(): boolean;
  25054. /**
  25055. * Gets if the system has been started. (Note: this will still be true after stop is called)
  25056. * @returns True if it has been started, otherwise false.
  25057. */
  25058. isStarted(): boolean;
  25059. /**
  25060. * Starts the particle system and begins to emit
  25061. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  25062. */
  25063. start(delay?: number): void;
  25064. /**
  25065. * Stops the particle system.
  25066. */
  25067. stop(): void;
  25068. /**
  25069. * Remove all active particles
  25070. */
  25071. reset(): void;
  25072. /**
  25073. * Returns the string "GPUParticleSystem"
  25074. * @returns a string containing the class name
  25075. */
  25076. getClassName(): string;
  25077. private _colorGradientsTexture;
  25078. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  25079. /**
  25080. * Adds a new color gradient
  25081. * @param gradient defines the gradient to use (between 0 and 1)
  25082. * @param color defines the color to affect to the specified gradient
  25083. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  25084. * @returns the current particle system
  25085. */
  25086. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  25087. /**
  25088. * Remove a specific color gradient
  25089. * @param gradient defines the gradient to remove
  25090. * @returns the current particle system
  25091. */
  25092. removeColorGradient(gradient: number): GPUParticleSystem;
  25093. private _angularSpeedGradientsTexture;
  25094. private _sizeGradientsTexture;
  25095. private _velocityGradientsTexture;
  25096. private _limitVelocityGradientsTexture;
  25097. private _dragGradientsTexture;
  25098. private _addFactorGradient;
  25099. /**
  25100. * Adds a new size gradient
  25101. * @param gradient defines the gradient to use (between 0 and 1)
  25102. * @param factor defines the size factor to affect to the specified gradient
  25103. * @returns the current particle system
  25104. */
  25105. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  25106. /**
  25107. * Remove a specific size gradient
  25108. * @param gradient defines the gradient to remove
  25109. * @returns the current particle system
  25110. */
  25111. removeSizeGradient(gradient: number): GPUParticleSystem;
  25112. /**
  25113. * Adds a new angular speed gradient
  25114. * @param gradient defines the gradient to use (between 0 and 1)
  25115. * @param factor defines the angular speed to affect to the specified gradient
  25116. * @returns the current particle system
  25117. */
  25118. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  25119. /**
  25120. * Remove a specific angular speed gradient
  25121. * @param gradient defines the gradient to remove
  25122. * @returns the current particle system
  25123. */
  25124. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  25125. /**
  25126. * Adds a new velocity gradient
  25127. * @param gradient defines the gradient to use (between 0 and 1)
  25128. * @param factor defines the velocity to affect to the specified gradient
  25129. * @returns the current particle system
  25130. */
  25131. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  25132. /**
  25133. * Remove a specific velocity gradient
  25134. * @param gradient defines the gradient to remove
  25135. * @returns the current particle system
  25136. */
  25137. removeVelocityGradient(gradient: number): GPUParticleSystem;
  25138. /**
  25139. * Adds a new limit velocity gradient
  25140. * @param gradient defines the gradient to use (between 0 and 1)
  25141. * @param factor defines the limit velocity value to affect to the specified gradient
  25142. * @returns the current particle system
  25143. */
  25144. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  25145. /**
  25146. * Remove a specific limit velocity gradient
  25147. * @param gradient defines the gradient to remove
  25148. * @returns the current particle system
  25149. */
  25150. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  25151. /**
  25152. * Adds a new drag gradient
  25153. * @param gradient defines the gradient to use (between 0 and 1)
  25154. * @param factor defines the drag value to affect to the specified gradient
  25155. * @returns the current particle system
  25156. */
  25157. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  25158. /**
  25159. * Remove a specific drag gradient
  25160. * @param gradient defines the gradient to remove
  25161. * @returns the current particle system
  25162. */
  25163. removeDragGradient(gradient: number): GPUParticleSystem;
  25164. /**
  25165. * Not supported by GPUParticleSystem
  25166. * @param gradient defines the gradient to use (between 0 and 1)
  25167. * @param factor defines the emit rate value to affect to the specified gradient
  25168. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25169. * @returns the current particle system
  25170. */
  25171. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25172. /**
  25173. * Not supported by GPUParticleSystem
  25174. * @param gradient defines the gradient to remove
  25175. * @returns the current particle system
  25176. */
  25177. removeEmitRateGradient(gradient: number): IParticleSystem;
  25178. /**
  25179. * Not supported by GPUParticleSystem
  25180. * @param gradient defines the gradient to use (between 0 and 1)
  25181. * @param factor defines the start size value to affect to the specified gradient
  25182. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25183. * @returns the current particle system
  25184. */
  25185. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25186. /**
  25187. * Not supported by GPUParticleSystem
  25188. * @param gradient defines the gradient to remove
  25189. * @returns the current particle system
  25190. */
  25191. removeStartSizeGradient(gradient: number): IParticleSystem;
  25192. /**
  25193. * Not supported by GPUParticleSystem
  25194. * @param gradient defines the gradient to use (between 0 and 1)
  25195. * @param min defines the color remap minimal range
  25196. * @param max defines the color remap maximal range
  25197. * @returns the current particle system
  25198. */
  25199. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  25200. /**
  25201. * Not supported by GPUParticleSystem
  25202. * @param gradient defines the gradient to remove
  25203. * @returns the current particle system
  25204. */
  25205. removeColorRemapGradient(gradient: number): IParticleSystem;
  25206. /**
  25207. * Not supported by GPUParticleSystem
  25208. * @param gradient defines the gradient to use (between 0 and 1)
  25209. * @param min defines the alpha remap minimal range
  25210. * @param max defines the alpha remap maximal range
  25211. * @returns the current particle system
  25212. */
  25213. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  25214. /**
  25215. * Not supported by GPUParticleSystem
  25216. * @param gradient defines the gradient to remove
  25217. * @returns the current particle system
  25218. */
  25219. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  25220. /**
  25221. * Not supported by GPUParticleSystem
  25222. * @param gradient defines the gradient to use (between 0 and 1)
  25223. * @param color defines the color to affect to the specified gradient
  25224. * @returns the current particle system
  25225. */
  25226. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  25227. /**
  25228. * Not supported by GPUParticleSystem
  25229. * @param gradient defines the gradient to remove
  25230. * @returns the current particle system
  25231. */
  25232. removeRampGradient(gradient: number): IParticleSystem;
  25233. /**
  25234. * Not supported by GPUParticleSystem
  25235. * @returns the list of ramp gradients
  25236. */
  25237. getRampGradients(): Nullable<Array<Color3Gradient>>;
  25238. /**
  25239. * Instantiates a GPU particle system.
  25240. * 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.
  25241. * @param name The name of the particle system
  25242. * @param options The options used to create the system
  25243. * @param scene The scene the particle system belongs to
  25244. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  25245. */
  25246. constructor(name: string, options: Partial<{
  25247. capacity: number;
  25248. randomTextureSize: number;
  25249. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  25250. protected _reset(): void;
  25251. private _createUpdateVAO;
  25252. private _createRenderVAO;
  25253. private _initialize;
  25254. /** @hidden */
  25255. _recreateUpdateEffect(): void;
  25256. /** @hidden */
  25257. _recreateRenderEffect(): void;
  25258. /**
  25259. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  25260. * @param preWarm defines if we are in the pre-warmimg phase
  25261. */
  25262. animate(preWarm?: boolean): void;
  25263. private _createFactorGradientTexture;
  25264. private _createSizeGradientTexture;
  25265. private _createAngularSpeedGradientTexture;
  25266. private _createVelocityGradientTexture;
  25267. private _createLimitVelocityGradientTexture;
  25268. private _createDragGradientTexture;
  25269. private _createColorGradientTexture;
  25270. /**
  25271. * Renders the particle system in its current state
  25272. * @param preWarm defines if the system should only update the particles but not render them
  25273. * @returns the current number of particles
  25274. */
  25275. render(preWarm?: boolean): number;
  25276. /**
  25277. * Rebuilds the particle system
  25278. */
  25279. rebuild(): void;
  25280. private _releaseBuffers;
  25281. private _releaseVAOs;
  25282. /**
  25283. * Disposes the particle system and free the associated resources
  25284. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  25285. */
  25286. dispose(disposeTexture?: boolean): void;
  25287. /**
  25288. * Clones the particle system.
  25289. * @param name The name of the cloned object
  25290. * @param newEmitter The new emitter to use
  25291. * @returns the cloned particle system
  25292. */
  25293. clone(name: string, newEmitter: any): GPUParticleSystem;
  25294. /**
  25295. * Serializes the particle system to a JSON object.
  25296. * @returns the JSON object
  25297. */
  25298. serialize(): any;
  25299. /**
  25300. * Parses a JSON object to create a GPU particle system.
  25301. * @param parsedParticleSystem The JSON object to parse
  25302. * @param scene The scene to create the particle system in
  25303. * @param rootUrl The root url to use to load external dependencies like texture
  25304. * @returns the parsed GPU particle system
  25305. */
  25306. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  25307. }
  25308. }
  25309. declare module BABYLON {
  25310. /**
  25311. * Interface representing a particle system in Babylon.js.
  25312. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  25313. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  25314. */
  25315. interface IParticleSystem {
  25316. /**
  25317. * List of animations used by the particle system.
  25318. */
  25319. animations: Animation[];
  25320. /**
  25321. * The id of the Particle system.
  25322. */
  25323. id: string;
  25324. /**
  25325. * The name of the Particle system.
  25326. */
  25327. name: string;
  25328. /**
  25329. * The emitter represents the Mesh or position we are attaching the particle system to.
  25330. */
  25331. emitter: Nullable<AbstractMesh | Vector3>;
  25332. /**
  25333. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  25334. */
  25335. isBillboardBased: boolean;
  25336. /**
  25337. * The rendering group used by the Particle system to chose when to render.
  25338. */
  25339. renderingGroupId: number;
  25340. /**
  25341. * The layer mask we are rendering the particles through.
  25342. */
  25343. layerMask: number;
  25344. /**
  25345. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  25346. */
  25347. updateSpeed: number;
  25348. /**
  25349. * The amount of time the particle system is running (depends of the overall update speed).
  25350. */
  25351. targetStopDuration: number;
  25352. /**
  25353. * The texture used to render each particle. (this can be a spritesheet)
  25354. */
  25355. particleTexture: Nullable<Texture>;
  25356. /**
  25357. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  25358. */
  25359. blendMode: number;
  25360. /**
  25361. * Minimum life time of emitting particles.
  25362. */
  25363. minLifeTime: number;
  25364. /**
  25365. * Maximum life time of emitting particles.
  25366. */
  25367. maxLifeTime: number;
  25368. /**
  25369. * Minimum Size of emitting particles.
  25370. */
  25371. minSize: number;
  25372. /**
  25373. * Maximum Size of emitting particles.
  25374. */
  25375. maxSize: number;
  25376. /**
  25377. * Minimum scale of emitting particles on X axis.
  25378. */
  25379. minScaleX: number;
  25380. /**
  25381. * Maximum scale of emitting particles on X axis.
  25382. */
  25383. maxScaleX: number;
  25384. /**
  25385. * Minimum scale of emitting particles on Y axis.
  25386. */
  25387. minScaleY: number;
  25388. /**
  25389. * Maximum scale of emitting particles on Y axis.
  25390. */
  25391. maxScaleY: number;
  25392. /**
  25393. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  25394. */
  25395. color1: Color4;
  25396. /**
  25397. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  25398. */
  25399. color2: Color4;
  25400. /**
  25401. * Color the particle will have at the end of its lifetime.
  25402. */
  25403. colorDead: Color4;
  25404. /**
  25405. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  25406. */
  25407. emitRate: number;
  25408. /**
  25409. * You can use gravity if you want to give an orientation to your particles.
  25410. */
  25411. gravity: Vector3;
  25412. /**
  25413. * Minimum power of emitting particles.
  25414. */
  25415. minEmitPower: number;
  25416. /**
  25417. * Maximum power of emitting particles.
  25418. */
  25419. maxEmitPower: number;
  25420. /**
  25421. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  25422. */
  25423. minAngularSpeed: number;
  25424. /**
  25425. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  25426. */
  25427. maxAngularSpeed: number;
  25428. /**
  25429. * Gets or sets the minimal initial rotation in radians.
  25430. */
  25431. minInitialRotation: number;
  25432. /**
  25433. * Gets or sets the maximal initial rotation in radians.
  25434. */
  25435. maxInitialRotation: number;
  25436. /**
  25437. * The particle emitter type defines the emitter used by the particle system.
  25438. * It can be for example box, sphere, or cone...
  25439. */
  25440. particleEmitterType: Nullable<IParticleEmitterType>;
  25441. /**
  25442. * 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
  25443. */
  25444. preWarmCycles: number;
  25445. /**
  25446. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  25447. */
  25448. preWarmStepOffset: number;
  25449. /**
  25450. * 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)
  25451. */
  25452. spriteCellChangeSpeed: number;
  25453. /**
  25454. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  25455. */
  25456. startSpriteCellID: number;
  25457. /**
  25458. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  25459. */
  25460. endSpriteCellID: number;
  25461. /**
  25462. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  25463. */
  25464. spriteCellWidth: number;
  25465. /**
  25466. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  25467. */
  25468. spriteCellHeight: number;
  25469. /**
  25470. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  25471. */
  25472. spriteRandomStartCell: boolean;
  25473. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  25474. translationPivot: Vector2;
  25475. /**
  25476. * Gets or sets a texture used to add random noise to particle positions
  25477. */
  25478. noiseTexture: Nullable<BaseTexture>;
  25479. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  25480. noiseStrength: Vector3;
  25481. /**
  25482. * Gets or sets the billboard mode to use when isBillboardBased = true.
  25483. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  25484. */
  25485. billboardMode: number;
  25486. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  25487. limitVelocityDamping: number;
  25488. /**
  25489. * Gets the maximum number of particles active at the same time.
  25490. * @returns The max number of active particles.
  25491. */
  25492. getCapacity(): number;
  25493. /**
  25494. * Gets if the system has been started. (Note: this will still be true after stop is called)
  25495. * @returns True if it has been started, otherwise false.
  25496. */
  25497. isStarted(): boolean;
  25498. /**
  25499. * Animates the particle system for this frame.
  25500. */
  25501. animate(): void;
  25502. /**
  25503. * Renders the particle system in its current state.
  25504. * @returns the current number of particles
  25505. */
  25506. render(): number;
  25507. /**
  25508. * Dispose the particle system and frees its associated resources.
  25509. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  25510. */
  25511. dispose(disposeTexture?: boolean): void;
  25512. /**
  25513. * Clones the particle system.
  25514. * @param name The name of the cloned object
  25515. * @param newEmitter The new emitter to use
  25516. * @returns the cloned particle system
  25517. */
  25518. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  25519. /**
  25520. * Serializes the particle system to a JSON object.
  25521. * @returns the JSON object
  25522. */
  25523. serialize(): any;
  25524. /**
  25525. * Rebuild the particle system
  25526. */
  25527. rebuild(): void;
  25528. /**
  25529. * Starts the particle system and begins to emit
  25530. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  25531. */
  25532. start(delay?: number): void;
  25533. /**
  25534. * Stops the particle system.
  25535. */
  25536. stop(): void;
  25537. /**
  25538. * Remove all active particles
  25539. */
  25540. reset(): void;
  25541. /**
  25542. * Is this system ready to be used/rendered
  25543. * @return true if the system is ready
  25544. */
  25545. isReady(): boolean;
  25546. /**
  25547. * Adds a new color gradient
  25548. * @param gradient defines the gradient to use (between 0 and 1)
  25549. * @param color defines the color to affect to the specified gradient
  25550. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  25551. * @returns the current particle system
  25552. */
  25553. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  25554. /**
  25555. * Remove a specific color gradient
  25556. * @param gradient defines the gradient to remove
  25557. * @returns the current particle system
  25558. */
  25559. removeColorGradient(gradient: number): IParticleSystem;
  25560. /**
  25561. * Adds a new size gradient
  25562. * @param gradient defines the gradient to use (between 0 and 1)
  25563. * @param factor defines the size factor to affect to the specified gradient
  25564. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25565. * @returns the current particle system
  25566. */
  25567. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25568. /**
  25569. * Remove a specific size gradient
  25570. * @param gradient defines the gradient to remove
  25571. * @returns the current particle system
  25572. */
  25573. removeSizeGradient(gradient: number): IParticleSystem;
  25574. /**
  25575. * Gets the current list of color gradients.
  25576. * You must use addColorGradient and removeColorGradient to udpate this list
  25577. * @returns the list of color gradients
  25578. */
  25579. getColorGradients(): Nullable<Array<ColorGradient>>;
  25580. /**
  25581. * Gets the current list of size gradients.
  25582. * You must use addSizeGradient and removeSizeGradient to udpate this list
  25583. * @returns the list of size gradients
  25584. */
  25585. getSizeGradients(): Nullable<Array<FactorGradient>>;
  25586. /**
  25587. * Gets the current list of angular speed gradients.
  25588. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  25589. * @returns the list of angular speed gradients
  25590. */
  25591. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  25592. /**
  25593. * Adds a new angular speed gradient
  25594. * @param gradient defines the gradient to use (between 0 and 1)
  25595. * @param factor defines the angular speed to affect to the specified gradient
  25596. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25597. * @returns the current particle system
  25598. */
  25599. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25600. /**
  25601. * Remove a specific angular speed gradient
  25602. * @param gradient defines the gradient to remove
  25603. * @returns the current particle system
  25604. */
  25605. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  25606. /**
  25607. * Gets the current list of velocity gradients.
  25608. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  25609. * @returns the list of velocity gradients
  25610. */
  25611. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  25612. /**
  25613. * Adds a new velocity gradient
  25614. * @param gradient defines the gradient to use (between 0 and 1)
  25615. * @param factor defines the velocity to affect to the specified gradient
  25616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25617. * @returns the current particle system
  25618. */
  25619. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25620. /**
  25621. * Remove a specific velocity gradient
  25622. * @param gradient defines the gradient to remove
  25623. * @returns the current particle system
  25624. */
  25625. removeVelocityGradient(gradient: number): IParticleSystem;
  25626. /**
  25627. * Gets the current list of limit velocity gradients.
  25628. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  25629. * @returns the list of limit velocity gradients
  25630. */
  25631. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  25632. /**
  25633. * Adds a new limit velocity gradient
  25634. * @param gradient defines the gradient to use (between 0 and 1)
  25635. * @param factor defines the limit velocity to affect to the specified gradient
  25636. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25637. * @returns the current particle system
  25638. */
  25639. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25640. /**
  25641. * Remove a specific limit velocity gradient
  25642. * @param gradient defines the gradient to remove
  25643. * @returns the current particle system
  25644. */
  25645. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  25646. /**
  25647. * Adds a new drag gradient
  25648. * @param gradient defines the gradient to use (between 0 and 1)
  25649. * @param factor defines the drag to affect to the specified gradient
  25650. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25651. * @returns the current particle system
  25652. */
  25653. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25654. /**
  25655. * Remove a specific drag gradient
  25656. * @param gradient defines the gradient to remove
  25657. * @returns the current particle system
  25658. */
  25659. removeDragGradient(gradient: number): IParticleSystem;
  25660. /**
  25661. * Gets the current list of drag gradients.
  25662. * You must use addDragGradient and removeDragGradient to udpate this list
  25663. * @returns the list of drag gradients
  25664. */
  25665. getDragGradients(): Nullable<Array<FactorGradient>>;
  25666. /**
  25667. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  25668. * @param gradient defines the gradient to use (between 0 and 1)
  25669. * @param factor defines the emit rate to affect to the specified gradient
  25670. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25671. * @returns the current particle system
  25672. */
  25673. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25674. /**
  25675. * Remove a specific emit rate gradient
  25676. * @param gradient defines the gradient to remove
  25677. * @returns the current particle system
  25678. */
  25679. removeEmitRateGradient(gradient: number): IParticleSystem;
  25680. /**
  25681. * Gets the current list of emit rate gradients.
  25682. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  25683. * @returns the list of emit rate gradients
  25684. */
  25685. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  25686. /**
  25687. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  25688. * @param gradient defines the gradient to use (between 0 and 1)
  25689. * @param factor defines the start size to affect to the specified gradient
  25690. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25691. * @returns the current particle system
  25692. */
  25693. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25694. /**
  25695. * Remove a specific start size gradient
  25696. * @param gradient defines the gradient to remove
  25697. * @returns the current particle system
  25698. */
  25699. removeStartSizeGradient(gradient: number): IParticleSystem;
  25700. /**
  25701. * Gets the current list of start size gradients.
  25702. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  25703. * @returns the list of start size gradients
  25704. */
  25705. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  25706. /**
  25707. * Gets the current list of color gradients.
  25708. * You must use addColorGradient and removeColorGradient to udpate this list
  25709. * @returns the list of color gradients
  25710. */
  25711. getColorGradients(): Nullable<Array<ColorGradient>>;
  25712. /**
  25713. * Adds a new ramp gradient used to remap particle colors
  25714. * @param gradient defines the gradient to use (between 0 and 1)
  25715. * @param color defines the color to affect to the specified gradient
  25716. * @returns the current particle system
  25717. */
  25718. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  25719. /**
  25720. * Gets the current list of ramp gradients.
  25721. * You must use addRampGradient and removeRampGradient to udpate this list
  25722. * @returns the list of ramp gradients
  25723. */
  25724. getRampGradients(): Nullable<Array<Color3Gradient>>;
  25725. /**
  25726. * Adds a new color remap gradient
  25727. * @param gradient defines the gradient to use (between 0 and 1)
  25728. * @param min defines the color remap minimal range
  25729. * @param max defines the color remap maximal range
  25730. * @returns the current particle system
  25731. */
  25732. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  25733. /**
  25734. * Gets the current list of color remap gradients.
  25735. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  25736. * @returns the list of color remap gradients
  25737. */
  25738. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  25739. /**
  25740. * Adds a new alpha remap gradient
  25741. * @param gradient defines the gradient to use (between 0 and 1)
  25742. * @param min defines the alpha remap minimal range
  25743. * @param max defines the alpha remap maximal range
  25744. * @returns the current particle system
  25745. */
  25746. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  25747. /**
  25748. * Gets the current list of alpha remap gradients.
  25749. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  25750. * @returns the list of alpha remap gradients
  25751. */
  25752. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  25753. /**
  25754. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  25755. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  25756. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  25757. * @returns the emitter
  25758. */
  25759. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  25760. /**
  25761. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  25762. * @param radius The radius of the hemisphere to emit from
  25763. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  25764. * @returns the emitter
  25765. */
  25766. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  25767. /**
  25768. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  25769. * @param radius The radius of the sphere to emit from
  25770. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  25771. * @returns the emitter
  25772. */
  25773. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  25774. /**
  25775. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  25776. * @param radius The radius of the sphere to emit from
  25777. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  25778. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  25779. * @returns the emitter
  25780. */
  25781. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  25782. /**
  25783. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  25784. * @param radius The radius of the emission cylinder
  25785. * @param height The height of the emission cylinder
  25786. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  25787. * @param directionRandomizer How much to randomize the particle direction [0-1]
  25788. * @returns the emitter
  25789. */
  25790. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  25791. /**
  25792. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  25793. * @param radius The radius of the cylinder to emit from
  25794. * @param height The height of the emission cylinder
  25795. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  25796. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  25797. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  25798. * @returns the emitter
  25799. */
  25800. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  25801. /**
  25802. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  25803. * @param radius The radius of the cone to emit from
  25804. * @param angle The base angle of the cone
  25805. * @returns the emitter
  25806. */
  25807. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  25808. /**
  25809. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  25810. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  25811. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  25812. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  25813. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  25814. * @returns the emitter
  25815. */
  25816. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  25817. /**
  25818. * Get hosting scene
  25819. * @returns the scene
  25820. */
  25821. getScene(): Scene;
  25822. }
  25823. }
  25824. declare module BABYLON {
  25825. /**
  25826. * A particle represents one of the element emitted by a particle system.
  25827. * This is mainly define by its coordinates, direction, velocity and age.
  25828. */
  25829. class Particle {
  25830. /**
  25831. * The particle system the particle belongs to.
  25832. */
  25833. particleSystem: ParticleSystem;
  25834. private static _Count;
  25835. /**
  25836. * Unique ID of the particle
  25837. */
  25838. id: number;
  25839. /**
  25840. * The world position of the particle in the scene.
  25841. */
  25842. position: Vector3;
  25843. /**
  25844. * The world direction of the particle in the scene.
  25845. */
  25846. direction: Vector3;
  25847. /**
  25848. * The color of the particle.
  25849. */
  25850. color: Color4;
  25851. /**
  25852. * The color change of the particle per step.
  25853. */
  25854. colorStep: Color4;
  25855. /**
  25856. * Defines how long will the life of the particle be.
  25857. */
  25858. lifeTime: number;
  25859. /**
  25860. * The current age of the particle.
  25861. */
  25862. age: number;
  25863. /**
  25864. * The current size of the particle.
  25865. */
  25866. size: number;
  25867. /**
  25868. * The current scale of the particle.
  25869. */
  25870. scale: Vector2;
  25871. /**
  25872. * The current angle of the particle.
  25873. */
  25874. angle: number;
  25875. /**
  25876. * Defines how fast is the angle changing.
  25877. */
  25878. angularSpeed: number;
  25879. /**
  25880. * Defines the cell index used by the particle to be rendered from a sprite.
  25881. */
  25882. cellIndex: number;
  25883. /**
  25884. * The information required to support color remapping
  25885. */
  25886. remapData: Vector4;
  25887. /** @hidden */
  25888. _randomCellOffset?: number;
  25889. /** @hidden */
  25890. _initialDirection: Nullable<Vector3>;
  25891. /** @hidden */
  25892. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  25893. /** @hidden */
  25894. _initialStartSpriteCellID: number;
  25895. _initialEndSpriteCellID: number;
  25896. /** @hidden */
  25897. _currentColorGradient: Nullable<ColorGradient>;
  25898. /** @hidden */
  25899. _currentColor1: Color4;
  25900. /** @hidden */
  25901. _currentColor2: Color4;
  25902. /** @hidden */
  25903. _currentSizeGradient: Nullable<FactorGradient>;
  25904. /** @hidden */
  25905. _currentSize1: number;
  25906. /** @hidden */
  25907. _currentSize2: number;
  25908. /** @hidden */
  25909. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  25910. /** @hidden */
  25911. _currentAngularSpeed1: number;
  25912. /** @hidden */
  25913. _currentAngularSpeed2: number;
  25914. /** @hidden */
  25915. _currentVelocityGradient: Nullable<FactorGradient>;
  25916. /** @hidden */
  25917. _currentVelocity1: number;
  25918. /** @hidden */
  25919. _currentVelocity2: number;
  25920. /** @hidden */
  25921. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  25922. /** @hidden */
  25923. _currentLimitVelocity1: number;
  25924. /** @hidden */
  25925. _currentLimitVelocity2: number;
  25926. /** @hidden */
  25927. _currentDragGradient: Nullable<FactorGradient>;
  25928. /** @hidden */
  25929. _currentDrag1: number;
  25930. /** @hidden */
  25931. _currentDrag2: number;
  25932. /**
  25933. * Creates a new instance Particle
  25934. * @param particleSystem the particle system the particle belongs to
  25935. */
  25936. constructor(
  25937. /**
  25938. * The particle system the particle belongs to.
  25939. */
  25940. particleSystem: ParticleSystem);
  25941. private updateCellInfoFromSystem;
  25942. /**
  25943. * Defines how the sprite cell index is updated for the particle
  25944. */
  25945. updateCellIndex(): void;
  25946. /** @hidden */
  25947. _reset(): void;
  25948. /**
  25949. * Copy the properties of particle to another one.
  25950. * @param other the particle to copy the information to.
  25951. */
  25952. copyTo(other: Particle): void;
  25953. }
  25954. }
  25955. declare module BABYLON {
  25956. /**
  25957. * This class is made for on one-liner static method to help creating particle system set.
  25958. */
  25959. class ParticleHelper {
  25960. /**
  25961. * Gets or sets base Assets URL
  25962. */
  25963. static BaseAssetsUrl: string;
  25964. /**
  25965. * Create a default particle system that you can tweak
  25966. * @param emitter defines the emitter to use
  25967. * @param capacity defines the system capacity (default is 500 particles)
  25968. * @param scene defines the hosting scene
  25969. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  25970. * @returns the new Particle system
  25971. */
  25972. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  25973. /**
  25974. * This is the main static method (one-liner) of this helper to create different particle systems
  25975. * @param type This string represents the type to the particle system to create
  25976. * @param scene The scene where the particle system should live
  25977. * @param gpu If the system will use gpu
  25978. * @returns the ParticleSystemSet created
  25979. */
  25980. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  25981. /**
  25982. * Static function used to export a particle system to a ParticleSystemSet variable.
  25983. * Please note that the emitter shape is not exported
  25984. * @param system defines the particle systems to export
  25985. */
  25986. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  25987. }
  25988. }
  25989. declare module BABYLON {
  25990. /**
  25991. * This represents a particle system in Babylon.
  25992. * 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.
  25993. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  25994. * @example https://doc.babylonjs.com/babylon101/particles
  25995. */
  25996. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  25997. /**
  25998. * This function can be defined to provide custom update for active particles.
  25999. * This function will be called instead of regular update (age, position, color, etc.).
  26000. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  26001. */
  26002. updateFunction: (particles: Particle[]) => void;
  26003. private _emitterWorldMatrix;
  26004. /**
  26005. * This function can be defined to specify initial direction for every new particle.
  26006. * It by default use the emitterType defined function
  26007. */
  26008. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  26009. /**
  26010. * This function can be defined to specify initial position for every new particle.
  26011. * It by default use the emitterType defined function
  26012. */
  26013. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  26014. /**
  26015. * @hidden
  26016. */
  26017. _inheritedVelocityOffset: Vector3;
  26018. /**
  26019. * An event triggered when the system is disposed
  26020. */
  26021. onDisposeObservable: Observable<ParticleSystem>;
  26022. private _onDisposeObserver;
  26023. /**
  26024. * Sets a callback that will be triggered when the system is disposed
  26025. */
  26026. onDispose: () => void;
  26027. private _particles;
  26028. private _epsilon;
  26029. private _capacity;
  26030. private _stockParticles;
  26031. private _newPartsExcess;
  26032. private _vertexData;
  26033. private _vertexBuffer;
  26034. private _vertexBuffers;
  26035. private _spriteBuffer;
  26036. private _indexBuffer;
  26037. private _effect;
  26038. private _customEffect;
  26039. private _cachedDefines;
  26040. private _scaledColorStep;
  26041. private _colorDiff;
  26042. private _scaledDirection;
  26043. private _scaledGravity;
  26044. private _currentRenderId;
  26045. private _alive;
  26046. private _useInstancing;
  26047. private _started;
  26048. private _stopped;
  26049. private _actualFrame;
  26050. private _scaledUpdateSpeed;
  26051. private _vertexBufferSize;
  26052. /** @hidden */
  26053. _currentEmitRateGradient: Nullable<FactorGradient>;
  26054. /** @hidden */
  26055. _currentEmitRate1: number;
  26056. /** @hidden */
  26057. _currentEmitRate2: number;
  26058. /** @hidden */
  26059. _currentStartSizeGradient: Nullable<FactorGradient>;
  26060. /** @hidden */
  26061. _currentStartSize1: number;
  26062. /** @hidden */
  26063. _currentStartSize2: number;
  26064. private readonly _rawTextureWidth;
  26065. private _rampGradientsTexture;
  26066. private _useRampGradients;
  26067. /** Gets or sets a boolean indicating that ramp gradients must be used
  26068. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  26069. */
  26070. useRampGradients: boolean;
  26071. /**
  26072. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  26073. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  26074. */
  26075. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  26076. private _subEmitters;
  26077. /**
  26078. * @hidden
  26079. * If the particle systems emitter should be disposed when the particle system is disposed
  26080. */
  26081. _disposeEmitterOnDispose: boolean;
  26082. /**
  26083. * The current active Sub-systems, this property is used by the root particle system only.
  26084. */
  26085. activeSubSystems: Array<ParticleSystem>;
  26086. private _rootParticleSystem;
  26087. /**
  26088. * Gets the current list of active particles
  26089. */
  26090. readonly particles: Particle[];
  26091. /**
  26092. * Returns the string "ParticleSystem"
  26093. * @returns a string containing the class name
  26094. */
  26095. getClassName(): string;
  26096. /**
  26097. * Instantiates a particle system.
  26098. * 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.
  26099. * @param name The name of the particle system
  26100. * @param capacity The max number of particles alive at the same time
  26101. * @param scene The scene the particle system belongs to
  26102. * @param customEffect a custom effect used to change the way particles are rendered by default
  26103. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  26104. * @param epsilon Offset used to render the particles
  26105. */
  26106. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  26107. private static _InheritParticleInfoToSubEmitter;
  26108. private _addFactorGradient;
  26109. private _removeFactorGradient;
  26110. /**
  26111. * Adds a new life time gradient
  26112. * @param gradient defines the gradient to use (between 0 and 1)
  26113. * @param factor defines the life time factor to affect to the specified gradient
  26114. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26115. * @returns the current particle system
  26116. */
  26117. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26118. /**
  26119. * Remove a specific life time gradient
  26120. * @param gradient defines the gradient to remove
  26121. * @returns the current particle system
  26122. */
  26123. removeLifeTimeGradient(gradient: number): IParticleSystem;
  26124. /**
  26125. * Adds a new size gradient
  26126. * @param gradient defines the gradient to use (between 0 and 1)
  26127. * @param factor defines the size factor to affect to the specified gradient
  26128. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26129. * @returns the current particle system
  26130. */
  26131. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26132. /**
  26133. * Remove a specific size gradient
  26134. * @param gradient defines the gradient to remove
  26135. * @returns the current particle system
  26136. */
  26137. removeSizeGradient(gradient: number): IParticleSystem;
  26138. /**
  26139. * Adds a new color remap gradient
  26140. * @param gradient defines the gradient to use (between 0 and 1)
  26141. * @param min defines the color remap minimal range
  26142. * @param max defines the color remap maximal range
  26143. * @returns the current particle system
  26144. */
  26145. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  26146. /**
  26147. * Remove a specific color remap gradient
  26148. * @param gradient defines the gradient to remove
  26149. * @returns the current particle system
  26150. */
  26151. removeColorRemapGradient(gradient: number): IParticleSystem;
  26152. /**
  26153. * Adds a new alpha remap gradient
  26154. * @param gradient defines the gradient to use (between 0 and 1)
  26155. * @param min defines the alpha remap minimal range
  26156. * @param max defines the alpha remap maximal range
  26157. * @returns the current particle system
  26158. */
  26159. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  26160. /**
  26161. * Remove a specific alpha remap gradient
  26162. * @param gradient defines the gradient to remove
  26163. * @returns the current particle system
  26164. */
  26165. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  26166. /**
  26167. * Adds a new angular speed gradient
  26168. * @param gradient defines the gradient to use (between 0 and 1)
  26169. * @param factor defines the angular speed to affect to the specified gradient
  26170. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26171. * @returns the current particle system
  26172. */
  26173. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26174. /**
  26175. * Remove a specific angular speed gradient
  26176. * @param gradient defines the gradient to remove
  26177. * @returns the current particle system
  26178. */
  26179. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  26180. /**
  26181. * Adds a new velocity gradient
  26182. * @param gradient defines the gradient to use (between 0 and 1)
  26183. * @param factor defines the velocity to affect to the specified gradient
  26184. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26185. * @returns the current particle system
  26186. */
  26187. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26188. /**
  26189. * Remove a specific velocity gradient
  26190. * @param gradient defines the gradient to remove
  26191. * @returns the current particle system
  26192. */
  26193. removeVelocityGradient(gradient: number): IParticleSystem;
  26194. /**
  26195. * Adds a new limit velocity gradient
  26196. * @param gradient defines the gradient to use (between 0 and 1)
  26197. * @param factor defines the limit velocity value to affect to the specified gradient
  26198. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26199. * @returns the current particle system
  26200. */
  26201. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26202. /**
  26203. * Remove a specific limit velocity gradient
  26204. * @param gradient defines the gradient to remove
  26205. * @returns the current particle system
  26206. */
  26207. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  26208. /**
  26209. * Adds a new drag gradient
  26210. * @param gradient defines the gradient to use (between 0 and 1)
  26211. * @param factor defines the drag value to affect to the specified gradient
  26212. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26213. * @returns the current particle system
  26214. */
  26215. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26216. /**
  26217. * Remove a specific drag gradient
  26218. * @param gradient defines the gradient to remove
  26219. * @returns the current particle system
  26220. */
  26221. removeDragGradient(gradient: number): IParticleSystem;
  26222. /**
  26223. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  26224. * @param gradient defines the gradient to use (between 0 and 1)
  26225. * @param factor defines the emit rate value to affect to the specified gradient
  26226. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26227. * @returns the current particle system
  26228. */
  26229. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26230. /**
  26231. * Remove a specific emit rate gradient
  26232. * @param gradient defines the gradient to remove
  26233. * @returns the current particle system
  26234. */
  26235. removeEmitRateGradient(gradient: number): IParticleSystem;
  26236. /**
  26237. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  26238. * @param gradient defines the gradient to use (between 0 and 1)
  26239. * @param factor defines the start size value to affect to the specified gradient
  26240. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  26241. * @returns the current particle system
  26242. */
  26243. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  26244. /**
  26245. * Remove a specific start size gradient
  26246. * @param gradient defines the gradient to remove
  26247. * @returns the current particle system
  26248. */
  26249. removeStartSizeGradient(gradient: number): IParticleSystem;
  26250. private _createRampGradientTexture;
  26251. /**
  26252. * Gets the current list of ramp gradients.
  26253. * You must use addRampGradient and removeRampGradient to udpate this list
  26254. * @returns the list of ramp gradients
  26255. */
  26256. getRampGradients(): Nullable<Array<Color3Gradient>>;
  26257. /**
  26258. * Adds a new ramp gradient used to remap particle colors
  26259. * @param gradient defines the gradient to use (between 0 and 1)
  26260. * @param color defines the color to affect to the specified gradient
  26261. * @returns the current particle system
  26262. */
  26263. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  26264. /**
  26265. * Remove a specific ramp gradient
  26266. * @param gradient defines the gradient to remove
  26267. * @returns the current particle system
  26268. */
  26269. removeRampGradient(gradient: number): ParticleSystem;
  26270. /**
  26271. * Adds a new color gradient
  26272. * @param gradient defines the gradient to use (between 0 and 1)
  26273. * @param color defines the color to affect to the specified gradient
  26274. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  26275. */
  26276. addColorGradient(gradient: number, color: Color4, color2?: Color4): IParticleSystem;
  26277. /**
  26278. * Remove a specific color gradient
  26279. * @param gradient defines the gradient to remove
  26280. */
  26281. removeColorGradient(gradient: number): IParticleSystem;
  26282. private _fetchR;
  26283. protected _reset(): void;
  26284. private _resetEffect;
  26285. private _createVertexBuffers;
  26286. private _createIndexBuffer;
  26287. /**
  26288. * Gets the maximum number of particles active at the same time.
  26289. * @returns The max number of active particles.
  26290. */
  26291. getCapacity(): number;
  26292. /**
  26293. * Gets whether there are still active particles in the system.
  26294. * @returns True if it is alive, otherwise false.
  26295. */
  26296. isAlive(): boolean;
  26297. /**
  26298. * Gets if the system has been started. (Note: this will still be true after stop is called)
  26299. * @returns True if it has been started, otherwise false.
  26300. */
  26301. isStarted(): boolean;
  26302. /**
  26303. * Starts the particle system and begins to emit
  26304. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  26305. */
  26306. start(delay?: number): void;
  26307. /**
  26308. * Stops the particle system.
  26309. * @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.
  26310. */
  26311. stop(stopSubEmitters?: boolean): void;
  26312. /**
  26313. * Remove all active particles
  26314. */
  26315. reset(): void;
  26316. /**
  26317. * @hidden (for internal use only)
  26318. */
  26319. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  26320. /**
  26321. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  26322. * Its lifetime will start back at 0.
  26323. */
  26324. recycleParticle: (particle: Particle) => void;
  26325. private _stopSubEmitters;
  26326. private _createParticle;
  26327. private _removeFromRoot;
  26328. private _emitFromParticle;
  26329. private _update;
  26330. /** @hidden */
  26331. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  26332. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  26333. private _getEffect;
  26334. /**
  26335. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  26336. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  26337. */
  26338. animate(preWarmOnly?: boolean): void;
  26339. private _appendParticleVertices;
  26340. /**
  26341. * Rebuilds the particle system.
  26342. */
  26343. rebuild(): void;
  26344. /**
  26345. * Is this system ready to be used/rendered
  26346. * @return true if the system is ready
  26347. */
  26348. isReady(): boolean;
  26349. private _render;
  26350. /**
  26351. * Renders the particle system in its current state.
  26352. * @returns the current number of particles
  26353. */
  26354. render(): number;
  26355. /**
  26356. * Disposes the particle system and free the associated resources
  26357. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  26358. */
  26359. dispose(disposeTexture?: boolean): void;
  26360. /**
  26361. * Clones the particle system.
  26362. * @param name The name of the cloned object
  26363. * @param newEmitter The new emitter to use
  26364. * @returns the cloned particle system
  26365. */
  26366. clone(name: string, newEmitter: any): ParticleSystem;
  26367. /**
  26368. * Serializes the particle system to a JSON object.
  26369. * @returns the JSON object
  26370. */
  26371. serialize(): any;
  26372. /** @hidden */
  26373. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  26374. /** @hidden */
  26375. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  26376. /**
  26377. * Parses a JSON object to create a particle system.
  26378. * @param parsedParticleSystem The JSON object to parse
  26379. * @param scene The scene to create the particle system in
  26380. * @param rootUrl The root url to use to load external dependencies like texture
  26381. * @returns the Parsed particle system
  26382. */
  26383. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  26384. }
  26385. }
  26386. declare module BABYLON {
  26387. interface Engine {
  26388. /**
  26389. * Create an effect to use with particle systems.
  26390. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  26391. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  26392. * @param uniformsNames defines a list of attribute names
  26393. * @param samplers defines an array of string used to represent textures
  26394. * @param defines defines the string containing the defines to use to compile the shaders
  26395. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  26396. * @param onCompiled defines a function to call when the effect creation is successful
  26397. * @param onError defines a function to call when the effect creation has failed
  26398. * @returns the new Effect
  26399. */
  26400. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  26401. }
  26402. }
  26403. declare module BABYLON {
  26404. /**
  26405. * Represents a set of particle systems working together to create a specific effect
  26406. */
  26407. class ParticleSystemSet implements IDisposable {
  26408. private _emitterCreationOptions;
  26409. private _emitterNode;
  26410. /**
  26411. * Gets the particle system list
  26412. */
  26413. systems: IParticleSystem[];
  26414. /**
  26415. * Gets the emitter node used with this set
  26416. */
  26417. readonly emitterNode: Nullable<TransformNode>;
  26418. /**
  26419. * Creates a new emitter mesh as a sphere
  26420. * @param options defines the options used to create the sphere
  26421. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  26422. * @param scene defines the hosting scene
  26423. */
  26424. setEmitterAsSphere(options: {
  26425. diameter: number;
  26426. segments: number;
  26427. color: Color3;
  26428. }, renderingGroupId: number, scene: Scene): void;
  26429. /**
  26430. * Starts all particle systems of the set
  26431. * @param emitter defines an optional mesh to use as emitter for the particle systems
  26432. */
  26433. start(emitter?: AbstractMesh): void;
  26434. /**
  26435. * Release all associated resources
  26436. */
  26437. dispose(): void;
  26438. /**
  26439. * Serialize the set into a JSON compatible object
  26440. * @returns a JSON compatible representation of the set
  26441. */
  26442. serialize(): any;
  26443. /**
  26444. * Parse a new ParticleSystemSet from a serialized source
  26445. * @param data defines a JSON compatible representation of the set
  26446. * @param scene defines the hosting scene
  26447. * @param gpu defines if we want GPU particles or CPU particles
  26448. * @returns a new ParticleSystemSet
  26449. */
  26450. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  26451. }
  26452. }
  26453. declare module BABYLON {
  26454. /**
  26455. * Represents one particle of a solid particle system.
  26456. */
  26457. class SolidParticle {
  26458. /**
  26459. * particle global index
  26460. */
  26461. idx: number;
  26462. /**
  26463. * The color of the particle
  26464. */
  26465. color: Nullable<Color4>;
  26466. /**
  26467. * The world space position of the particle.
  26468. */
  26469. position: Vector3;
  26470. /**
  26471. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26472. */
  26473. rotation: Vector3;
  26474. /**
  26475. * The world space rotation quaternion of the particle.
  26476. */
  26477. rotationQuaternion: Nullable<Quaternion>;
  26478. /**
  26479. * The scaling of the particle.
  26480. */
  26481. scaling: Vector3;
  26482. /**
  26483. * The uvs of the particle.
  26484. */
  26485. uvs: Vector4;
  26486. /**
  26487. * The current speed of the particle.
  26488. */
  26489. velocity: Vector3;
  26490. /**
  26491. * The pivot point in the particle local space.
  26492. */
  26493. pivot: Vector3;
  26494. /**
  26495. * Must the particle be translated from its pivot point in its local space ?
  26496. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26497. * Default : false
  26498. */
  26499. translateFromPivot: boolean;
  26500. /**
  26501. * Is the particle active or not ?
  26502. */
  26503. alive: boolean;
  26504. /**
  26505. * Is the particle visible or not ?
  26506. */
  26507. isVisible: boolean;
  26508. /**
  26509. * Index of this particle in the global "positions" array (Internal use)
  26510. * @hidden
  26511. */
  26512. _pos: number;
  26513. /**
  26514. * @hidden Index of this particle in the global "indices" array (Internal use)
  26515. */
  26516. _ind: number;
  26517. /**
  26518. * @hidden ModelShape of this particle (Internal use)
  26519. */
  26520. _model: ModelShape;
  26521. /**
  26522. * ModelShape id of this particle
  26523. */
  26524. shapeId: number;
  26525. /**
  26526. * Index of the particle in its shape id (Internal use)
  26527. */
  26528. idxInShape: number;
  26529. /**
  26530. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26531. */
  26532. _modelBoundingInfo: BoundingInfo;
  26533. /**
  26534. * @hidden Particle BoundingInfo object (Internal use)
  26535. */
  26536. _boundingInfo: BoundingInfo;
  26537. /**
  26538. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26539. */
  26540. _sps: SolidParticleSystem;
  26541. /**
  26542. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26543. */
  26544. _stillInvisible: boolean;
  26545. /**
  26546. * @hidden Last computed particle rotation matrix
  26547. */
  26548. _rotationMatrix: number[];
  26549. /**
  26550. * Parent particle Id, if any.
  26551. * Default null.
  26552. */
  26553. parentId: Nullable<number>;
  26554. /**
  26555. * @hidden Internal global position in the SPS.
  26556. */
  26557. _globalPosition: Vector3;
  26558. /**
  26559. * Creates a Solid Particle object.
  26560. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26561. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26562. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26563. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26564. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26565. * @param shapeId (integer) is the model shape identifier in the SPS.
  26566. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26567. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26568. */
  26569. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26570. /**
  26571. * Legacy support, changed scale to scaling
  26572. */
  26573. /**
  26574. * Legacy support, changed scale to scaling
  26575. */
  26576. scale: Vector3;
  26577. /**
  26578. * Legacy support, changed quaternion to rotationQuaternion
  26579. */
  26580. /**
  26581. * Legacy support, changed quaternion to rotationQuaternion
  26582. */
  26583. quaternion: Nullable<Quaternion>;
  26584. /**
  26585. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26586. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26587. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26588. * @returns true if it intersects
  26589. */
  26590. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26591. }
  26592. /**
  26593. * Represents the shape of the model used by one particle of a solid particle system.
  26594. * SPS internal tool, don't use it manually.
  26595. */
  26596. class ModelShape {
  26597. /**
  26598. * The shape id
  26599. * @hidden
  26600. */
  26601. shapeID: number;
  26602. /**
  26603. * flat array of model positions (internal use)
  26604. * @hidden
  26605. */
  26606. _shape: Vector3[];
  26607. /**
  26608. * flat array of model UVs (internal use)
  26609. * @hidden
  26610. */
  26611. _shapeUV: number[];
  26612. /**
  26613. * length of the shape in the model indices array (internal use)
  26614. * @hidden
  26615. */
  26616. _indicesLength: number;
  26617. /**
  26618. * Custom position function (internal use)
  26619. * @hidden
  26620. */
  26621. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26622. /**
  26623. * Custom vertex function (internal use)
  26624. * @hidden
  26625. */
  26626. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26627. /**
  26628. * 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.
  26629. * SPS internal tool, don't use it manually.
  26630. * @hidden
  26631. */
  26632. 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>);
  26633. }
  26634. /**
  26635. * Represents a Depth Sorted Particle in the solid particle system.
  26636. */
  26637. class DepthSortedParticle {
  26638. /**
  26639. * Index of the particle in the "indices" array
  26640. */
  26641. ind: number;
  26642. /**
  26643. * Length of the particle shape in the "indices" array
  26644. */
  26645. indicesLength: number;
  26646. /**
  26647. * Squared distance from the particle to the camera
  26648. */
  26649. sqDistance: number;
  26650. }
  26651. }
  26652. declare module BABYLON {
  26653. /**
  26654. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26655. *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.
  26656. * The SPS is also a particle system. It provides some methods to manage the particles.
  26657. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26658. *
  26659. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  26660. */
  26661. class SolidParticleSystem implements IDisposable {
  26662. /**
  26663. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26664. * Example : var p = SPS.particles[i];
  26665. */
  26666. particles: SolidParticle[];
  26667. /**
  26668. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26669. */
  26670. nbParticles: number;
  26671. /**
  26672. * If the particles must ever face the camera (default false). Useful for planar particles.
  26673. */
  26674. billboard: boolean;
  26675. /**
  26676. * Recompute normals when adding a shape
  26677. */
  26678. recomputeNormals: boolean;
  26679. /**
  26680. * This a counter ofr your own usage. It's not set by any SPS functions.
  26681. */
  26682. counter: number;
  26683. /**
  26684. * The SPS name. This name is also given to the underlying mesh.
  26685. */
  26686. name: string;
  26687. /**
  26688. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26689. */
  26690. mesh: Mesh;
  26691. /**
  26692. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26693. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  26694. */
  26695. vars: any;
  26696. /**
  26697. * This array is populated when the SPS is set as 'pickable'.
  26698. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26699. * Each element of this array is an object `{idx: int, faceId: int}`.
  26700. * `idx` is the picked particle index in the `SPS.particles` array
  26701. * `faceId` is the picked face index counted within this particle.
  26702. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  26703. */
  26704. pickedParticles: {
  26705. idx: number;
  26706. faceId: number;
  26707. }[];
  26708. /**
  26709. * This array is populated when `enableDepthSort` is set to true.
  26710. * Each element of this array is an instance of the class DepthSortedParticle.
  26711. */
  26712. depthSortedParticles: DepthSortedParticle[];
  26713. /**
  26714. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26715. * @hidden
  26716. */
  26717. _bSphereOnly: boolean;
  26718. /**
  26719. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26720. * @hidden
  26721. */
  26722. _bSphereRadiusFactor: number;
  26723. private _scene;
  26724. private _positions;
  26725. private _indices;
  26726. private _normals;
  26727. private _colors;
  26728. private _uvs;
  26729. private _indices32;
  26730. private _positions32;
  26731. private _normals32;
  26732. private _fixedNormal32;
  26733. private _colors32;
  26734. private _uvs32;
  26735. private _index;
  26736. private _updatable;
  26737. private _pickable;
  26738. private _isVisibilityBoxLocked;
  26739. private _alwaysVisible;
  26740. private _depthSort;
  26741. private _shapeCounter;
  26742. private _copy;
  26743. private _shape;
  26744. private _shapeUV;
  26745. private _color;
  26746. private _computeParticleColor;
  26747. private _computeParticleTexture;
  26748. private _computeParticleRotation;
  26749. private _computeParticleVertex;
  26750. private _computeBoundingBox;
  26751. private _depthSortParticles;
  26752. private _cam_axisZ;
  26753. private _cam_axisY;
  26754. private _cam_axisX;
  26755. private _axisZ;
  26756. private _camera;
  26757. private _particle;
  26758. private _camDir;
  26759. private _camInvertedPosition;
  26760. private _rotMatrix;
  26761. private _invertMatrix;
  26762. private _rotated;
  26763. private _quaternion;
  26764. private _vertex;
  26765. private _normal;
  26766. private _yaw;
  26767. private _pitch;
  26768. private _roll;
  26769. private _halfroll;
  26770. private _halfpitch;
  26771. private _halfyaw;
  26772. private _sinRoll;
  26773. private _cosRoll;
  26774. private _sinPitch;
  26775. private _cosPitch;
  26776. private _sinYaw;
  26777. private _cosYaw;
  26778. private _mustUnrotateFixedNormals;
  26779. private _minimum;
  26780. private _maximum;
  26781. private _minBbox;
  26782. private _maxBbox;
  26783. private _particlesIntersect;
  26784. private _depthSortFunction;
  26785. private _needs32Bits;
  26786. private _pivotBackTranslation;
  26787. private _scaledPivot;
  26788. private _particleHasParent;
  26789. private _parent;
  26790. /**
  26791. * Creates a SPS (Solid Particle System) object.
  26792. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26793. * @param scene (Scene) is the scene in which the SPS is added.
  26794. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26795. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26796. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26797. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26798. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26799. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26800. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26801. */
  26802. constructor(name: string, scene: Scene, options?: {
  26803. updatable?: boolean;
  26804. isPickable?: boolean;
  26805. enableDepthSort?: boolean;
  26806. particleIntersection?: boolean;
  26807. boundingSphereOnly?: boolean;
  26808. bSphereRadiusFactor?: number;
  26809. });
  26810. /**
  26811. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26812. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26813. * @returns the created mesh
  26814. */
  26815. buildMesh(): Mesh;
  26816. /**
  26817. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26818. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26819. * Thus the particles generated from `digest()` have their property `position` set yet.
  26820. * @param mesh ( Mesh ) is the mesh to be digested
  26821. * @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
  26822. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26823. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26824. * @returns the current SPS
  26825. */
  26826. digest(mesh: Mesh, options?: {
  26827. facetNb?: number;
  26828. number?: number;
  26829. delta?: number;
  26830. }): SolidParticleSystem;
  26831. private _unrotateFixedNormals;
  26832. private _resetCopy;
  26833. private _meshBuilder;
  26834. private _posToShape;
  26835. private _uvsToShapeUV;
  26836. private _addParticle;
  26837. /**
  26838. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26839. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  26840. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26841. * @param nb (positive integer) the number of particles to be created from this model
  26842. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26843. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26844. * @returns the number of shapes in the system
  26845. */
  26846. addShape(mesh: Mesh, nb: number, options?: {
  26847. positionFunction?: any;
  26848. vertexFunction?: any;
  26849. }): number;
  26850. private _rebuildParticle;
  26851. /**
  26852. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26853. * @returns the SPS.
  26854. */
  26855. rebuildMesh(): SolidParticleSystem;
  26856. /**
  26857. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26858. * This method calls `updateParticle()` for each particle of the SPS.
  26859. * For an animated SPS, it is usually called within the render loop.
  26860. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26861. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26862. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26863. * @returns the SPS.
  26864. */
  26865. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26866. private _quaternionRotationYPR;
  26867. private _quaternionToRotationMatrix;
  26868. /**
  26869. * Disposes the SPS.
  26870. */
  26871. dispose(): void;
  26872. /**
  26873. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26874. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26875. * @returns the SPS.
  26876. */
  26877. refreshVisibleSize(): SolidParticleSystem;
  26878. /**
  26879. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26880. * @param size the size (float) of the visibility box
  26881. * note : this doesn't lock the SPS mesh bounding box.
  26882. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26883. */
  26884. setVisibilityBox(size: number): void;
  26885. /**
  26886. * Gets whether the SPS as always visible or not
  26887. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26888. */
  26889. /**
  26890. * Sets the SPS as always visible or not
  26891. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26892. */
  26893. isAlwaysVisible: boolean;
  26894. /**
  26895. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26896. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26897. */
  26898. /**
  26899. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26900. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26901. */
  26902. isVisibilityBoxLocked: boolean;
  26903. /**
  26904. * Tells to `setParticles()` to compute the particle rotations or not.
  26905. * Default value : true. The SPS is faster when it's set to false.
  26906. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26907. */
  26908. /**
  26909. * Gets if `setParticles()` computes the particle rotations or not.
  26910. * Default value : true. The SPS is faster when it's set to false.
  26911. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26912. */
  26913. computeParticleRotation: boolean;
  26914. /**
  26915. * Tells to `setParticles()` to compute the particle colors or not.
  26916. * Default value : true. The SPS is faster when it's set to false.
  26917. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26918. */
  26919. /**
  26920. * Gets if `setParticles()` computes the particle colors or not.
  26921. * Default value : true. The SPS is faster when it's set to false.
  26922. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26923. */
  26924. computeParticleColor: boolean;
  26925. /**
  26926. * Gets if `setParticles()` computes the particle textures or not.
  26927. * Default value : true. The SPS is faster when it's set to false.
  26928. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26929. */
  26930. computeParticleTexture: boolean;
  26931. /**
  26932. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26933. * Default value : false. The SPS is faster when it's set to false.
  26934. * Note : the particle custom vertex positions aren't stored values.
  26935. */
  26936. /**
  26937. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26938. * Default value : false. The SPS is faster when it's set to false.
  26939. * Note : the particle custom vertex positions aren't stored values.
  26940. */
  26941. computeParticleVertex: boolean;
  26942. /**
  26943. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26944. */
  26945. /**
  26946. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26947. */
  26948. computeBoundingBox: boolean;
  26949. /**
  26950. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26951. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26952. * Default : `true`
  26953. */
  26954. /**
  26955. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26956. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26957. * Default : `true`
  26958. */
  26959. depthSortParticles: boolean;
  26960. /**
  26961. * This function does nothing. It may be overwritten to set all the particle first values.
  26962. * The SPS doesn't call this function, you may have to call it by your own.
  26963. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26964. */
  26965. initParticles(): void;
  26966. /**
  26967. * This function does nothing. It may be overwritten to recycle a particle.
  26968. * The SPS doesn't call this function, you may have to call it by your own.
  26969. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26970. * @param particle The particle to recycle
  26971. * @returns the recycled particle
  26972. */
  26973. recycleParticle(particle: SolidParticle): SolidParticle;
  26974. /**
  26975. * Updates a particle : this function should be overwritten by the user.
  26976. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26977. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26978. * @example : just set a particle position or velocity and recycle conditions
  26979. * @param particle The particle to update
  26980. * @returns the updated particle
  26981. */
  26982. updateParticle(particle: SolidParticle): SolidParticle;
  26983. /**
  26984. * Updates a vertex of a particle : it can be overwritten by the user.
  26985. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26986. * @param particle the current particle
  26987. * @param vertex the current index of the current particle
  26988. * @param pt the index of the current vertex in the particle shape
  26989. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  26990. * @example : just set a vertex particle position
  26991. * @returns the updated vertex
  26992. */
  26993. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26994. /**
  26995. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26996. * This does nothing and may be overwritten by the user.
  26997. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26998. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26999. * @param update the boolean update value actually passed to setParticles()
  27000. */
  27001. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27002. /**
  27003. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27004. * This will be passed three parameters.
  27005. * This does nothing and may be overwritten by the user.
  27006. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27007. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27008. * @param update the boolean update value actually passed to setParticles()
  27009. */
  27010. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27011. }
  27012. }
  27013. declare module BABYLON {
  27014. /**
  27015. * Type of sub emitter
  27016. */
  27017. enum SubEmitterType {
  27018. /**
  27019. * Attached to the particle over it's lifetime
  27020. */
  27021. ATTACHED = 0,
  27022. /**
  27023. * Created when the particle dies
  27024. */
  27025. END = 1
  27026. }
  27027. /**
  27028. * Sub emitter class used to emit particles from an existing particle
  27029. */
  27030. class SubEmitter {
  27031. /**
  27032. * the particle system to be used by the sub emitter
  27033. */
  27034. particleSystem: ParticleSystem;
  27035. /**
  27036. * Type of the submitter (Default: END)
  27037. */
  27038. type: SubEmitterType;
  27039. /**
  27040. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  27041. * Note: This only is supported when using an emitter of type Mesh
  27042. */
  27043. inheritDirection: boolean;
  27044. /**
  27045. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  27046. */
  27047. inheritedVelocityAmount: number;
  27048. /**
  27049. * Creates a sub emitter
  27050. * @param particleSystem the particle system to be used by the sub emitter
  27051. */
  27052. constructor(
  27053. /**
  27054. * the particle system to be used by the sub emitter
  27055. */
  27056. particleSystem: ParticleSystem);
  27057. /**
  27058. * Clones the sub emitter
  27059. * @returns the cloned sub emitter
  27060. */
  27061. clone(): SubEmitter;
  27062. }
  27063. }
  27064. declare module BABYLON {
  27065. interface PhysicsImpostorJoint {
  27066. mainImpostor: PhysicsImpostor;
  27067. connectedImpostor: PhysicsImpostor;
  27068. joint: PhysicsJoint;
  27069. }
  27070. class PhysicsEngine {
  27071. private _physicsPlugin;
  27072. gravity: Vector3;
  27073. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  27074. setGravity(gravity: Vector3): void;
  27075. /**
  27076. * Set the time step of the physics engine.
  27077. * default is 1/60.
  27078. * To slow it down, enter 1/600 for example.
  27079. * To speed it up, 1/30
  27080. * @param {number} newTimeStep the new timestep to apply to this world.
  27081. */
  27082. setTimeStep(newTimeStep?: number): void;
  27083. /**
  27084. * Get the time step of the physics engine.
  27085. */
  27086. getTimeStep(): number;
  27087. dispose(): void;
  27088. getPhysicsPluginName(): string;
  27089. static Epsilon: number;
  27090. private _impostors;
  27091. private _joints;
  27092. /**
  27093. * Adding a new impostor for the impostor tracking.
  27094. * This will be done by the impostor itself.
  27095. * @param {PhysicsImpostor} impostor the impostor to add
  27096. */
  27097. addImpostor(impostor: PhysicsImpostor): void;
  27098. /**
  27099. * Remove an impostor from the engine.
  27100. * This impostor and its mesh will not longer be updated by the physics engine.
  27101. * @param {PhysicsImpostor} impostor the impostor to remove
  27102. */
  27103. removeImpostor(impostor: PhysicsImpostor): void;
  27104. /**
  27105. * Add a joint to the physics engine
  27106. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  27107. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  27108. * @param {PhysicsJoint} the joint that will connect both impostors.
  27109. */
  27110. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27111. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27112. /**
  27113. * Called by the scene. no need to call it.
  27114. * @hidden
  27115. */
  27116. _step(delta: number): void;
  27117. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27118. getImpostors(): Array<PhysicsImpostor>;
  27119. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27120. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27121. }
  27122. interface IPhysicsEnginePlugin {
  27123. world: any;
  27124. name: string;
  27125. setGravity(gravity: Vector3): void;
  27126. setTimeStep(timeStep: number): void;
  27127. getTimeStep(): number;
  27128. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27129. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27130. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27131. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27132. removePhysicsBody(impostor: PhysicsImpostor): void;
  27133. generateJoint(joint: PhysicsImpostorJoint): void;
  27134. removeJoint(joint: PhysicsImpostorJoint): void;
  27135. isSupported(): boolean;
  27136. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27137. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27138. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27139. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27140. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27141. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27142. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27143. getBodyMass(impostor: PhysicsImpostor): number;
  27144. getBodyFriction(impostor: PhysicsImpostor): number;
  27145. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27146. getBodyRestitution(impostor: PhysicsImpostor): number;
  27147. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27148. sleepBody(impostor: PhysicsImpostor): void;
  27149. wakeUpBody(impostor: PhysicsImpostor): void;
  27150. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27151. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27152. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27153. getRadius(impostor: PhysicsImpostor): number;
  27154. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27155. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27156. dispose(): void;
  27157. }
  27158. }
  27159. declare module BABYLON {
  27160. class PhysicsHelper {
  27161. private _scene;
  27162. private _physicsEngine;
  27163. constructor(scene: Scene);
  27164. /**
  27165. * @param {Vector3} origin the origin of the explosion
  27166. * @param {number} radius the explosion radius
  27167. * @param {number} strength the explosion strength
  27168. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  27169. */
  27170. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  27171. /**
  27172. * @param {Vector3} origin the origin of the explosion
  27173. * @param {number} radius the explosion radius
  27174. * @param {number} strength the explosion strength
  27175. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  27176. */
  27177. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  27178. /**
  27179. * @param {Vector3} origin the origin of the explosion
  27180. * @param {number} radius the explosion radius
  27181. * @param {number} strength the explosion strength
  27182. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  27183. */
  27184. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  27185. /**
  27186. * @param {Vector3} origin the origin of the updraft
  27187. * @param {number} radius the radius of the updraft
  27188. * @param {number} strength the strength of the updraft
  27189. * @param {number} height the height of the updraft
  27190. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  27191. */
  27192. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  27193. /**
  27194. * @param {Vector3} origin the of the vortex
  27195. * @param {number} radius the radius of the vortex
  27196. * @param {number} strength the strength of the vortex
  27197. * @param {number} height the height of the vortex
  27198. */
  27199. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  27200. }
  27201. /***** Radial explosion *****/
  27202. class PhysicsRadialExplosionEvent {
  27203. private _scene;
  27204. private _sphere;
  27205. private _sphereOptions;
  27206. private _rays;
  27207. private _dataFetched;
  27208. constructor(scene: Scene);
  27209. /**
  27210. * Returns the data related to the radial explosion event (sphere & rays).
  27211. * @returns {PhysicsRadialExplosionEventData}
  27212. */
  27213. getData(): PhysicsRadialExplosionEventData;
  27214. /**
  27215. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  27216. * @param impostor
  27217. * @param {Vector3} origin the origin of the explosion
  27218. * @param {number} radius the explosion radius
  27219. * @param {number} strength the explosion strength
  27220. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  27221. * @returns {Nullable<PhysicsForceAndContactPoint>}
  27222. */
  27223. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  27224. /**
  27225. * Disposes the sphere.
  27226. * @param {bolean} force
  27227. */
  27228. dispose(force?: boolean): void;
  27229. /*** Helpers ***/
  27230. private _prepareSphere;
  27231. private _intersectsWithSphere;
  27232. }
  27233. /***** Gravitational Field *****/
  27234. class PhysicsGravitationalFieldEvent {
  27235. private _physicsHelper;
  27236. private _scene;
  27237. private _origin;
  27238. private _radius;
  27239. private _strength;
  27240. private _falloff;
  27241. private _tickCallback;
  27242. private _sphere;
  27243. private _dataFetched;
  27244. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  27245. /**
  27246. * Returns the data related to the gravitational field event (sphere).
  27247. * @returns {PhysicsGravitationalFieldEventData}
  27248. */
  27249. getData(): PhysicsGravitationalFieldEventData;
  27250. /**
  27251. * Enables the gravitational field.
  27252. */
  27253. enable(): void;
  27254. /**
  27255. * Disables the gravitational field.
  27256. */
  27257. disable(): void;
  27258. /**
  27259. * Disposes the sphere.
  27260. * @param {bolean} force
  27261. */
  27262. dispose(force?: boolean): void;
  27263. private _tick;
  27264. }
  27265. /***** Updraft *****/
  27266. class PhysicsUpdraftEvent {
  27267. private _scene;
  27268. private _origin;
  27269. private _radius;
  27270. private _strength;
  27271. private _height;
  27272. private _updraftMode;
  27273. private _physicsEngine;
  27274. private _originTop;
  27275. private _originDirection;
  27276. private _tickCallback;
  27277. private _cylinder;
  27278. private _cylinderPosition;
  27279. private _dataFetched;
  27280. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  27281. /**
  27282. * Returns the data related to the updraft event (cylinder).
  27283. * @returns {PhysicsUpdraftEventData}
  27284. */
  27285. getData(): PhysicsUpdraftEventData;
  27286. /**
  27287. * Enables the updraft.
  27288. */
  27289. enable(): void;
  27290. /**
  27291. * Disables the cortex.
  27292. */
  27293. disable(): void;
  27294. /**
  27295. * Disposes the sphere.
  27296. * @param {bolean} force
  27297. */
  27298. dispose(force?: boolean): void;
  27299. private getImpostorForceAndContactPoint;
  27300. private _tick;
  27301. /*** Helpers ***/
  27302. private _prepareCylinder;
  27303. private _intersectsWithCylinder;
  27304. }
  27305. /***** Vortex *****/
  27306. class PhysicsVortexEvent {
  27307. private _scene;
  27308. private _origin;
  27309. private _radius;
  27310. private _strength;
  27311. private _height;
  27312. private _physicsEngine;
  27313. private _originTop;
  27314. private _centripetalForceThreshold;
  27315. private _updraftMultiplier;
  27316. private _tickCallback;
  27317. private _cylinder;
  27318. private _cylinderPosition;
  27319. private _dataFetched;
  27320. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  27321. /**
  27322. * Returns the data related to the vortex event (cylinder).
  27323. * @returns {PhysicsVortexEventData}
  27324. */
  27325. getData(): PhysicsVortexEventData;
  27326. /**
  27327. * Enables the vortex.
  27328. */
  27329. enable(): void;
  27330. /**
  27331. * Disables the cortex.
  27332. */
  27333. disable(): void;
  27334. /**
  27335. * Disposes the sphere.
  27336. * @param {bolean} force
  27337. */
  27338. dispose(force?: boolean): void;
  27339. private getImpostorForceAndContactPoint;
  27340. private _tick;
  27341. /*** Helpers ***/
  27342. private _prepareCylinder;
  27343. private _intersectsWithCylinder;
  27344. }
  27345. /***** Enums *****/
  27346. /**
  27347. * The strenght of the force in correspondence to the distance of the affected object
  27348. */
  27349. enum PhysicsRadialImpulseFalloff {
  27350. /** Defines that impulse is constant in strength across it's whole radius */
  27351. Constant = 0,
  27352. /** DEfines that impulse gets weaker if it's further from the origin */
  27353. Linear = 1
  27354. }
  27355. /**
  27356. * The strenght of the force in correspondence to the distance of the affected object
  27357. */
  27358. enum PhysicsUpdraftMode {
  27359. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  27360. Center = 0,
  27361. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  27362. Perpendicular = 1
  27363. }
  27364. /***** Data interfaces *****/
  27365. interface PhysicsForceAndContactPoint {
  27366. force: Vector3;
  27367. contactPoint: Vector3;
  27368. }
  27369. interface PhysicsRadialExplosionEventData {
  27370. sphere: Mesh;
  27371. rays: Array<Ray>;
  27372. }
  27373. interface PhysicsGravitationalFieldEventData {
  27374. sphere: Mesh;
  27375. }
  27376. interface PhysicsUpdraftEventData {
  27377. cylinder: Mesh;
  27378. }
  27379. interface PhysicsVortexEventData {
  27380. cylinder: Mesh;
  27381. }
  27382. }
  27383. declare module BABYLON {
  27384. interface PhysicsImpostorParameters {
  27385. mass: number;
  27386. friction?: number;
  27387. restitution?: number;
  27388. nativeOptions?: any;
  27389. ignoreParent?: boolean;
  27390. disableBidirectionalTransformation?: boolean;
  27391. }
  27392. interface IPhysicsEnabledObject {
  27393. position: Vector3;
  27394. rotationQuaternion: Nullable<Quaternion>;
  27395. scaling: Vector3;
  27396. rotation?: Vector3;
  27397. parent?: any;
  27398. getBoundingInfo(): BoundingInfo;
  27399. computeWorldMatrix(force: boolean): Matrix;
  27400. getWorldMatrix?(): Matrix;
  27401. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27402. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27403. getIndices?(): Nullable<IndicesArray>;
  27404. getScene?(): Scene;
  27405. getAbsolutePosition(): Vector3;
  27406. getAbsolutePivotPoint(): Vector3;
  27407. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27408. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27409. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27410. getClassName(): string;
  27411. }
  27412. class PhysicsImpostor {
  27413. object: IPhysicsEnabledObject;
  27414. type: number;
  27415. private _options;
  27416. private _scene?;
  27417. static DEFAULT_OBJECT_SIZE: Vector3;
  27418. static IDENTITY_QUATERNION: Quaternion;
  27419. private _physicsEngine;
  27420. private _physicsBody;
  27421. private _bodyUpdateRequired;
  27422. private _onBeforePhysicsStepCallbacks;
  27423. private _onAfterPhysicsStepCallbacks;
  27424. private _onPhysicsCollideCallbacks;
  27425. private _deltaPosition;
  27426. private _deltaRotation;
  27427. private _deltaRotationConjugated;
  27428. private _parent;
  27429. private _isDisposed;
  27430. private static _tmpVecs;
  27431. private static _tmpQuat;
  27432. readonly isDisposed: boolean;
  27433. mass: number;
  27434. friction: number;
  27435. restitution: number;
  27436. uniqueId: number;
  27437. private _joints;
  27438. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27439. /**
  27440. * This function will completly initialize this impostor.
  27441. * It will create a new body - but only if this mesh has no parent.
  27442. * If it has, this impostor will not be used other than to define the impostor
  27443. * of the child mesh.
  27444. * @hidden
  27445. */
  27446. _init(): void;
  27447. private _getPhysicsParent;
  27448. /**
  27449. * Should a new body be generated.
  27450. */
  27451. isBodyInitRequired(): boolean;
  27452. setScalingUpdated(updated: boolean): void;
  27453. /**
  27454. * Force a regeneration of this or the parent's impostor's body.
  27455. * Use under cautious - This will remove all joints already implemented.
  27456. */
  27457. forceUpdate(): void;
  27458. /**
  27459. * Gets the body that holds this impostor. Either its own, or its parent.
  27460. */
  27461. /**
  27462. * Set the physics body. Used mainly by the physics engine/plugin
  27463. */
  27464. physicsBody: any;
  27465. parent: Nullable<PhysicsImpostor>;
  27466. resetUpdateFlags(): void;
  27467. getObjectExtendSize(): Vector3;
  27468. getObjectCenter(): Vector3;
  27469. /**
  27470. * Get a specific parametes from the options parameter.
  27471. */
  27472. getParam(paramName: string): any;
  27473. /**
  27474. * Sets a specific parameter in the options given to the physics plugin
  27475. */
  27476. setParam(paramName: string, value: number): void;
  27477. /**
  27478. * Specifically change the body's mass option. Won't recreate the physics body object
  27479. */
  27480. setMass(mass: number): void;
  27481. getLinearVelocity(): Nullable<Vector3>;
  27482. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27483. getAngularVelocity(): Nullable<Vector3>;
  27484. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27485. /**
  27486. * Execute a function with the physics plugin native code.
  27487. * Provide a function the will have two variables - the world object and the physics body object.
  27488. */
  27489. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27490. /**
  27491. * Register a function that will be executed before the physics world is stepping forward.
  27492. */
  27493. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27494. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27495. /**
  27496. * Register a function that will be executed after the physics step
  27497. */
  27498. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27499. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27500. /**
  27501. * register a function that will be executed when this impostor collides against a different body.
  27502. */
  27503. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27504. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27505. private _tmpQuat;
  27506. private _tmpQuat2;
  27507. getParentsRotation(): Quaternion;
  27508. /**
  27509. * this function is executed by the physics engine.
  27510. */
  27511. beforeStep: () => void;
  27512. /**
  27513. * this function is executed by the physics engine.
  27514. */
  27515. afterStep: () => void;
  27516. /**
  27517. * Legacy collision detection event support
  27518. */
  27519. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27520. onCollide: (e: {
  27521. body: any;
  27522. }) => void;
  27523. /**
  27524. * Apply a force
  27525. */
  27526. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27527. /**
  27528. * Apply an impulse
  27529. */
  27530. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27531. /**
  27532. * A help function to create a joint.
  27533. */
  27534. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27535. /**
  27536. * Add a joint to this impostor with a different impostor.
  27537. */
  27538. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27539. /**
  27540. * Will keep this body still, in a sleep mode.
  27541. */
  27542. sleep(): PhysicsImpostor;
  27543. /**
  27544. * Wake the body up.
  27545. */
  27546. wakeUp(): PhysicsImpostor;
  27547. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27548. dispose(): void;
  27549. setDeltaPosition(position: Vector3): void;
  27550. setDeltaRotation(rotation: Quaternion): void;
  27551. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27552. getRadius(): number;
  27553. /**
  27554. * Sync a bone with this impostor
  27555. * @param bone The bone to sync to the impostor.
  27556. * @param boneMesh The mesh that the bone is influencing.
  27557. * @param jointPivot The pivot of the joint / bone in local space.
  27558. * @param distToJoint Optional distance from the impostor to the joint.
  27559. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27560. */
  27561. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27562. /**
  27563. * Sync impostor to a bone
  27564. * @param bone The bone that the impostor will be synced to.
  27565. * @param boneMesh The mesh that the bone is influencing.
  27566. * @param jointPivot The pivot of the joint / bone in local space.
  27567. * @param distToJoint Optional distance from the impostor to the joint.
  27568. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27569. * @param boneAxis Optional vector3 axis the bone is aligned with
  27570. */
  27571. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27572. static NoImpostor: number;
  27573. static SphereImpostor: number;
  27574. static BoxImpostor: number;
  27575. static PlaneImpostor: number;
  27576. static MeshImpostor: number;
  27577. static CylinderImpostor: number;
  27578. static ParticleImpostor: number;
  27579. static HeightmapImpostor: number;
  27580. }
  27581. }
  27582. declare module BABYLON {
  27583. interface PhysicsJointData {
  27584. mainPivot?: Vector3;
  27585. connectedPivot?: Vector3;
  27586. mainAxis?: Vector3;
  27587. connectedAxis?: Vector3;
  27588. collision?: boolean;
  27589. nativeParams?: any;
  27590. }
  27591. /**
  27592. * This is a holder class for the physics joint created by the physics plugin.
  27593. * It holds a set of functions to control the underlying joint.
  27594. */
  27595. class PhysicsJoint {
  27596. type: number;
  27597. jointData: PhysicsJointData;
  27598. private _physicsJoint;
  27599. protected _physicsPlugin: IPhysicsEnginePlugin;
  27600. constructor(type: number, jointData: PhysicsJointData);
  27601. physicsJoint: any;
  27602. physicsPlugin: IPhysicsEnginePlugin;
  27603. /**
  27604. * Execute a function that is physics-plugin specific.
  27605. * @param {Function} func the function that will be executed.
  27606. * It accepts two parameters: the physics world and the physics joint.
  27607. */
  27608. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27609. static DistanceJoint: number;
  27610. static HingeJoint: number;
  27611. static BallAndSocketJoint: number;
  27612. static WheelJoint: number;
  27613. static SliderJoint: number;
  27614. static PrismaticJoint: number;
  27615. static UniversalJoint: number;
  27616. static Hinge2Joint: number;
  27617. static PointToPointJoint: number;
  27618. static SpringJoint: number;
  27619. static LockJoint: number;
  27620. }
  27621. /**
  27622. * A class representing a physics distance joint.
  27623. */
  27624. class DistanceJoint extends PhysicsJoint {
  27625. constructor(jointData: DistanceJointData);
  27626. /**
  27627. * Update the predefined distance.
  27628. */
  27629. updateDistance(maxDistance: number, minDistance?: number): void;
  27630. }
  27631. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27632. constructor(type: number, jointData: PhysicsJointData);
  27633. /**
  27634. * Set the motor values.
  27635. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27636. * @param {number} force the force to apply
  27637. * @param {number} maxForce max force for this motor.
  27638. */
  27639. setMotor(force?: number, maxForce?: number): void;
  27640. /**
  27641. * Set the motor's limits.
  27642. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27643. */
  27644. setLimit(upperLimit: number, lowerLimit?: number): void;
  27645. }
  27646. /**
  27647. * This class represents a single hinge physics joint
  27648. */
  27649. class HingeJoint extends MotorEnabledJoint {
  27650. constructor(jointData: PhysicsJointData);
  27651. /**
  27652. * Set the motor values.
  27653. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27654. * @param {number} force the force to apply
  27655. * @param {number} maxForce max force for this motor.
  27656. */
  27657. setMotor(force?: number, maxForce?: number): void;
  27658. /**
  27659. * Set the motor's limits.
  27660. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27661. */
  27662. setLimit(upperLimit: number, lowerLimit?: number): void;
  27663. }
  27664. /**
  27665. * This class represents a dual hinge physics joint (same as wheel joint)
  27666. */
  27667. class Hinge2Joint extends MotorEnabledJoint {
  27668. constructor(jointData: PhysicsJointData);
  27669. /**
  27670. * Set the motor values.
  27671. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27672. * @param {number} force the force to apply
  27673. * @param {number} maxForce max force for this motor.
  27674. * @param {motorIndex} the motor's index, 0 or 1.
  27675. */
  27676. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27677. /**
  27678. * Set the motor limits.
  27679. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27680. * @param {number} upperLimit the upper limit
  27681. * @param {number} lowerLimit lower limit
  27682. * @param {motorIndex} the motor's index, 0 or 1.
  27683. */
  27684. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27685. }
  27686. interface IMotorEnabledJoint {
  27687. physicsJoint: any;
  27688. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27689. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27690. }
  27691. interface DistanceJointData extends PhysicsJointData {
  27692. maxDistance: number;
  27693. }
  27694. interface SpringJointData extends PhysicsJointData {
  27695. length: number;
  27696. stiffness: number;
  27697. damping: number;
  27698. /** this callback will be called when applying the force to the impostors. */
  27699. forceApplicationCallback: () => void;
  27700. }
  27701. }
  27702. declare module BABYLON {
  27703. /**
  27704. * Postprocess used to generate anaglyphic rendering
  27705. */
  27706. class AnaglyphPostProcess extends PostProcess {
  27707. private _passedProcess;
  27708. /**
  27709. * Creates a new AnaglyphPostProcess
  27710. * @param name defines postprocess name
  27711. * @param options defines creation options or target ratio scale
  27712. * @param rigCameras defines cameras using this postprocess
  27713. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  27714. * @param engine defines hosting engine
  27715. * @param reusable defines if the postprocess will be reused multiple times per frame
  27716. */
  27717. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  27718. }
  27719. }
  27720. declare module BABYLON {
  27721. class BlackAndWhitePostProcess extends PostProcess {
  27722. degree: number;
  27723. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27724. }
  27725. }
  27726. declare module BABYLON {
  27727. /**
  27728. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  27729. */
  27730. class BloomEffect extends PostProcessRenderEffect {
  27731. private bloomScale;
  27732. /**
  27733. * @hidden Internal
  27734. */
  27735. _effects: Array<PostProcess>;
  27736. /**
  27737. * @hidden Internal
  27738. */
  27739. _downscale: ExtractHighlightsPostProcess;
  27740. private _blurX;
  27741. private _blurY;
  27742. private _merge;
  27743. /**
  27744. * The luminance threshold to find bright areas of the image to bloom.
  27745. */
  27746. threshold: number;
  27747. /**
  27748. * The strength of the bloom.
  27749. */
  27750. weight: number;
  27751. /**
  27752. * Specifies the size of the bloom blur kernel, relative to the final output size
  27753. */
  27754. kernel: number;
  27755. /**
  27756. * Creates a new instance of @see BloomEffect
  27757. * @param scene The scene the effect belongs to.
  27758. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  27759. * @param bloomKernel The size of the kernel to be used when applying the blur.
  27760. * @param bloomWeight The the strength of bloom.
  27761. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27762. * @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)
  27763. */
  27764. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  27765. /**
  27766. * Disposes each of the internal effects for a given camera.
  27767. * @param camera The camera to dispose the effect on.
  27768. */
  27769. disposeEffects(camera: Camera): void;
  27770. /**
  27771. * @hidden Internal
  27772. */
  27773. _updateEffects(): void;
  27774. /**
  27775. * Internal
  27776. * @returns if all the contained post processes are ready.
  27777. * @hidden
  27778. */
  27779. _isReady(): boolean;
  27780. }
  27781. }
  27782. declare module BABYLON {
  27783. /**
  27784. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27785. */
  27786. class BloomMergePostProcess extends PostProcess {
  27787. /** Weight of the bloom to be added to the original input. */
  27788. weight: number;
  27789. /**
  27790. * Creates a new instance of @see BloomMergePostProcess
  27791. * @param name The name of the effect.
  27792. * @param originalFromInput Post process which's input will be used for the merge.
  27793. * @param blurred Blurred highlights post process which's output will be used.
  27794. * @param weight Weight of the bloom to be added to the original input.
  27795. * @param options The required width/height ratio to downsize to before computing the render pass.
  27796. * @param camera The camera to apply the render pass to.
  27797. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27798. * @param engine The engine which the post process will be applied. (default: current engine)
  27799. * @param reusable If the post process can be reused on the same frame. (default: false)
  27800. * @param textureType Type of textures used when performing the post process. (default: 0)
  27801. * @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)
  27802. */
  27803. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  27804. /** Weight of the bloom to be added to the original input. */
  27805. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27806. }
  27807. }
  27808. declare module BABYLON {
  27809. /**
  27810. * The Blur Post Process which blurs an image based on a kernel and direction.
  27811. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  27812. */
  27813. class BlurPostProcess extends PostProcess {
  27814. /** The direction in which to blur the image. */
  27815. direction: Vector2;
  27816. private blockCompilation;
  27817. protected _kernel: number;
  27818. protected _idealKernel: number;
  27819. protected _packedFloat: boolean;
  27820. private _staticDefines;
  27821. /**
  27822. * Sets the length in pixels of the blur sample region
  27823. */
  27824. /**
  27825. * Gets the length in pixels of the blur sample region
  27826. */
  27827. kernel: number;
  27828. /**
  27829. * Sets wether or not the blur needs to unpack/repack floats
  27830. */
  27831. /**
  27832. * Gets wether or not the blur is unpacking/repacking floats
  27833. */
  27834. packedFloat: boolean;
  27835. /**
  27836. * Creates a new instance BlurPostProcess
  27837. * @param name The name of the effect.
  27838. * @param direction The direction in which to blur the image.
  27839. * @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.
  27840. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27841. * @param camera The camera to apply the render pass to.
  27842. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27843. * @param engine The engine which the post process will be applied. (default: current engine)
  27844. * @param reusable If the post process can be reused on the same frame. (default: false)
  27845. * @param textureType Type of textures used when performing the post process. (default: 0)
  27846. * @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)
  27847. */
  27848. constructor(name: string,
  27849. /** The direction in which to blur the image. */
  27850. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  27851. /**
  27852. * Updates the effect with the current post process compile time values and recompiles the shader.
  27853. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27854. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27855. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27856. * @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
  27857. * @param onCompiled Called when the shader has been compiled.
  27858. * @param onError Called if there is an error when compiling a shader.
  27859. */
  27860. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27861. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27862. /**
  27863. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  27864. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  27865. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  27866. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  27867. * The gaps between physical kernels are compensated for in the weighting of the samples
  27868. * @param idealKernel Ideal blur kernel.
  27869. * @return Nearest best kernel.
  27870. */
  27871. protected _nearestBestKernel(idealKernel: number): number;
  27872. /**
  27873. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  27874. * @param x The point on the Gaussian distribution to sample.
  27875. * @return the value of the Gaussian function at x.
  27876. */
  27877. protected _gaussianWeight(x: number): number;
  27878. /**
  27879. * Generates a string that can be used as a floating point number in GLSL.
  27880. * @param x Value to print.
  27881. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  27882. * @return GLSL float string.
  27883. */
  27884. protected _glslFloat(x: number, decimalFigures?: number): string;
  27885. }
  27886. }
  27887. declare module BABYLON {
  27888. /**
  27889. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  27890. */
  27891. class ChromaticAberrationPostProcess extends PostProcess {
  27892. /**
  27893. * The amount of seperation of rgb channels (default: 30)
  27894. */
  27895. aberrationAmount: number;
  27896. /**
  27897. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  27898. */
  27899. radialIntensity: number;
  27900. /**
  27901. * 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))
  27902. */
  27903. direction: Vector2;
  27904. /**
  27905. * 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))
  27906. */
  27907. centerPosition: Vector2;
  27908. /**
  27909. * Creates a new instance ChromaticAberrationPostProcess
  27910. * @param name The name of the effect.
  27911. * @param screenWidth The width of the screen to apply the effect on.
  27912. * @param screenHeight The height of the screen to apply the effect on.
  27913. * @param options The required width/height ratio to downsize to before computing the render pass.
  27914. * @param camera The camera to apply the render pass to.
  27915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27916. * @param engine The engine which the post process will be applied. (default: current engine)
  27917. * @param reusable If the post process can be reused on the same frame. (default: false)
  27918. * @param textureType Type of textures used when performing the post process. (default: 0)
  27919. * @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)
  27920. */
  27921. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27922. }
  27923. }
  27924. declare module BABYLON {
  27925. /**
  27926. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  27927. */
  27928. class CircleOfConfusionPostProcess extends PostProcess {
  27929. /**
  27930. * 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.
  27931. */
  27932. lensSize: number;
  27933. /**
  27934. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27935. */
  27936. fStop: number;
  27937. /**
  27938. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27939. */
  27940. focusDistance: number;
  27941. /**
  27942. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  27943. */
  27944. focalLength: number;
  27945. private _depthTexture;
  27946. /**
  27947. * Creates a new instance CircleOfConfusionPostProcess
  27948. * @param name The name of the effect.
  27949. * @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.
  27950. * @param options The required width/height ratio to downsize to before computing the render pass.
  27951. * @param camera The camera to apply the render pass to.
  27952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27953. * @param engine The engine which the post process will be applied. (default: current engine)
  27954. * @param reusable If the post process can be reused on the same frame. (default: false)
  27955. * @param textureType Type of textures used when performing the post process. (default: 0)
  27956. * @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)
  27957. */
  27958. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27959. /**
  27960. * 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.
  27961. */
  27962. depthTexture: RenderTargetTexture;
  27963. }
  27964. }
  27965. declare module BABYLON {
  27966. class ColorCorrectionPostProcess extends PostProcess {
  27967. private _colorTableTexture;
  27968. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27969. }
  27970. }
  27971. declare module BABYLON {
  27972. /**
  27973. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  27974. * input texture to perform effects such as edge detection or sharpening
  27975. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  27976. */
  27977. class ConvolutionPostProcess extends PostProcess {
  27978. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  27979. kernel: number[];
  27980. /**
  27981. * Creates a new instance ConvolutionPostProcess
  27982. * @param name The name of the effect.
  27983. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  27984. * @param options The required width/height ratio to downsize to before computing the render pass.
  27985. * @param camera The camera to apply the render pass to.
  27986. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27987. * @param engine The engine which the post process will be applied. (default: current engine)
  27988. * @param reusable If the post process can be reused on the same frame. (default: false)
  27989. * @param textureType Type of textures used when performing the post process. (default: 0)
  27990. */
  27991. constructor(name: string,
  27992. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  27993. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27994. /**
  27995. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27996. */
  27997. static EdgeDetect0Kernel: number[];
  27998. /**
  27999. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  28000. */
  28001. static EdgeDetect1Kernel: number[];
  28002. /**
  28003. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  28004. */
  28005. static EdgeDetect2Kernel: number[];
  28006. /**
  28007. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  28008. */
  28009. static SharpenKernel: number[];
  28010. /**
  28011. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  28012. */
  28013. static EmbossKernel: number[];
  28014. /**
  28015. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  28016. */
  28017. static GaussianKernel: number[];
  28018. }
  28019. }
  28020. declare module BABYLON {
  28021. /**
  28022. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  28023. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  28024. * based on samples that have a large difference in distance than the center pixel.
  28025. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  28026. */
  28027. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  28028. direction: Vector2;
  28029. /**
  28030. * Creates a new instance CircleOfConfusionPostProcess
  28031. * @param name The name of the effect.
  28032. * @param scene The scene the effect belongs to.
  28033. * @param direction The direction the blur should be applied.
  28034. * @param kernel The size of the kernel used to blur.
  28035. * @param options The required width/height ratio to downsize to before computing the render pass.
  28036. * @param camera The camera to apply the render pass to.
  28037. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  28038. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  28039. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28040. * @param engine The engine which the post process will be applied. (default: current engine)
  28041. * @param reusable If the post process can be reused on the same frame. (default: false)
  28042. * @param textureType Type of textures used when performing the post process. (default: 0)
  28043. * @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)
  28044. */
  28045. 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);
  28046. }
  28047. }
  28048. declare module BABYLON {
  28049. /**
  28050. * Specifies the level of max blur that should be applied when using the depth of field effect
  28051. */
  28052. enum DepthOfFieldEffectBlurLevel {
  28053. /**
  28054. * Subtle blur
  28055. */
  28056. Low = 0,
  28057. /**
  28058. * Medium blur
  28059. */
  28060. Medium = 1,
  28061. /**
  28062. * Large blur
  28063. */
  28064. High = 2
  28065. }
  28066. /**
  28067. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  28068. */
  28069. class DepthOfFieldEffect extends PostProcessRenderEffect {
  28070. private _circleOfConfusion;
  28071. /**
  28072. * @hidden Internal, blurs from high to low
  28073. */
  28074. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  28075. private _depthOfFieldBlurY;
  28076. private _dofMerge;
  28077. /**
  28078. * @hidden Internal post processes in depth of field effect
  28079. */
  28080. _effects: Array<PostProcess>;
  28081. /**
  28082. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  28083. */
  28084. focalLength: number;
  28085. /**
  28086. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  28087. */
  28088. fStop: number;
  28089. /**
  28090. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  28091. */
  28092. focusDistance: number;
  28093. /**
  28094. * 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.
  28095. */
  28096. lensSize: number;
  28097. /**
  28098. * Creates a new instance DepthOfFieldEffect
  28099. * @param scene The scene the effect belongs to.
  28100. * @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.
  28101. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  28102. * @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)
  28103. */
  28104. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  28105. /**
  28106. * 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.
  28107. */
  28108. depthTexture: RenderTargetTexture;
  28109. /**
  28110. * Disposes each of the internal effects for a given camera.
  28111. * @param camera The camera to dispose the effect on.
  28112. */
  28113. disposeEffects(camera: Camera): void;
  28114. /**
  28115. * @hidden Internal
  28116. */
  28117. _updateEffects(): void;
  28118. /**
  28119. * Internal
  28120. * @returns if all the contained post processes are ready.
  28121. * @hidden
  28122. */
  28123. _isReady(): boolean;
  28124. }
  28125. }
  28126. declare module BABYLON {
  28127. /**
  28128. * Options to be set when merging outputs from the default pipeline.
  28129. */
  28130. class DepthOfFieldMergePostProcessOptions {
  28131. /**
  28132. * The original image to merge on top of
  28133. */
  28134. originalFromInput: PostProcess;
  28135. /**
  28136. * Parameters to perform the merge of the depth of field effect
  28137. */
  28138. depthOfField?: {
  28139. circleOfConfusion: PostProcess;
  28140. blurSteps: Array<PostProcess>;
  28141. };
  28142. /**
  28143. * Parameters to perform the merge of bloom effect
  28144. */
  28145. bloom?: {
  28146. blurred: PostProcess;
  28147. weight: number;
  28148. };
  28149. }
  28150. /**
  28151. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  28152. */
  28153. class DepthOfFieldMergePostProcess extends PostProcess {
  28154. private blurSteps;
  28155. /**
  28156. * Creates a new instance of DepthOfFieldMergePostProcess
  28157. * @param name The name of the effect.
  28158. * @param originalFromInput Post process which's input will be used for the merge.
  28159. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  28160. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  28161. * @param options The required width/height ratio to downsize to before computing the render pass.
  28162. * @param camera The camera to apply the render pass to.
  28163. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28164. * @param engine The engine which the post process will be applied. (default: current engine)
  28165. * @param reusable If the post process can be reused on the same frame. (default: false)
  28166. * @param textureType Type of textures used when performing the post process. (default: 0)
  28167. * @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)
  28168. */
  28169. 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);
  28170. /**
  28171. * Updates the effect with the current post process compile time values and recompiles the shader.
  28172. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28173. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28174. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28175. * @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
  28176. * @param onCompiled Called when the shader has been compiled.
  28177. * @param onError Called if there is an error when compiling a shader.
  28178. */
  28179. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28180. }
  28181. }
  28182. declare module BABYLON {
  28183. class DisplayPassPostProcess extends PostProcess {
  28184. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28185. }
  28186. }
  28187. declare module BABYLON {
  28188. /**
  28189. * 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.
  28190. */
  28191. class ExtractHighlightsPostProcess extends PostProcess {
  28192. /**
  28193. * The luminance threshold, pixels below this value will be set to black.
  28194. */
  28195. threshold: number;
  28196. /** @hidden */
  28197. _exposure: number;
  28198. /**
  28199. * Post process which has the input texture to be used when performing highlight extraction
  28200. * @hidden
  28201. */
  28202. _inputPostProcess: Nullable<PostProcess>;
  28203. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28204. }
  28205. }
  28206. declare module BABYLON {
  28207. class FilterPostProcess extends PostProcess {
  28208. kernelMatrix: Matrix;
  28209. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28210. }
  28211. }
  28212. declare module BABYLON {
  28213. class FxaaPostProcess extends PostProcess {
  28214. texelWidth: number;
  28215. texelHeight: number;
  28216. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  28217. private _getDefines;
  28218. }
  28219. }
  28220. declare module BABYLON {
  28221. /**
  28222. * The GrainPostProcess adds noise to the image at mid luminance levels
  28223. */
  28224. class GrainPostProcess extends PostProcess {
  28225. /**
  28226. * The intensity of the grain added (default: 30)
  28227. */
  28228. intensity: number;
  28229. /**
  28230. * If the grain should be randomized on every frame
  28231. */
  28232. animated: boolean;
  28233. /**
  28234. * Creates a new instance of @see GrainPostProcess
  28235. * @param name The name of the effect.
  28236. * @param options The required width/height ratio to downsize to before computing the render pass.
  28237. * @param camera The camera to apply the render pass to.
  28238. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28239. * @param engine The engine which the post process will be applied. (default: current engine)
  28240. * @param reusable If the post process can be reused on the same frame. (default: false)
  28241. * @param textureType Type of textures used when performing the post process. (default: 0)
  28242. * @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)
  28243. */
  28244. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28245. }
  28246. }
  28247. declare module BABYLON {
  28248. class HighlightsPostProcess extends PostProcess {
  28249. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  28250. }
  28251. }
  28252. declare module BABYLON {
  28253. class ImageProcessingPostProcess extends PostProcess {
  28254. /**
  28255. * Default configuration related to image processing available in the PBR Material.
  28256. */
  28257. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  28258. /**
  28259. * Gets the image processing configuration used either in this material.
  28260. */
  28261. /**
  28262. * Sets the Default image processing configuration used either in the this material.
  28263. *
  28264. * If sets to null, the scene one is in use.
  28265. */
  28266. imageProcessingConfiguration: ImageProcessingConfiguration;
  28267. /**
  28268. * Keep track of the image processing observer to allow dispose and replace.
  28269. */
  28270. private _imageProcessingObserver;
  28271. /**
  28272. * Attaches a new image processing configuration to the PBR Material.
  28273. * @param configuration
  28274. */
  28275. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  28276. /**
  28277. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  28278. */
  28279. /**
  28280. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  28281. */
  28282. colorCurves: Nullable<ColorCurves>;
  28283. /**
  28284. * Gets wether the color curves effect is enabled.
  28285. */
  28286. /**
  28287. * Sets wether the color curves effect is enabled.
  28288. */
  28289. colorCurvesEnabled: boolean;
  28290. /**
  28291. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  28292. */
  28293. /**
  28294. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  28295. */
  28296. colorGradingTexture: Nullable<BaseTexture>;
  28297. /**
  28298. * Gets wether the color grading effect is enabled.
  28299. */
  28300. /**
  28301. * Gets wether the color grading effect is enabled.
  28302. */
  28303. colorGradingEnabled: boolean;
  28304. /**
  28305. * Gets exposure used in the effect.
  28306. */
  28307. /**
  28308. * Sets exposure used in the effect.
  28309. */
  28310. exposure: number;
  28311. /**
  28312. * Gets wether tonemapping is enabled or not.
  28313. */
  28314. /**
  28315. * Sets wether tonemapping is enabled or not
  28316. */
  28317. toneMappingEnabled: boolean;
  28318. /**
  28319. * Gets contrast used in the effect.
  28320. */
  28321. /**
  28322. * Sets contrast used in the effect.
  28323. */
  28324. contrast: number;
  28325. /**
  28326. * Gets Vignette stretch size.
  28327. */
  28328. /**
  28329. * Sets Vignette stretch size.
  28330. */
  28331. vignetteStretch: number;
  28332. /**
  28333. * Gets Vignette centre X Offset.
  28334. */
  28335. /**
  28336. * Sets Vignette centre X Offset.
  28337. */
  28338. vignetteCentreX: number;
  28339. /**
  28340. * Gets Vignette centre Y Offset.
  28341. */
  28342. /**
  28343. * Sets Vignette centre Y Offset.
  28344. */
  28345. vignetteCentreY: number;
  28346. /**
  28347. * Gets Vignette weight or intensity of the vignette effect.
  28348. */
  28349. /**
  28350. * Sets Vignette weight or intensity of the vignette effect.
  28351. */
  28352. vignetteWeight: number;
  28353. /**
  28354. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  28355. * if vignetteEnabled is set to true.
  28356. */
  28357. /**
  28358. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  28359. * if vignetteEnabled is set to true.
  28360. */
  28361. vignetteColor: Color4;
  28362. /**
  28363. * Gets Camera field of view used by the Vignette effect.
  28364. */
  28365. /**
  28366. * Sets Camera field of view used by the Vignette effect.
  28367. */
  28368. vignetteCameraFov: number;
  28369. /**
  28370. * Gets the vignette blend mode allowing different kind of effect.
  28371. */
  28372. /**
  28373. * Sets the vignette blend mode allowing different kind of effect.
  28374. */
  28375. vignetteBlendMode: number;
  28376. /**
  28377. * Gets wether the vignette effect is enabled.
  28378. */
  28379. /**
  28380. * Sets wether the vignette effect is enabled.
  28381. */
  28382. vignetteEnabled: boolean;
  28383. private _fromLinearSpace;
  28384. /**
  28385. * Gets wether the input of the processing is in Gamma or Linear Space.
  28386. */
  28387. /**
  28388. * Sets wether the input of the processing is in Gamma or Linear Space.
  28389. */
  28390. fromLinearSpace: boolean;
  28391. /**
  28392. * Defines cache preventing GC.
  28393. */
  28394. private _defines;
  28395. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  28396. getClassName(): string;
  28397. protected _updateParameters(): void;
  28398. dispose(camera?: Camera): void;
  28399. }
  28400. }
  28401. declare module BABYLON {
  28402. class PassPostProcess extends PostProcess {
  28403. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28404. }
  28405. }
  28406. declare module BABYLON {
  28407. type PostProcessOptions = {
  28408. width: number;
  28409. height: number;
  28410. };
  28411. /**
  28412. * PostProcess can be used to apply a shader to a texture after it has been rendered
  28413. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28414. */
  28415. class PostProcess {
  28416. /** Name of the PostProcess. */
  28417. name: string;
  28418. /**
  28419. * Width of the texture to apply the post process on
  28420. */
  28421. width: number;
  28422. /**
  28423. * Height of the texture to apply the post process on
  28424. */
  28425. height: number;
  28426. /**
  28427. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  28428. * @hidden
  28429. */
  28430. _outputTexture: Nullable<InternalTexture>;
  28431. /**
  28432. * Sampling mode used by the shader
  28433. * See https://doc.babylonjs.com/classes/3.1/texture
  28434. */
  28435. renderTargetSamplingMode: number;
  28436. /**
  28437. * Clear color to use when screen clearing
  28438. */
  28439. clearColor: Color4;
  28440. /**
  28441. * If the buffer needs to be cleared before applying the post process. (default: true)
  28442. * Should be set to false if shader will overwrite all previous pixels.
  28443. */
  28444. autoClear: boolean;
  28445. /**
  28446. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  28447. */
  28448. alphaMode: number;
  28449. /**
  28450. * Sets the setAlphaBlendConstants of the babylon engine
  28451. */
  28452. alphaConstants: Color4;
  28453. /**
  28454. * Animations to be used for the post processing
  28455. */
  28456. animations: Animation[];
  28457. /**
  28458. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  28459. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  28460. */
  28461. enablePixelPerfectMode: boolean;
  28462. /**
  28463. * Force the postprocess to be applied without taking in account viewport
  28464. */
  28465. forceFullscreenViewport: boolean;
  28466. /**
  28467. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  28468. *
  28469. * | Value | Type | Description |
  28470. * | ----- | ----------------------------------- | ----------- |
  28471. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  28472. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  28473. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  28474. *
  28475. */
  28476. scaleMode: number;
  28477. /**
  28478. * Force textures to be a power of two (default: false)
  28479. */
  28480. alwaysForcePOT: boolean;
  28481. private _samples;
  28482. /**
  28483. * Number of sample textures (default: 1)
  28484. */
  28485. samples: number;
  28486. /**
  28487. * Modify the scale of the post process to be the same as the viewport (default: false)
  28488. */
  28489. adaptScaleToCurrentViewport: boolean;
  28490. private _camera;
  28491. private _scene;
  28492. private _engine;
  28493. private _options;
  28494. private _reusable;
  28495. private _textureType;
  28496. /**
  28497. * Smart array of input and output textures for the post process.
  28498. * @hidden
  28499. */
  28500. _textures: SmartArray<InternalTexture>;
  28501. /**
  28502. * The index in _textures that corresponds to the output texture.
  28503. * @hidden
  28504. */
  28505. _currentRenderTextureInd: number;
  28506. private _effect;
  28507. private _samplers;
  28508. private _fragmentUrl;
  28509. private _vertexUrl;
  28510. private _parameters;
  28511. private _scaleRatio;
  28512. protected _indexParameters: any;
  28513. private _shareOutputWithPostProcess;
  28514. private _texelSize;
  28515. private _forcedOutputTexture;
  28516. /**
  28517. * An event triggered when the postprocess is activated.
  28518. */
  28519. onActivateObservable: Observable<Camera>;
  28520. private _onActivateObserver;
  28521. /**
  28522. * A function that is added to the onActivateObservable
  28523. */
  28524. onActivate: Nullable<(camera: Camera) => void>;
  28525. /**
  28526. * An event triggered when the postprocess changes its size.
  28527. */
  28528. onSizeChangedObservable: Observable<PostProcess>;
  28529. private _onSizeChangedObserver;
  28530. /**
  28531. * A function that is added to the onSizeChangedObservable
  28532. */
  28533. onSizeChanged: (postProcess: PostProcess) => void;
  28534. /**
  28535. * An event triggered when the postprocess applies its effect.
  28536. */
  28537. onApplyObservable: Observable<Effect>;
  28538. private _onApplyObserver;
  28539. /**
  28540. * A function that is added to the onApplyObservable
  28541. */
  28542. onApply: (effect: Effect) => void;
  28543. /**
  28544. * An event triggered before rendering the postprocess
  28545. */
  28546. onBeforeRenderObservable: Observable<Effect>;
  28547. private _onBeforeRenderObserver;
  28548. /**
  28549. * A function that is added to the onBeforeRenderObservable
  28550. */
  28551. onBeforeRender: (effect: Effect) => void;
  28552. /**
  28553. * An event triggered after rendering the postprocess
  28554. */
  28555. onAfterRenderObservable: Observable<Effect>;
  28556. private _onAfterRenderObserver;
  28557. /**
  28558. * A function that is added to the onAfterRenderObservable
  28559. */
  28560. onAfterRender: (efect: Effect) => void;
  28561. /**
  28562. * 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
  28563. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  28564. */
  28565. inputTexture: InternalTexture;
  28566. /**
  28567. * Gets the camera which post process is applied to.
  28568. * @returns The camera the post process is applied to.
  28569. */
  28570. getCamera(): Camera;
  28571. /**
  28572. * Gets the texel size of the postprocess.
  28573. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  28574. */
  28575. readonly texelSize: Vector2;
  28576. /**
  28577. * Creates a new instance PostProcess
  28578. * @param name The name of the PostProcess.
  28579. * @param fragmentUrl The url of the fragment shader to be used.
  28580. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  28581. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  28582. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28583. * @param camera The camera to apply the render pass to.
  28584. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28585. * @param engine The engine which the post process will be applied. (default: current engine)
  28586. * @param reusable If the post process can be reused on the same frame. (default: false)
  28587. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  28588. * @param textureType Type of textures used when performing the post process. (default: 0)
  28589. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  28590. * @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
  28591. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  28592. */
  28593. constructor(
  28594. /** Name of the PostProcess. */
  28595. 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);
  28596. /**
  28597. * Gets the engine which this post process belongs to.
  28598. * @returns The engine the post process was enabled with.
  28599. */
  28600. getEngine(): Engine;
  28601. /**
  28602. * The effect that is created when initializing the post process.
  28603. * @returns The created effect corrisponding the the postprocess.
  28604. */
  28605. getEffect(): Effect;
  28606. /**
  28607. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  28608. * @param postProcess The post process to share the output with.
  28609. * @returns This post process.
  28610. */
  28611. shareOutputWith(postProcess: PostProcess): PostProcess;
  28612. /**
  28613. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28614. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28615. */
  28616. useOwnOutput(): void;
  28617. /**
  28618. * Updates the effect with the current post process compile time values and recompiles the shader.
  28619. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28620. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28621. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28622. * @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
  28623. * @param onCompiled Called when the shader has been compiled.
  28624. * @param onError Called if there is an error when compiling a shader.
  28625. */
  28626. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28627. /**
  28628. * The post process is reusable if it can be used multiple times within one frame.
  28629. * @returns If the post process is reusable
  28630. */
  28631. isReusable(): boolean;
  28632. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28633. markTextureDirty(): void;
  28634. /**
  28635. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28636. * 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.
  28637. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28638. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28639. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28640. * @returns The target texture that was bound to be written to.
  28641. */
  28642. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28643. /**
  28644. * If the post process is supported.
  28645. */
  28646. readonly isSupported: boolean;
  28647. /**
  28648. * The aspect ratio of the output texture.
  28649. */
  28650. readonly aspectRatio: number;
  28651. /**
  28652. * Get a value indicating if the post-process is ready to be used
  28653. * @returns true if the post-process is ready (shader is compiled)
  28654. */
  28655. isReady(): boolean;
  28656. /**
  28657. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28658. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  28659. */
  28660. apply(): Nullable<Effect>;
  28661. private _disposeTextures;
  28662. /**
  28663. * Disposes the post process.
  28664. * @param camera The camera to dispose the post process on.
  28665. */
  28666. dispose(camera?: Camera): void;
  28667. }
  28668. }
  28669. declare module BABYLON {
  28670. /**
  28671. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28672. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28673. */
  28674. class PostProcessManager {
  28675. private _scene;
  28676. private _indexBuffer;
  28677. private _vertexBuffers;
  28678. /**
  28679. * Creates a new instance PostProcess
  28680. * @param scene The scene that the post process is associated with.
  28681. */
  28682. constructor(scene: Scene);
  28683. private _prepareBuffers;
  28684. private _buildIndexBuffer;
  28685. /**
  28686. * Rebuilds the vertex buffers of the manager.
  28687. * @hidden
  28688. */
  28689. _rebuild(): void;
  28690. /**
  28691. * Prepares a frame to be run through a post process.
  28692. * @param sourceTexture The input texture to the post procesess. (default: null)
  28693. * @param postProcesses An array of post processes to be run. (default: null)
  28694. * @returns True if the post processes were able to be run.
  28695. * @hidden
  28696. */
  28697. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  28698. /**
  28699. * Manually render a set of post processes to a texture.
  28700. * @param postProcesses An array of post processes to be run.
  28701. * @param targetTexture The target texture to render to.
  28702. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28703. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28704. * @param lodLevel defines which lod of the texture to render to
  28705. */
  28706. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  28707. /**
  28708. * Finalize the result of the output of the postprocesses.
  28709. * @param doNotPresent If true the result will not be displayed to the screen.
  28710. * @param targetTexture The target texture to render to.
  28711. * @param faceIndex The index of the face to bind the target texture to.
  28712. * @param postProcesses The array of post processes to render.
  28713. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28714. * @hidden
  28715. */
  28716. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28717. /**
  28718. * Disposes of the post process manager.
  28719. */
  28720. dispose(): void;
  28721. }
  28722. }
  28723. declare module BABYLON {
  28724. class RefractionPostProcess extends PostProcess {
  28725. color: Color3;
  28726. depth: number;
  28727. colorLevel: number;
  28728. private _refTexture;
  28729. private _ownRefractionTexture;
  28730. /**
  28731. * Gets or sets the refraction texture
  28732. * Please note that you are responsible for disposing the texture if you set it manually
  28733. */
  28734. refractionTexture: Texture;
  28735. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28736. dispose(camera: Camera): void;
  28737. }
  28738. }
  28739. declare module BABYLON {
  28740. /**
  28741. * The SharpenPostProcess applies a sharpen kernel to every pixel
  28742. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  28743. */
  28744. class SharpenPostProcess extends PostProcess {
  28745. /**
  28746. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  28747. */
  28748. colorAmount: number;
  28749. /**
  28750. * How much sharpness should be applied (default: 0.3)
  28751. */
  28752. edgeAmount: number;
  28753. /**
  28754. * Creates a new instance ConvolutionPostProcess
  28755. * @param name The name of the effect.
  28756. * @param options The required width/height ratio to downsize to before computing the render pass.
  28757. * @param camera The camera to apply the render pass to.
  28758. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28759. * @param engine The engine which the post process will be applied. (default: current engine)
  28760. * @param reusable If the post process can be reused on the same frame. (default: false)
  28761. * @param textureType Type of textures used when performing the post process. (default: 0)
  28762. * @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)
  28763. */
  28764. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28765. }
  28766. }
  28767. declare module BABYLON {
  28768. class StereoscopicInterlacePostProcess extends PostProcess {
  28769. private _stepSize;
  28770. private _passedProcess;
  28771. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28772. }
  28773. }
  28774. declare module BABYLON {
  28775. /** Defines operator used for tonemapping */
  28776. enum TonemappingOperator {
  28777. /** Hable */
  28778. Hable = 0,
  28779. /** Reinhard */
  28780. Reinhard = 1,
  28781. /** HejiDawson */
  28782. HejiDawson = 2,
  28783. /** Photographic */
  28784. Photographic = 3
  28785. }
  28786. /**
  28787. * Defines a post process to apply tone mapping
  28788. */
  28789. class TonemapPostProcess extends PostProcess {
  28790. private _operator;
  28791. /** Defines the required exposure adjustement */
  28792. exposureAdjustment: number;
  28793. /**
  28794. * Creates a new TonemapPostProcess
  28795. * @param name defines the name of the postprocess
  28796. * @param _operator defines the operator to use
  28797. * @param exposureAdjustment defines the required exposure adjustement
  28798. * @param camera defines the camera to use (can be null)
  28799. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  28800. * @param engine defines the hosting engine (can be ignore if camera is set)
  28801. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28802. */
  28803. constructor(name: string, _operator: TonemappingOperator,
  28804. /** Defines the required exposure adjustement */
  28805. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  28806. }
  28807. }
  28808. declare module BABYLON {
  28809. class VolumetricLightScatteringPostProcess extends PostProcess {
  28810. private _volumetricLightScatteringPass;
  28811. private _volumetricLightScatteringRTT;
  28812. private _viewPort;
  28813. private _screenCoordinates;
  28814. private _cachedDefines;
  28815. /**
  28816. * If not undefined, the mesh position is computed from the attached node position
  28817. */
  28818. attachedNode: {
  28819. position: Vector3;
  28820. };
  28821. /**
  28822. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  28823. */
  28824. customMeshPosition: Vector3;
  28825. /**
  28826. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  28827. */
  28828. useCustomMeshPosition: boolean;
  28829. /**
  28830. * If the post-process should inverse the light scattering direction
  28831. */
  28832. invert: boolean;
  28833. /**
  28834. * The internal mesh used by the post-process
  28835. */
  28836. mesh: Mesh;
  28837. useDiffuseColor: boolean;
  28838. /**
  28839. * Array containing the excluded meshes not rendered in the internal pass
  28840. */
  28841. excludedMeshes: AbstractMesh[];
  28842. /**
  28843. * Controls the overall intensity of the post-process
  28844. */
  28845. exposure: number;
  28846. /**
  28847. * Dissipates each sample's contribution in range [0, 1]
  28848. */
  28849. decay: number;
  28850. /**
  28851. * Controls the overall intensity of each sample
  28852. */
  28853. weight: number;
  28854. /**
  28855. * Controls the density of each sample
  28856. */
  28857. density: number;
  28858. /**
  28859. * @constructor
  28860. * @param {string} name - The post-process name
  28861. * @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)
  28862. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  28863. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  28864. * @param {number} samples - The post-process quality, default 100
  28865. * @param {number} samplingMode - The post-process filtering mode
  28866. * @param {BABYLON.Engine} engine - The babylon engine
  28867. * @param {boolean} reusable - If the post-process is reusable
  28868. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  28869. */
  28870. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  28871. getClassName(): string;
  28872. private _isReady;
  28873. /**
  28874. * Sets the new light position for light scattering effect
  28875. * @param {BABYLON.Vector3} The new custom light position
  28876. */
  28877. setCustomMeshPosition(position: Vector3): void;
  28878. /**
  28879. * Returns the light position for light scattering effect
  28880. * @return {BABYLON.Vector3} The custom light position
  28881. */
  28882. getCustomMeshPosition(): Vector3;
  28883. /**
  28884. * Disposes the internal assets and detaches the post-process from the camera
  28885. */
  28886. dispose(camera: Camera): void;
  28887. /**
  28888. * Returns the render target texture used by the post-process
  28889. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  28890. */
  28891. getPass(): RenderTargetTexture;
  28892. private _meshExcluded;
  28893. private _createPass;
  28894. private _updateMeshScreenCoordinates;
  28895. /**
  28896. * Creates a default mesh for the Volumeric Light Scattering post-process
  28897. * @param {string} The mesh name
  28898. * @param {BABYLON.Scene} The scene where to create the mesh
  28899. * @return {BABYLON.Mesh} the default mesh
  28900. */
  28901. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  28902. }
  28903. }
  28904. declare module BABYLON {
  28905. class VRDistortionCorrectionPostProcess extends PostProcess {
  28906. private _isRightEye;
  28907. private _distortionFactors;
  28908. private _postProcessScaleFactor;
  28909. private _lensCenterOffset;
  28910. private _scaleIn;
  28911. private _scaleFactor;
  28912. private _lensCenter;
  28913. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  28914. }
  28915. }
  28916. declare module BABYLON {
  28917. interface Scene {
  28918. /**
  28919. * The list of reflection probes added to the scene
  28920. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  28921. */
  28922. reflectionProbes: Array<ReflectionProbe>;
  28923. }
  28924. /**
  28925. * Class used to generate realtime reflection / refraction cube textures
  28926. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  28927. */
  28928. class ReflectionProbe {
  28929. /** defines the name of the probe */
  28930. name: string;
  28931. private _scene;
  28932. private _renderTargetTexture;
  28933. private _projectionMatrix;
  28934. private _viewMatrix;
  28935. private _target;
  28936. private _add;
  28937. private _attachedMesh;
  28938. private _invertYAxis;
  28939. /** Gets or sets probe position (center of the cube map) */
  28940. position: Vector3;
  28941. /**
  28942. * Creates a new reflection probe
  28943. * @param name defines the name of the probe
  28944. * @param size defines the texture resolution (for each face)
  28945. * @param scene defines the hosting scene
  28946. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  28947. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  28948. */
  28949. constructor(
  28950. /** defines the name of the probe */
  28951. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  28952. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  28953. samples: number;
  28954. /** Gets or sets the refresh rate to use (on every frame by default) */
  28955. refreshRate: number;
  28956. /**
  28957. * Gets the hosting scene
  28958. * @returns a Scene
  28959. */
  28960. getScene(): Scene;
  28961. /** Gets the internal CubeTexture used to render to */
  28962. readonly cubeTexture: RenderTargetTexture;
  28963. /** Gets the list of meshes to render */
  28964. readonly renderList: Nullable<AbstractMesh[]>;
  28965. /**
  28966. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  28967. * @param mesh defines the mesh to attach to
  28968. */
  28969. attachToMesh(mesh: AbstractMesh): void;
  28970. /**
  28971. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  28972. * @param renderingGroupId The rendering group id corresponding to its index
  28973. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28974. */
  28975. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  28976. /**
  28977. * Clean all associated resources
  28978. */
  28979. dispose(): void;
  28980. }
  28981. }
  28982. declare module BABYLON {
  28983. interface Scene {
  28984. /** @hidden (Backing field) */
  28985. _boundingBoxRenderer: BoundingBoxRenderer;
  28986. /** @hidden (Backing field) */
  28987. _forceShowBoundingBoxes: boolean;
  28988. /**
  28989. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  28990. */
  28991. forceShowBoundingBoxes: boolean;
  28992. /**
  28993. * Gets the bounding box renderer associated with the scene
  28994. * @returns a BoundingBoxRenderer
  28995. */
  28996. getBoundingBoxRenderer(): BoundingBoxRenderer;
  28997. }
  28998. interface AbstractMesh {
  28999. /** @hidden (Backing field) */
  29000. _showBoundingBox: boolean;
  29001. /**
  29002. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  29003. */
  29004. showBoundingBox: boolean;
  29005. }
  29006. class BoundingBoxRenderer implements ISceneComponent {
  29007. /**
  29008. * The component name helpfull to identify the component in the list of scene components.
  29009. */
  29010. readonly name: string;
  29011. /**
  29012. * The scene the component belongs to.
  29013. */
  29014. scene: Scene;
  29015. frontColor: Color3;
  29016. backColor: Color3;
  29017. showBackLines: boolean;
  29018. renderList: SmartArray<BoundingBox>;
  29019. private _colorShader;
  29020. private _vertexBuffers;
  29021. private _indexBuffer;
  29022. constructor(scene: Scene);
  29023. /**
  29024. * Registers the component in a given scene
  29025. */
  29026. register(): void;
  29027. private _evaluateSubMesh;
  29028. private _activeMesh;
  29029. private _prepareRessources;
  29030. private _createIndexBuffer;
  29031. /**
  29032. * Rebuilds the elements related to this component in case of
  29033. * context lost for instance.
  29034. */
  29035. rebuild(): void;
  29036. reset(): void;
  29037. render(renderingGroupId: number): void;
  29038. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  29039. dispose(): void;
  29040. }
  29041. }
  29042. declare module BABYLON {
  29043. /**
  29044. * This represents a depth renderer in Babylon.
  29045. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  29046. */
  29047. class DepthRenderer {
  29048. private _scene;
  29049. private _depthMap;
  29050. private _effect;
  29051. private _cachedDefines;
  29052. private _camera;
  29053. /**
  29054. * Specifiess that the depth renderer will only be used within
  29055. * the camera it is created for.
  29056. * This can help forcing its rendering during the camera processing.
  29057. */
  29058. useOnlyInActiveCamera: boolean;
  29059. /**
  29060. * Instantiates a depth renderer
  29061. * @param scene The scene the renderer belongs to
  29062. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  29063. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  29064. */
  29065. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  29066. /**
  29067. * Creates the depth rendering effect and checks if the effect is ready.
  29068. * @param subMesh The submesh to be used to render the depth map of
  29069. * @param useInstances If multiple world instances should be used
  29070. * @returns if the depth renderer is ready to render the depth map
  29071. */
  29072. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  29073. /**
  29074. * Gets the texture which the depth map will be written to.
  29075. * @returns The depth map texture
  29076. */
  29077. getDepthMap(): RenderTargetTexture;
  29078. /**
  29079. * Disposes of the depth renderer.
  29080. */
  29081. dispose(): void;
  29082. }
  29083. }
  29084. declare module BABYLON {
  29085. interface Scene {
  29086. /** @hidden (Backing field) */
  29087. _depthRenderer: {
  29088. [id: string]: DepthRenderer;
  29089. };
  29090. /**
  29091. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  29092. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  29093. * @returns the created depth renderer
  29094. */
  29095. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  29096. /**
  29097. * Disables a depth renderer for a given camera
  29098. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  29099. */
  29100. disableDepthRenderer(camera?: Nullable<Camera>): void;
  29101. }
  29102. /**
  29103. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  29104. * in several rendering techniques.
  29105. */
  29106. class DepthRendererSceneComponent implements ISceneComponent {
  29107. /**
  29108. * The component name helpfull to identify the component in the list of scene components.
  29109. */
  29110. readonly name: string;
  29111. /**
  29112. * The scene the component belongs to.
  29113. */
  29114. scene: Scene;
  29115. /**
  29116. * Creates a new instance of the component for the given scene
  29117. * @param scene Defines the scene to register the component in
  29118. */
  29119. constructor(scene: Scene);
  29120. /**
  29121. * Registers the component in a given scene
  29122. */
  29123. register(): void;
  29124. /**
  29125. * Rebuilds the elements related to this component in case of
  29126. * context lost for instance.
  29127. */
  29128. rebuild(): void;
  29129. /**
  29130. * Disposes the component and the associated ressources
  29131. */
  29132. dispose(): void;
  29133. private _gatherRenderTargets;
  29134. private _gatherActiveCameraRenderTargets;
  29135. }
  29136. }
  29137. declare module BABYLON {
  29138. interface AbstractMesh {
  29139. /**
  29140. * Disables the mesh edge rendering mode
  29141. * @returns the currentAbstractMesh
  29142. */
  29143. disableEdgesRendering(): AbstractMesh;
  29144. /**
  29145. * Enables the edge rendering mode on the mesh.
  29146. * This mode makes the mesh edges visible
  29147. * @param epsilon defines the maximal distance between two angles to detect a face
  29148. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29149. * @returns the currentAbstractMesh
  29150. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29151. */
  29152. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29153. /**
  29154. * Gets the edgesRenderer associated with the mesh
  29155. */
  29156. edgesRenderer: Nullable<EdgesRenderer>;
  29157. }
  29158. interface LinesMesh {
  29159. /**
  29160. * Enables the edge rendering mode on the mesh.
  29161. * This mode makes the mesh edges visible
  29162. * @param epsilon defines the maximal distance between two angles to detect a face
  29163. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29164. * @returns the currentAbstractMesh
  29165. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29166. */
  29167. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29168. }
  29169. /**
  29170. * Defines the minimum contract an Edges renderer should follow.
  29171. */
  29172. interface IEdgesRenderer extends IDisposable {
  29173. /**
  29174. * Gets or sets a boolean indicating if the edgesRenderer is active
  29175. */
  29176. isEnabled: boolean;
  29177. /**
  29178. * Renders the edges of the attached mesh,
  29179. */
  29180. render(): void;
  29181. /**
  29182. * Checks wether or not the edges renderer is ready to render.
  29183. * @return true if ready, otherwise false.
  29184. */
  29185. isReady(): boolean;
  29186. }
  29187. /**
  29188. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  29189. */
  29190. class EdgesRenderer implements IEdgesRenderer {
  29191. edgesWidthScalerForOrthographic: number;
  29192. edgesWidthScalerForPerspective: number;
  29193. protected _source: AbstractMesh;
  29194. protected _linesPositions: number[];
  29195. protected _linesNormals: number[];
  29196. protected _linesIndices: number[];
  29197. protected _epsilon: number;
  29198. protected _indicesCount: number;
  29199. protected _lineShader: ShaderMaterial;
  29200. protected _ib: WebGLBuffer;
  29201. protected _buffers: {
  29202. [key: string]: Nullable<VertexBuffer>;
  29203. };
  29204. protected _checkVerticesInsteadOfIndices: boolean;
  29205. private _meshRebuildObserver;
  29206. private _meshDisposeObserver;
  29207. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29208. isEnabled: boolean;
  29209. /**
  29210. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29211. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29212. * @param source Mesh used to create edges
  29213. * @param epsilon sum of angles in adjacency to check for edge
  29214. * @param checkVerticesInsteadOfIndices
  29215. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29216. */
  29217. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  29218. protected _prepareRessources(): void;
  29219. /** @hidden */
  29220. _rebuild(): void;
  29221. /**
  29222. * Releases the required resources for the edges renderer
  29223. */
  29224. dispose(): void;
  29225. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29226. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29227. /**
  29228. * Checks if the pair of p0 and p1 is en edge
  29229. * @param faceIndex
  29230. * @param edge
  29231. * @param faceNormals
  29232. * @param p0
  29233. * @param p1
  29234. * @private
  29235. */
  29236. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29237. /**
  29238. * Generates lines edges from adjacencjes
  29239. * @private
  29240. */
  29241. _generateEdgesLines(): void;
  29242. /**
  29243. * Checks wether or not the edges renderer is ready to render.
  29244. * @return true if ready, otherwise false.
  29245. */
  29246. isReady(): boolean;
  29247. /**
  29248. * Renders the edges of the attached mesh,
  29249. */
  29250. render(): void;
  29251. }
  29252. }
  29253. declare module BABYLON {
  29254. /**
  29255. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  29256. */
  29257. class GeometryBufferRenderer {
  29258. private _scene;
  29259. private _multiRenderTarget;
  29260. private _ratio;
  29261. private _enablePosition;
  29262. protected _effect: Effect;
  29263. protected _cachedDefines: string;
  29264. /**
  29265. * Set the render list (meshes to be rendered) used in the G buffer.
  29266. */
  29267. renderList: Mesh[];
  29268. /**
  29269. * Gets wether or not G buffer are supported by the running hardware.
  29270. * This requires draw buffer supports
  29271. */
  29272. readonly isSupported: boolean;
  29273. /**
  29274. * Gets wether or not position are enabled for the G buffer.
  29275. */
  29276. /**
  29277. * Sets wether or not position are enabled for the G buffer.
  29278. */
  29279. enablePosition: boolean;
  29280. /**
  29281. * Gets the scene associated with the buffer.
  29282. */
  29283. readonly scene: Scene;
  29284. /**
  29285. * Gets the ratio used by the buffer during its creation.
  29286. * How big is the buffer related to the main canvas.
  29287. */
  29288. readonly ratio: number;
  29289. /**
  29290. * Creates a new G Buffer for the scene
  29291. * @param scene The scene the buffer belongs to
  29292. * @param ratio How big is the buffer related to the main canvas.
  29293. */
  29294. constructor(scene: Scene, ratio?: number);
  29295. /**
  29296. * Checks wether everything is ready to render a submesh to the G buffer.
  29297. * @param subMesh the submesh to check readiness for
  29298. * @param useInstances is the mesh drawn using instance or not
  29299. * @returns true if ready otherwise false
  29300. */
  29301. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  29302. /**
  29303. * Gets the current underlying G Buffer.
  29304. * @returns the buffer
  29305. */
  29306. getGBuffer(): MultiRenderTarget;
  29307. /**
  29308. * Gets the number of samples used to render the buffer (anti aliasing).
  29309. */
  29310. /**
  29311. * Sets the number of samples used to render the buffer (anti aliasing).
  29312. */
  29313. samples: number;
  29314. /**
  29315. * Disposes the renderer and frees up associated resources.
  29316. */
  29317. dispose(): void;
  29318. protected _createRenderTargets(): void;
  29319. }
  29320. }
  29321. declare module BABYLON {
  29322. interface Scene {
  29323. /** @hidden (Backing field) */
  29324. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  29325. /**
  29326. * Gets or Sets the current geometry buffer associated to the scene.
  29327. */
  29328. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  29329. /**
  29330. * Enables a GeometryBufferRender and associates it with the scene
  29331. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  29332. * @returns the GeometryBufferRenderer
  29333. */
  29334. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  29335. /**
  29336. * Disables the GeometryBufferRender associated with the scene
  29337. */
  29338. disableGeometryBufferRenderer(): void;
  29339. }
  29340. /**
  29341. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer usefull
  29342. * in several rendering techniques.
  29343. */
  29344. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  29345. /**
  29346. * The component name helpfull to identify the component in the list of scene components.
  29347. */
  29348. readonly name: string;
  29349. /**
  29350. * The scene the component belongs to.
  29351. */
  29352. scene: Scene;
  29353. /**
  29354. * Creates a new instance of the component for the given scene
  29355. * @param scene Defines the scene to register the component in
  29356. */
  29357. constructor(scene: Scene);
  29358. /**
  29359. * Registers the component in a given scene
  29360. */
  29361. register(): void;
  29362. /**
  29363. * Rebuilds the elements related to this component in case of
  29364. * context lost for instance.
  29365. */
  29366. rebuild(): void;
  29367. /**
  29368. * Disposes the component and the associated ressources
  29369. */
  29370. dispose(): void;
  29371. private _gatherRenderTargets;
  29372. }
  29373. }
  29374. declare module BABYLON {
  29375. /**
  29376. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29377. */
  29378. class LineEdgesRenderer extends EdgesRenderer {
  29379. /**
  29380. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29381. * @param source LineMesh used to generate edges
  29382. * @param epsilon not important (specified angle for edge detection)
  29383. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29384. */
  29385. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29386. /**
  29387. * Always create the edge since its a line so only important things are p0 and p1
  29388. * @param faceIndex not important for LineMesh
  29389. * @param edge not important for LineMesh
  29390. * @param faceNormals not important for LineMesh
  29391. * @param p0 beginnig of line
  29392. * @param p1 end of line
  29393. */
  29394. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29395. /**
  29396. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29397. */
  29398. _generateEdgesLines(): void;
  29399. }
  29400. }
  29401. declare module BABYLON {
  29402. interface Scene {
  29403. /** @hidden */
  29404. _outlineRenderer: OutlineRenderer;
  29405. /**
  29406. * Gets the outline renderer associated with the scene
  29407. * @returns a OutlineRenderer
  29408. */
  29409. getOutlineRenderer(): OutlineRenderer;
  29410. }
  29411. interface AbstractMesh {
  29412. /** @hidden (Backing field) */
  29413. _renderOutline: boolean;
  29414. /**
  29415. * Gets or sets a boolean indicating if the outline must be rendered as well
  29416. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  29417. */
  29418. renderOutline: boolean;
  29419. /** @hidden (Backing field) */
  29420. _renderOverlay: boolean;
  29421. /**
  29422. * Gets or sets a boolean indicating if the overlay must be rendered as well
  29423. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  29424. */
  29425. renderOverlay: boolean;
  29426. }
  29427. /**
  29428. * This class is responsible to draw bothe outline/overlay of meshes.
  29429. * It should not be used directly but through the available method on mesh.
  29430. */
  29431. class OutlineRenderer implements ISceneComponent {
  29432. /**
  29433. * The name of the component. Each component must have a unique name.
  29434. */
  29435. name: string;
  29436. /**
  29437. * The scene the component belongs to.
  29438. */
  29439. scene: Scene;
  29440. /**
  29441. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  29442. */
  29443. zOffset: number;
  29444. private _engine;
  29445. private _effect;
  29446. private _cachedDefines;
  29447. private _savedDepthWrite;
  29448. /**
  29449. * Instantiates a new outline renderer. (There could be only one per scene).
  29450. * @param scene Defines the scene it belongs to
  29451. */
  29452. constructor(scene: Scene);
  29453. /**
  29454. * Register the component to one instance of a scene.
  29455. */
  29456. register(): void;
  29457. /**
  29458. * Rebuilds the elements related to this component in case of
  29459. * context lost for instance.
  29460. */
  29461. rebuild(): void;
  29462. /**
  29463. * Disposes the component and the associated ressources.
  29464. */
  29465. dispose(): void;
  29466. /**
  29467. * Renders the outline in the canvas.
  29468. * @param subMesh Defines the sumesh to render
  29469. * @param batch Defines the batch of meshes in case of instances
  29470. * @param useOverlay Defines if the rendering is for the overlay or the outline
  29471. */
  29472. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  29473. /**
  29474. * Returns whether or not the outline renderer is ready for a given submesh.
  29475. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  29476. * @param subMesh Defines the submesh to check readyness for
  29477. * @param useInstances Defines wheter wee are trying to render instances or not
  29478. * @returns true if ready otherwise false
  29479. */
  29480. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  29481. private _beforeRenderingMesh;
  29482. private _afterRenderingMesh;
  29483. }
  29484. }
  29485. declare module BABYLON {
  29486. class RenderingGroup {
  29487. index: number;
  29488. private _scene;
  29489. private _opaqueSubMeshes;
  29490. private _transparentSubMeshes;
  29491. private _alphaTestSubMeshes;
  29492. private _depthOnlySubMeshes;
  29493. private _particleSystems;
  29494. private _spriteManagers;
  29495. private _opaqueSortCompareFn;
  29496. private _alphaTestSortCompareFn;
  29497. private _transparentSortCompareFn;
  29498. private _renderOpaque;
  29499. private _renderAlphaTest;
  29500. private _renderTransparent;
  29501. private _edgesRenderers;
  29502. onBeforeTransparentRendering: () => void;
  29503. /**
  29504. * Set the opaque sort comparison function.
  29505. * If null the sub meshes will be render in the order they were created
  29506. */
  29507. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  29508. /**
  29509. * Set the alpha test sort comparison function.
  29510. * If null the sub meshes will be render in the order they were created
  29511. */
  29512. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  29513. /**
  29514. * Set the transparent sort comparison function.
  29515. * If null the sub meshes will be render in the order they were created
  29516. */
  29517. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  29518. /**
  29519. * Creates a new rendering group.
  29520. * @param index The rendering group index
  29521. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29522. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29523. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29524. */
  29525. 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>);
  29526. /**
  29527. * Render all the sub meshes contained in the group.
  29528. * @param customRenderFunction Used to override the default render behaviour of the group.
  29529. * @returns true if rendered some submeshes.
  29530. */
  29531. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29532. /**
  29533. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29534. * @param subMeshes The submeshes to render
  29535. */
  29536. private renderOpaqueSorted;
  29537. /**
  29538. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29539. * @param subMeshes The submeshes to render
  29540. */
  29541. private renderAlphaTestSorted;
  29542. /**
  29543. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29544. * @param subMeshes The submeshes to render
  29545. */
  29546. private renderTransparentSorted;
  29547. /**
  29548. * Renders the submeshes in a specified order.
  29549. * @param subMeshes The submeshes to sort before render
  29550. * @param sortCompareFn The comparison function use to sort
  29551. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29552. * @param transparent Specifies to activate blending if true
  29553. */
  29554. private static renderSorted;
  29555. /**
  29556. * Renders the submeshes in the order they were dispatched (no sort applied).
  29557. * @param subMeshes The submeshes to render
  29558. */
  29559. private static renderUnsorted;
  29560. /**
  29561. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29562. * are rendered back to front if in the same alpha index.
  29563. *
  29564. * @param a The first submesh
  29565. * @param b The second submesh
  29566. * @returns The result of the comparison
  29567. */
  29568. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29569. /**
  29570. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29571. * are rendered back to front.
  29572. *
  29573. * @param a The first submesh
  29574. * @param b The second submesh
  29575. * @returns The result of the comparison
  29576. */
  29577. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29578. /**
  29579. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29580. * are rendered front to back (prevent overdraw).
  29581. *
  29582. * @param a The first submesh
  29583. * @param b The second submesh
  29584. * @returns The result of the comparison
  29585. */
  29586. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29587. /**
  29588. * Resets the different lists of submeshes to prepare a new frame.
  29589. */
  29590. prepare(): void;
  29591. dispose(): void;
  29592. /**
  29593. * Inserts the submesh in its correct queue depending on its material.
  29594. * @param subMesh The submesh to dispatch
  29595. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29596. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29597. */
  29598. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29599. dispatchSprites(spriteManager: ISpriteManager): void;
  29600. dispatchParticles(particleSystem: IParticleSystem): void;
  29601. private _renderParticles;
  29602. private _renderSprites;
  29603. }
  29604. }
  29605. declare module BABYLON {
  29606. /**
  29607. * Interface describing the different options available in the rendering manager
  29608. * regarding Auto Clear between groups.
  29609. */
  29610. interface IRenderingManagerAutoClearSetup {
  29611. /**
  29612. * Defines whether or not autoclear is enable.
  29613. */
  29614. autoClear: boolean;
  29615. /**
  29616. * Defines whether or not to autoclear the depth buffer.
  29617. */
  29618. depth: boolean;
  29619. /**
  29620. * Defines whether or not to autoclear the stencil buffer.
  29621. */
  29622. stencil: boolean;
  29623. }
  29624. class RenderingManager {
  29625. /**
  29626. * The max id used for rendering groups (not included)
  29627. */
  29628. static MAX_RENDERINGGROUPS: number;
  29629. /**
  29630. * The min id used for rendering groups (included)
  29631. */
  29632. static MIN_RENDERINGGROUPS: number;
  29633. /**
  29634. * Used to globally prevent autoclearing scenes.
  29635. */
  29636. static AUTOCLEAR: boolean;
  29637. /**
  29638. * @hidden
  29639. */
  29640. _useSceneAutoClearSetup: boolean;
  29641. private _scene;
  29642. private _renderingGroups;
  29643. private _depthStencilBufferAlreadyCleaned;
  29644. private _autoClearDepthStencil;
  29645. private _customOpaqueSortCompareFn;
  29646. private _customAlphaTestSortCompareFn;
  29647. private _customTransparentSortCompareFn;
  29648. private _renderingGroupInfo;
  29649. constructor(scene: Scene);
  29650. private _clearDepthStencilBuffer;
  29651. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29652. reset(): void;
  29653. dispose(): void;
  29654. /**
  29655. * Clear the info related to rendering groups preventing retention points during dispose.
  29656. */
  29657. freeRenderingGroups(): void;
  29658. private _prepareRenderingGroup;
  29659. dispatchSprites(spriteManager: ISpriteManager): void;
  29660. dispatchParticles(particleSystem: IParticleSystem): void;
  29661. /**
  29662. * @param subMesh The submesh to dispatch
  29663. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29664. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29665. */
  29666. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29667. /**
  29668. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29669. * This allowed control for front to back rendering or reversly depending of the special needs.
  29670. *
  29671. * @param renderingGroupId The rendering group id corresponding to its index
  29672. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29673. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29674. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29675. */
  29676. 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;
  29677. /**
  29678. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29679. *
  29680. * @param renderingGroupId The rendering group id corresponding to its index
  29681. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29682. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29683. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29684. */
  29685. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29686. /**
  29687. * Gets the current auto clear configuration for one rendering group of the rendering
  29688. * manager.
  29689. * @param index the rendering group index to get the information for
  29690. * @returns The auto clear setup for the requested rendering group
  29691. */
  29692. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29693. }
  29694. }
  29695. declare module BABYLON {
  29696. /**
  29697. * Renders a layer on top of an existing scene
  29698. */
  29699. class UtilityLayerRenderer implements IDisposable {
  29700. /** the original scene that will be rendered on top of */
  29701. originalScene: Scene;
  29702. private _pointerCaptures;
  29703. private _lastPointerEvents;
  29704. private static _DefaultUtilityLayer;
  29705. private static _DefaultKeepDepthUtilityLayer;
  29706. /**
  29707. * 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)
  29708. */
  29709. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  29710. /**
  29711. * 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)
  29712. */
  29713. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  29714. /**
  29715. * The scene that is rendered on top of the original scene
  29716. */
  29717. utilityLayerScene: Scene;
  29718. /**
  29719. * If the utility layer should automatically be rendered on top of existing scene
  29720. */
  29721. shouldRender: boolean;
  29722. /**
  29723. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  29724. */
  29725. onlyCheckPointerDownEvents: boolean;
  29726. /**
  29727. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  29728. */
  29729. processAllEvents: boolean;
  29730. /**
  29731. * Observable raised when the pointer move from the utility layer scene to the main scene
  29732. */
  29733. onPointerOutObservable: Observable<number>;
  29734. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  29735. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  29736. private _afterRenderObserver;
  29737. private _sceneDisposeObserver;
  29738. private _originalPointerObserver;
  29739. /**
  29740. * Instantiates a UtilityLayerRenderer
  29741. * @param originalScene the original scene that will be rendered on top of
  29742. */
  29743. constructor(
  29744. /** the original scene that will be rendered on top of */
  29745. originalScene: Scene);
  29746. private _notifyObservers;
  29747. /**
  29748. * Renders the utility layers scene on top of the original scene
  29749. */
  29750. render(): void;
  29751. /**
  29752. * Disposes of the renderer
  29753. */
  29754. dispose(): void;
  29755. private _updateCamera;
  29756. }
  29757. }
  29758. declare module BABYLON {
  29759. class Sprite {
  29760. name: string;
  29761. position: Vector3;
  29762. color: Color4;
  29763. width: number;
  29764. height: number;
  29765. angle: number;
  29766. cellIndex: number;
  29767. invertU: number;
  29768. invertV: number;
  29769. disposeWhenFinishedAnimating: boolean;
  29770. animations: Animation[];
  29771. isPickable: boolean;
  29772. actionManager: ActionManager;
  29773. private _animationStarted;
  29774. private _loopAnimation;
  29775. private _fromIndex;
  29776. private _toIndex;
  29777. private _delay;
  29778. private _direction;
  29779. private _manager;
  29780. private _time;
  29781. private _onAnimationEnd;
  29782. /**
  29783. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  29784. */
  29785. isVisible: boolean;
  29786. size: number;
  29787. constructor(name: string, manager: ISpriteManager);
  29788. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  29789. stopAnimation(): void;
  29790. /** @hidden */
  29791. _animate(deltaTime: number): void;
  29792. dispose(): void;
  29793. }
  29794. }
  29795. declare module BABYLON {
  29796. /**
  29797. * Defines the minimum interface to fullfil in order to be a sprite manager.
  29798. */
  29799. interface ISpriteManager extends IDisposable {
  29800. /**
  29801. * Restricts the camera to viewing objects with the same layerMask.
  29802. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  29803. */
  29804. layerMask: number;
  29805. /**
  29806. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  29807. */
  29808. isPickable: boolean;
  29809. /**
  29810. * Specifies the rendering group id for this mesh (0 by default)
  29811. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  29812. */
  29813. renderingGroupId: number;
  29814. /**
  29815. * Defines the list of sprites managed by the manager.
  29816. */
  29817. sprites: Array<Sprite>;
  29818. /**
  29819. * Tests the intersection of a sprite with a specific ray.
  29820. * @param ray The ray we are sending to test the collision
  29821. * @param camera The camera space we are sending rays in
  29822. * @param predicate A predicate allowing excluding sprites from the list of object to test
  29823. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  29824. * @returns picking info or null.
  29825. */
  29826. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  29827. /**
  29828. * Renders the list of sprites on screen.
  29829. */
  29830. render(): void;
  29831. }
  29832. class SpriteManager implements ISpriteManager {
  29833. name: string;
  29834. sprites: Sprite[];
  29835. renderingGroupId: number;
  29836. layerMask: number;
  29837. fogEnabled: boolean;
  29838. isPickable: boolean;
  29839. cellWidth: number;
  29840. cellHeight: number;
  29841. /**
  29842. * An event triggered when the manager is disposed.
  29843. */
  29844. onDisposeObservable: Observable<SpriteManager>;
  29845. private _onDisposeObserver;
  29846. onDispose: () => void;
  29847. private _capacity;
  29848. private _spriteTexture;
  29849. private _epsilon;
  29850. private _scene;
  29851. private _vertexData;
  29852. private _buffer;
  29853. private _vertexBuffers;
  29854. private _indexBuffer;
  29855. private _effectBase;
  29856. private _effectFog;
  29857. texture: Texture;
  29858. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  29859. private _appendSpriteVertex;
  29860. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  29861. render(): void;
  29862. dispose(): void;
  29863. }
  29864. }
  29865. declare module BABYLON {
  29866. interface Scene {
  29867. /** @hidden */
  29868. _pointerOverSprite: Nullable<Sprite>;
  29869. /** @hidden */
  29870. _pickedDownSprite: Nullable<Sprite>;
  29871. /** @hidden */
  29872. _tempSpritePickingRay: Nullable<Ray>;
  29873. /**
  29874. * All of the sprite managers added to this scene
  29875. * @see http://doc.babylonjs.com/babylon101/sprites
  29876. */
  29877. spriteManagers: Array<ISpriteManager>;
  29878. /**
  29879. * An event triggered when sprites rendering is about to start
  29880. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  29881. */
  29882. onBeforeSpritesRenderingObservable: Observable<Scene>;
  29883. /**
  29884. * An event triggered when sprites rendering is done
  29885. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  29886. */
  29887. onAfterSpritesRenderingObservable: Observable<Scene>;
  29888. /** @hidden */
  29889. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  29890. /** Launch a ray to try to pick a sprite in the scene
  29891. * @param x position on screen
  29892. * @param y position on screen
  29893. * @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
  29894. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  29895. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  29896. * @returns a PickingInfo
  29897. */
  29898. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  29899. /** Use the given ray to pick a sprite in the scene
  29900. * @param ray The ray (in world space) to use to pick meshes
  29901. * @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
  29902. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  29903. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  29904. * @returns a PickingInfo
  29905. */
  29906. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  29907. /**
  29908. * Force the sprite under the pointer
  29909. * @param sprite defines the sprite to use
  29910. */
  29911. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  29912. /**
  29913. * Gets the sprite under the pointer
  29914. * @returns a Sprite or null if no sprite is under the pointer
  29915. */
  29916. getPointerOverSprite(): Nullable<Sprite>;
  29917. }
  29918. /**
  29919. * Defines the sprite scene component responsible to manage sprites
  29920. * in a given scene.
  29921. */
  29922. class SpriteSceneComponent implements ISceneComponent {
  29923. /**
  29924. * The component name helpfull to identify the component in the list of scene components.
  29925. */
  29926. readonly name: string;
  29927. /**
  29928. * The scene the component belongs to.
  29929. */
  29930. scene: Scene;
  29931. /** @hidden */
  29932. private _spritePredicate;
  29933. /**
  29934. * Creates a new instance of the component for the given scene
  29935. * @param scene Defines the scene to register the component in
  29936. */
  29937. constructor(scene: Scene);
  29938. /**
  29939. * Registers the component in a given scene
  29940. */
  29941. register(): void;
  29942. /**
  29943. * Rebuilds the elements related to this component in case of
  29944. * context lost for instance.
  29945. */
  29946. rebuild(): void;
  29947. /**
  29948. * Disposes the component and the associated ressources.
  29949. */
  29950. dispose(): void;
  29951. private _pickSpriteButKeepRay;
  29952. private _pointerMove;
  29953. private _pointerDown;
  29954. private _pointerUp;
  29955. }
  29956. }
  29957. declare module BABYLON {
  29958. /**
  29959. * @hidden
  29960. **/
  29961. class _AlphaState {
  29962. private _isAlphaBlendDirty;
  29963. private _isBlendFunctionParametersDirty;
  29964. private _isBlendEquationParametersDirty;
  29965. private _isBlendConstantsDirty;
  29966. private _alphaBlend;
  29967. private _blendFunctionParameters;
  29968. private _blendEquationParameters;
  29969. private _blendConstants;
  29970. /**
  29971. * Initializes the state.
  29972. */
  29973. constructor();
  29974. readonly isDirty: boolean;
  29975. alphaBlend: boolean;
  29976. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29977. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29978. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29979. reset(): void;
  29980. apply(gl: WebGLRenderingContext): void;
  29981. }
  29982. }
  29983. declare module BABYLON {
  29984. /**
  29985. * @hidden
  29986. **/
  29987. class _DepthCullingState {
  29988. private _isDepthTestDirty;
  29989. private _isDepthMaskDirty;
  29990. private _isDepthFuncDirty;
  29991. private _isCullFaceDirty;
  29992. private _isCullDirty;
  29993. private _isZOffsetDirty;
  29994. private _isFrontFaceDirty;
  29995. private _depthTest;
  29996. private _depthMask;
  29997. private _depthFunc;
  29998. private _cull;
  29999. private _cullFace;
  30000. private _zOffset;
  30001. private _frontFace;
  30002. /**
  30003. * Initializes the state.
  30004. */
  30005. constructor();
  30006. readonly isDirty: boolean;
  30007. zOffset: number;
  30008. cullFace: Nullable<number>;
  30009. cull: Nullable<boolean>;
  30010. depthFunc: Nullable<number>;
  30011. depthMask: boolean;
  30012. depthTest: boolean;
  30013. frontFace: Nullable<number>;
  30014. reset(): void;
  30015. apply(gl: WebGLRenderingContext): void;
  30016. }
  30017. }
  30018. declare module BABYLON {
  30019. /**
  30020. * @hidden
  30021. **/
  30022. class _StencilState {
  30023. private _isStencilTestDirty;
  30024. private _isStencilMaskDirty;
  30025. private _isStencilFuncDirty;
  30026. private _isStencilOpDirty;
  30027. private _stencilTest;
  30028. private _stencilMask;
  30029. private _stencilFunc;
  30030. private _stencilFuncRef;
  30031. private _stencilFuncMask;
  30032. private _stencilOpStencilFail;
  30033. private _stencilOpDepthFail;
  30034. private _stencilOpStencilDepthPass;
  30035. readonly isDirty: boolean;
  30036. stencilFunc: number;
  30037. stencilFuncRef: number;
  30038. stencilFuncMask: number;
  30039. stencilOpStencilFail: number;
  30040. stencilOpDepthFail: number;
  30041. stencilOpStencilDepthPass: number;
  30042. stencilMask: number;
  30043. stencilTest: boolean;
  30044. constructor();
  30045. reset(): void;
  30046. apply(gl: WebGLRenderingContext): void;
  30047. }
  30048. }
  30049. declare module BABYLON {
  30050. /**
  30051. * Class used to evalaute queries containing `and` and `or` operators
  30052. */
  30053. class AndOrNotEvaluator {
  30054. /**
  30055. * Evaluate a query
  30056. * @param query defines the query to evaluate
  30057. * @param evaluateCallback defines the callback used to filter result
  30058. * @returns true if the query matches
  30059. */
  30060. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  30061. private static _HandleParenthesisContent;
  30062. private static _SimplifyNegation;
  30063. }
  30064. }
  30065. declare module BABYLON {
  30066. /**
  30067. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  30068. */
  30069. enum AssetTaskState {
  30070. /**
  30071. * Initialization
  30072. */
  30073. INIT = 0,
  30074. /**
  30075. * Running
  30076. */
  30077. RUNNING = 1,
  30078. /**
  30079. * Done
  30080. */
  30081. DONE = 2,
  30082. /**
  30083. * Error
  30084. */
  30085. ERROR = 3
  30086. }
  30087. /**
  30088. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  30089. */
  30090. abstract class AbstractAssetTask {
  30091. /**
  30092. * Task name
  30093. */ name: string;
  30094. /**
  30095. * Callback called when the task is successful
  30096. */
  30097. onSuccess: (task: any) => void;
  30098. /**
  30099. * Callback called when the task is not successful
  30100. */
  30101. onError: (task: any, message?: string, exception?: any) => void;
  30102. /**
  30103. * Creates a new {BABYLON.AssetsManager}
  30104. * @param name defines the name of the task
  30105. */
  30106. constructor(
  30107. /**
  30108. * Task name
  30109. */ name: string);
  30110. private _isCompleted;
  30111. private _taskState;
  30112. private _errorObject;
  30113. /**
  30114. * Get if the task is completed
  30115. */
  30116. readonly isCompleted: boolean;
  30117. /**
  30118. * Gets the current state of the task
  30119. */
  30120. readonly taskState: AssetTaskState;
  30121. /**
  30122. * Gets the current error object (if task is in error)
  30123. */
  30124. readonly errorObject: {
  30125. message?: string;
  30126. exception?: any;
  30127. };
  30128. /**
  30129. * Internal only
  30130. * @hidden
  30131. */
  30132. _setErrorObject(message?: string, exception?: any): void;
  30133. /**
  30134. * Execute the current task
  30135. * @param scene defines the scene where you want your assets to be loaded
  30136. * @param onSuccess is a callback called when the task is successfully executed
  30137. * @param onError is a callback called if an error occurs
  30138. */
  30139. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30140. /**
  30141. * Execute the current task
  30142. * @param scene defines the scene where you want your assets to be loaded
  30143. * @param onSuccess is a callback called when the task is successfully executed
  30144. * @param onError is a callback called if an error occurs
  30145. */
  30146. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30147. /**
  30148. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  30149. * This can be used with failed tasks that have the reason for failure fixed.
  30150. */
  30151. reset(): void;
  30152. private onErrorCallback;
  30153. private onDoneCallback;
  30154. }
  30155. /**
  30156. * Define the interface used by progress events raised during assets loading
  30157. */
  30158. interface IAssetsProgressEvent {
  30159. /**
  30160. * Defines the number of remaining tasks to process
  30161. */
  30162. remainingCount: number;
  30163. /**
  30164. * Defines the total number of tasks
  30165. */
  30166. totalCount: number;
  30167. /**
  30168. * Defines the task that was just processed
  30169. */
  30170. task: AbstractAssetTask;
  30171. }
  30172. /**
  30173. * Class used to share progress information about assets loading
  30174. */
  30175. class AssetsProgressEvent implements IAssetsProgressEvent {
  30176. /**
  30177. * Defines the number of remaining tasks to process
  30178. */
  30179. remainingCount: number;
  30180. /**
  30181. * Defines the total number of tasks
  30182. */
  30183. totalCount: number;
  30184. /**
  30185. * Defines the task that was just processed
  30186. */
  30187. task: AbstractAssetTask;
  30188. /**
  30189. * Creates a {BABYLON.AssetsProgressEvent}
  30190. * @param remainingCount defines the number of remaining tasks to process
  30191. * @param totalCount defines the total number of tasks
  30192. * @param task defines the task that was just processed
  30193. */
  30194. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  30195. }
  30196. /**
  30197. * Define a task used by {BABYLON.AssetsManager} to load meshes
  30198. */
  30199. class MeshAssetTask extends AbstractAssetTask {
  30200. /**
  30201. * Defines the name of the task
  30202. */
  30203. name: string;
  30204. /**
  30205. * Defines the list of mesh's names you want to load
  30206. */
  30207. meshesNames: any;
  30208. /**
  30209. * Defines the root url to use as a base to load your meshes and associated resources
  30210. */
  30211. rootUrl: string;
  30212. /**
  30213. * Defines the filename of the scene to load from
  30214. */
  30215. sceneFilename: string;
  30216. /**
  30217. * Gets the list of loaded meshes
  30218. */
  30219. loadedMeshes: Array<AbstractMesh>;
  30220. /**
  30221. * Gets the list of loaded particle systems
  30222. */
  30223. loadedParticleSystems: Array<IParticleSystem>;
  30224. /**
  30225. * Gets the list of loaded skeletons
  30226. */
  30227. loadedSkeletons: Array<Skeleton>;
  30228. /**
  30229. * Callback called when the task is successful
  30230. */
  30231. onSuccess: (task: MeshAssetTask) => void;
  30232. /**
  30233. * Callback called when the task is successful
  30234. */
  30235. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  30236. /**
  30237. * Creates a new {BABYLON.MeshAssetTask}
  30238. * @param name defines the name of the task
  30239. * @param meshesNames defines the list of mesh's names you want to load
  30240. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  30241. * @param sceneFilename defines the filename of the scene to load from
  30242. */
  30243. constructor(
  30244. /**
  30245. * Defines the name of the task
  30246. */
  30247. name: string,
  30248. /**
  30249. * Defines the list of mesh's names you want to load
  30250. */
  30251. meshesNames: any,
  30252. /**
  30253. * Defines the root url to use as a base to load your meshes and associated resources
  30254. */
  30255. rootUrl: string,
  30256. /**
  30257. * Defines the filename of the scene to load from
  30258. */
  30259. sceneFilename: string);
  30260. /**
  30261. * Execute the current task
  30262. * @param scene defines the scene where you want your assets to be loaded
  30263. * @param onSuccess is a callback called when the task is successfully executed
  30264. * @param onError is a callback called if an error occurs
  30265. */
  30266. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30267. }
  30268. /**
  30269. * Define a task used by {BABYLON.AssetsManager} to load text content
  30270. */
  30271. class TextFileAssetTask extends AbstractAssetTask {
  30272. /**
  30273. * Defines the name of the task
  30274. */
  30275. name: string;
  30276. /**
  30277. * Defines the location of the file to load
  30278. */
  30279. url: string;
  30280. /**
  30281. * Gets the loaded text string
  30282. */
  30283. text: string;
  30284. /**
  30285. * Callback called when the task is successful
  30286. */
  30287. onSuccess: (task: TextFileAssetTask) => void;
  30288. /**
  30289. * Callback called when the task is successful
  30290. */
  30291. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  30292. /**
  30293. * Creates a new TextFileAssetTask object
  30294. * @param name defines the name of the task
  30295. * @param url defines the location of the file to load
  30296. */
  30297. constructor(
  30298. /**
  30299. * Defines the name of the task
  30300. */
  30301. name: string,
  30302. /**
  30303. * Defines the location of the file to load
  30304. */
  30305. url: string);
  30306. /**
  30307. * Execute the current task
  30308. * @param scene defines the scene where you want your assets to be loaded
  30309. * @param onSuccess is a callback called when the task is successfully executed
  30310. * @param onError is a callback called if an error occurs
  30311. */
  30312. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30313. }
  30314. /**
  30315. * Define a task used by {BABYLON.AssetsManager} to load binary data
  30316. */
  30317. class BinaryFileAssetTask extends AbstractAssetTask {
  30318. /**
  30319. * Defines the name of the task
  30320. */
  30321. name: string;
  30322. /**
  30323. * Defines the location of the file to load
  30324. */
  30325. url: string;
  30326. /**
  30327. * Gets the lodaded data (as an array buffer)
  30328. */
  30329. data: ArrayBuffer;
  30330. /**
  30331. * Callback called when the task is successful
  30332. */
  30333. onSuccess: (task: BinaryFileAssetTask) => void;
  30334. /**
  30335. * Callback called when the task is successful
  30336. */
  30337. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  30338. /**
  30339. * Creates a new BinaryFileAssetTask object
  30340. * @param name defines the name of the new task
  30341. * @param url defines the location of the file to load
  30342. */
  30343. constructor(
  30344. /**
  30345. * Defines the name of the task
  30346. */
  30347. name: string,
  30348. /**
  30349. * Defines the location of the file to load
  30350. */
  30351. url: string);
  30352. /**
  30353. * Execute the current task
  30354. * @param scene defines the scene where you want your assets to be loaded
  30355. * @param onSuccess is a callback called when the task is successfully executed
  30356. * @param onError is a callback called if an error occurs
  30357. */
  30358. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30359. }
  30360. /**
  30361. * Define a task used by {BABYLON.AssetsManager} to load images
  30362. */
  30363. class ImageAssetTask extends AbstractAssetTask {
  30364. /**
  30365. * Defines the name of the task
  30366. */
  30367. name: string;
  30368. /**
  30369. * Defines the location of the image to load
  30370. */
  30371. url: string;
  30372. /**
  30373. * Gets the loaded images
  30374. */
  30375. image: HTMLImageElement;
  30376. /**
  30377. * Callback called when the task is successful
  30378. */
  30379. onSuccess: (task: ImageAssetTask) => void;
  30380. /**
  30381. * Callback called when the task is successful
  30382. */
  30383. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  30384. /**
  30385. * Creates a new ImageAssetTask
  30386. * @param name defines the name of the task
  30387. * @param url defines the location of the image to load
  30388. */
  30389. constructor(
  30390. /**
  30391. * Defines the name of the task
  30392. */
  30393. name: string,
  30394. /**
  30395. * Defines the location of the image to load
  30396. */
  30397. url: string);
  30398. /**
  30399. * Execute the current task
  30400. * @param scene defines the scene where you want your assets to be loaded
  30401. * @param onSuccess is a callback called when the task is successfully executed
  30402. * @param onError is a callback called if an error occurs
  30403. */
  30404. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30405. }
  30406. /**
  30407. * Defines the interface used by texture loading tasks
  30408. */
  30409. interface ITextureAssetTask<TEX extends BaseTexture> {
  30410. /**
  30411. * Gets the loaded texture
  30412. */
  30413. texture: TEX;
  30414. }
  30415. /**
  30416. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  30417. */
  30418. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  30419. /**
  30420. * Defines the name of the task
  30421. */
  30422. name: string;
  30423. /**
  30424. * Defines the location of the file to load
  30425. */
  30426. url: string;
  30427. /**
  30428. * Defines if mipmap should not be generated (default is false)
  30429. */
  30430. noMipmap?: boolean | undefined;
  30431. /**
  30432. * Defines if texture must be inverted on Y axis (default is false)
  30433. */
  30434. invertY?: boolean | undefined;
  30435. /**
  30436. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  30437. */
  30438. samplingMode: number;
  30439. /**
  30440. * Gets the loaded texture
  30441. */
  30442. texture: Texture;
  30443. /**
  30444. * Callback called when the task is successful
  30445. */
  30446. onSuccess: (task: TextureAssetTask) => void;
  30447. /**
  30448. * Callback called when the task is successful
  30449. */
  30450. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  30451. /**
  30452. * Creates a new TextureAssetTask object
  30453. * @param name defines the name of the task
  30454. * @param url defines the location of the file to load
  30455. * @param noMipmap defines if mipmap should not be generated (default is false)
  30456. * @param invertY defines if texture must be inverted on Y axis (default is false)
  30457. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  30458. */
  30459. constructor(
  30460. /**
  30461. * Defines the name of the task
  30462. */
  30463. name: string,
  30464. /**
  30465. * Defines the location of the file to load
  30466. */
  30467. url: string,
  30468. /**
  30469. * Defines if mipmap should not be generated (default is false)
  30470. */
  30471. noMipmap?: boolean | undefined,
  30472. /**
  30473. * Defines if texture must be inverted on Y axis (default is false)
  30474. */
  30475. invertY?: boolean | undefined,
  30476. /**
  30477. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  30478. */
  30479. samplingMode?: number);
  30480. /**
  30481. * Execute the current task
  30482. * @param scene defines the scene where you want your assets to be loaded
  30483. * @param onSuccess is a callback called when the task is successfully executed
  30484. * @param onError is a callback called if an error occurs
  30485. */
  30486. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30487. }
  30488. /**
  30489. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  30490. */
  30491. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  30492. /**
  30493. * Defines the name of the task
  30494. */
  30495. name: string;
  30496. /**
  30497. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  30498. */
  30499. url: string;
  30500. /**
  30501. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  30502. */
  30503. extensions?: string[] | undefined;
  30504. /**
  30505. * Defines if mipmaps should not be generated (default is false)
  30506. */
  30507. noMipmap?: boolean | undefined;
  30508. /**
  30509. * Defines the explicit list of files (undefined by default)
  30510. */
  30511. files?: string[] | undefined;
  30512. /**
  30513. * Gets the loaded texture
  30514. */
  30515. texture: CubeTexture;
  30516. /**
  30517. * Callback called when the task is successful
  30518. */
  30519. onSuccess: (task: CubeTextureAssetTask) => void;
  30520. /**
  30521. * Callback called when the task is successful
  30522. */
  30523. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  30524. /**
  30525. * Creates a new CubeTextureAssetTask
  30526. * @param name defines the name of the task
  30527. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  30528. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  30529. * @param noMipmap defines if mipmaps should not be generated (default is false)
  30530. * @param files defines the explicit list of files (undefined by default)
  30531. */
  30532. constructor(
  30533. /**
  30534. * Defines the name of the task
  30535. */
  30536. name: string,
  30537. /**
  30538. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  30539. */
  30540. url: string,
  30541. /**
  30542. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  30543. */
  30544. extensions?: string[] | undefined,
  30545. /**
  30546. * Defines if mipmaps should not be generated (default is false)
  30547. */
  30548. noMipmap?: boolean | undefined,
  30549. /**
  30550. * Defines the explicit list of files (undefined by default)
  30551. */
  30552. files?: string[] | undefined);
  30553. /**
  30554. * Execute the current task
  30555. * @param scene defines the scene where you want your assets to be loaded
  30556. * @param onSuccess is a callback called when the task is successfully executed
  30557. * @param onError is a callback called if an error occurs
  30558. */
  30559. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30560. }
  30561. /**
  30562. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  30563. */
  30564. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  30565. /**
  30566. * Defines the name of the task
  30567. */
  30568. name: string;
  30569. /**
  30570. * Defines the location of the file to load
  30571. */
  30572. url: string;
  30573. /**
  30574. * Defines the desired size (the more it increases the longer the generation will be)
  30575. */
  30576. size: number;
  30577. /**
  30578. * Defines if mipmaps should not be generated (default is false)
  30579. */
  30580. noMipmap: boolean;
  30581. /**
  30582. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  30583. */
  30584. generateHarmonics: boolean;
  30585. /**
  30586. * 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)
  30587. */
  30588. gammaSpace: boolean;
  30589. /**
  30590. * Internal Use Only
  30591. */
  30592. reserved: boolean;
  30593. /**
  30594. * Gets the loaded texture
  30595. */
  30596. texture: HDRCubeTexture;
  30597. /**
  30598. * Callback called when the task is successful
  30599. */
  30600. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  30601. /**
  30602. * Callback called when the task is successful
  30603. */
  30604. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  30605. /**
  30606. * Creates a new HDRCubeTextureAssetTask object
  30607. * @param name defines the name of the task
  30608. * @param url defines the location of the file to load
  30609. * @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.
  30610. * @param noMipmap defines if mipmaps should not be generated (default is false)
  30611. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  30612. * @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)
  30613. * @param reserved Internal use only
  30614. */
  30615. constructor(
  30616. /**
  30617. * Defines the name of the task
  30618. */
  30619. name: string,
  30620. /**
  30621. * Defines the location of the file to load
  30622. */
  30623. url: string,
  30624. /**
  30625. * Defines the desired size (the more it increases the longer the generation will be)
  30626. */
  30627. size: number,
  30628. /**
  30629. * Defines if mipmaps should not be generated (default is false)
  30630. */
  30631. noMipmap?: boolean,
  30632. /**
  30633. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  30634. */
  30635. generateHarmonics?: boolean,
  30636. /**
  30637. * 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)
  30638. */
  30639. gammaSpace?: boolean,
  30640. /**
  30641. * Internal Use Only
  30642. */
  30643. reserved?: boolean);
  30644. /**
  30645. * Execute the current task
  30646. * @param scene defines the scene where you want your assets to be loaded
  30647. * @param onSuccess is a callback called when the task is successfully executed
  30648. * @param onError is a callback called if an error occurs
  30649. */
  30650. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  30651. }
  30652. /**
  30653. * This class can be used to easily import assets into a scene
  30654. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  30655. */
  30656. class AssetsManager {
  30657. private _scene;
  30658. private _isLoading;
  30659. protected _tasks: AbstractAssetTask[];
  30660. protected _waitingTasksCount: number;
  30661. protected _totalTasksCount: number;
  30662. /**
  30663. * Callback called when all tasks are processed
  30664. */
  30665. onFinish: (tasks: AbstractAssetTask[]) => void;
  30666. /**
  30667. * Callback called when a task is successful
  30668. */
  30669. onTaskSuccess: (task: AbstractAssetTask) => void;
  30670. /**
  30671. * Callback called when a task had an error
  30672. */
  30673. onTaskError: (task: AbstractAssetTask) => void;
  30674. /**
  30675. * Callback called when a task is done (whatever the result is)
  30676. */
  30677. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  30678. /**
  30679. * Observable called when all tasks are processed
  30680. */
  30681. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  30682. /**
  30683. * Observable called when a task had an error
  30684. */
  30685. onTaskErrorObservable: Observable<AbstractAssetTask>;
  30686. /**
  30687. * Observable called when a task is successful
  30688. */
  30689. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  30690. /**
  30691. * Observable called when a task is done (whatever the result is)
  30692. */
  30693. onProgressObservable: Observable<IAssetsProgressEvent>;
  30694. /**
  30695. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  30696. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30697. */
  30698. useDefaultLoadingScreen: boolean;
  30699. /**
  30700. * Creates a new AssetsManager
  30701. * @param scene defines the scene to work on
  30702. */
  30703. constructor(scene: Scene);
  30704. /**
  30705. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  30706. * @param taskName defines the name of the new task
  30707. * @param meshesNames defines the name of meshes to load
  30708. * @param rootUrl defines the root url to use to locate files
  30709. * @param sceneFilename defines the filename of the scene file
  30710. * @returns a new {BABYLON.MeshAssetTask} object
  30711. */
  30712. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  30713. /**
  30714. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  30715. * @param taskName defines the name of the new task
  30716. * @param url defines the url of the file to load
  30717. * @returns a new {BABYLON.TextFileAssetTask} object
  30718. */
  30719. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  30720. /**
  30721. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  30722. * @param taskName defines the name of the new task
  30723. * @param url defines the url of the file to load
  30724. * @returns a new {BABYLON.BinaryFileAssetTask} object
  30725. */
  30726. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  30727. /**
  30728. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  30729. * @param taskName defines the name of the new task
  30730. * @param url defines the url of the file to load
  30731. * @returns a new {BABYLON.ImageAssetTask} object
  30732. */
  30733. addImageTask(taskName: string, url: string): ImageAssetTask;
  30734. /**
  30735. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  30736. * @param taskName defines the name of the new task
  30737. * @param url defines the url of the file to load
  30738. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  30739. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  30740. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  30741. * @returns a new {BABYLON.TextureAssetTask} object
  30742. */
  30743. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  30744. /**
  30745. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  30746. * @param taskName defines the name of the new task
  30747. * @param url defines the url of the file to load
  30748. * @param extensions defines the extension to use to load the cube map (can be null)
  30749. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  30750. * @param files defines the list of files to load (can be null)
  30751. * @returns a new {BABYLON.CubeTextureAssetTask} object
  30752. */
  30753. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  30754. /**
  30755. *
  30756. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  30757. * @param taskName defines the name of the new task
  30758. * @param url defines the url of the file to load
  30759. * @param size defines the size you want for the cubemap (can be null)
  30760. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  30761. * @param generateHarmonics defines if you want to automatically generate (true by default)
  30762. * @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)
  30763. * @param reserved Internal use only
  30764. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  30765. */
  30766. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  30767. /**
  30768. * Remove a task from the assets manager.
  30769. * @param task the task to remove
  30770. */
  30771. removeTask(task: AbstractAssetTask): void;
  30772. private _decreaseWaitingTasksCount;
  30773. private _runTask;
  30774. /**
  30775. * Reset the {BABYLON.AssetsManager} and remove all tasks
  30776. * @return the current instance of the {BABYLON.AssetsManager}
  30777. */
  30778. reset(): AssetsManager;
  30779. /**
  30780. * Start the loading process
  30781. * @return the current instance of the {BABYLON.AssetsManager}
  30782. */
  30783. load(): AssetsManager;
  30784. }
  30785. }
  30786. declare module BABYLON {
  30787. /**
  30788. * Class used to enable access to IndexedDB
  30789. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  30790. */
  30791. class Database {
  30792. private callbackManifestChecked;
  30793. private currentSceneUrl;
  30794. private db;
  30795. private _enableSceneOffline;
  30796. private _enableTexturesOffline;
  30797. private manifestVersionFound;
  30798. private mustUpdateRessources;
  30799. private hasReachedQuota;
  30800. private isSupported;
  30801. private idbFactory;
  30802. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  30803. static IsUASupportingBlobStorage: boolean;
  30804. /** Gets a boolean indicating if Database storate is enabled */
  30805. static IDBStorageEnabled: boolean;
  30806. /**
  30807. * Gets a boolean indicating if scene must be saved in the database
  30808. */
  30809. readonly enableSceneOffline: boolean;
  30810. /**
  30811. * Gets a boolean indicating if textures must be saved in the database
  30812. */
  30813. readonly enableTexturesOffline: boolean;
  30814. /**
  30815. * Creates a new Database
  30816. * @param urlToScene defines the url to load the scene
  30817. * @param callbackManifestChecked defines the callback to use when manifest is checked
  30818. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  30819. */
  30820. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  30821. private static _ParseURL;
  30822. private static _ReturnFullUrlLocation;
  30823. private _checkManifestFile;
  30824. /**
  30825. * Open the database and make it available
  30826. * @param successCallback defines the callback to call on success
  30827. * @param errorCallback defines the callback to call on error
  30828. */
  30829. openAsync(successCallback: () => void, errorCallback: () => void): void;
  30830. /**
  30831. * Loads an image from the database
  30832. * @param url defines the url to load from
  30833. * @param image defines the target DOM image
  30834. */
  30835. loadImageFromDB(url: string, image: HTMLImageElement): void;
  30836. private _loadImageFromDBAsync;
  30837. private _saveImageIntoDBAsync;
  30838. private _checkVersionFromDB;
  30839. private _loadVersionFromDBAsync;
  30840. private _saveVersionIntoDBAsync;
  30841. /**
  30842. * Loads a file from database
  30843. * @param url defines the URL to load from
  30844. * @param sceneLoaded defines a callback to call on success
  30845. * @param progressCallBack defines a callback to call when progress changed
  30846. * @param errorCallback defines a callback to call on error
  30847. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30848. */
  30849. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30850. private _loadFileFromDBAsync;
  30851. private _saveFileIntoDBAsync;
  30852. }
  30853. }
  30854. declare module BABYLON {
  30855. interface DDSInfo {
  30856. width: number;
  30857. height: number;
  30858. mipmapCount: number;
  30859. isFourCC: boolean;
  30860. isRGB: boolean;
  30861. isLuminance: boolean;
  30862. isCube: boolean;
  30863. isCompressed: boolean;
  30864. dxgiFormat: number;
  30865. textureType: number;
  30866. /** Sphericle polynomial created for the dds texture */
  30867. sphericalPolynomial?: SphericalPolynomial;
  30868. }
  30869. class DDSTools {
  30870. static StoreLODInAlphaChannel: boolean;
  30871. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  30872. private static _FloatView;
  30873. private static _Int32View;
  30874. private static _ToHalfFloat;
  30875. private static _FromHalfFloat;
  30876. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  30877. private static _GetHalfFloatRGBAArrayBuffer;
  30878. private static _GetFloatRGBAArrayBuffer;
  30879. private static _GetFloatAsUIntRGBAArrayBuffer;
  30880. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  30881. private static _GetRGBAArrayBuffer;
  30882. private static _ExtractLongWordOrder;
  30883. private static _GetRGBArrayBuffer;
  30884. private static _GetLuminanceArrayBuffer;
  30885. /**
  30886. * Uploads DDS Levels to a Babylon Texture
  30887. * @hidden
  30888. */
  30889. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  30890. }
  30891. }
  30892. declare module BABYLON {
  30893. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30894. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30895. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30896. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30897. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30898. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30899. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30900. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30901. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30902. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30903. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30904. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30905. /**
  30906. * Decorator used to define property that can be serialized as reference to a camera
  30907. * @param sourceName defines the name of the property to decorate
  30908. */
  30909. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30910. class SerializationHelper {
  30911. static Serialize<T>(entity: T, serializationObject?: any): any;
  30912. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30913. static Clone<T>(creationFunction: () => T, source: T): T;
  30914. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30915. }
  30916. }
  30917. declare module BABYLON {
  30918. /**
  30919. * Wrapper class for promise with external resolve and reject.
  30920. */
  30921. class Deferred<T> {
  30922. /**
  30923. * The promise associated with this deferred object.
  30924. */
  30925. readonly promise: Promise<T>;
  30926. private _resolve;
  30927. private _reject;
  30928. /**
  30929. * The resolve method of the promise associated with this deferred object.
  30930. */
  30931. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  30932. /**
  30933. * The reject method of the promise associated with this deferred object.
  30934. */
  30935. readonly reject: (reason?: any) => void;
  30936. /**
  30937. * Constructor for this deferred object.
  30938. */
  30939. constructor();
  30940. }
  30941. }
  30942. declare module BABYLON {
  30943. /**
  30944. * Raw texture data and descriptor sufficient for WebGL texture upload
  30945. */
  30946. interface EnvironmentTextureInfo {
  30947. /**
  30948. * Version of the environment map
  30949. */
  30950. version: number;
  30951. /**
  30952. * Width of image
  30953. */
  30954. width: number;
  30955. /**
  30956. * Irradiance information stored in the file.
  30957. */
  30958. irradiance: any;
  30959. /**
  30960. * Specular information stored in the file.
  30961. */
  30962. specular: any;
  30963. }
  30964. /**
  30965. * Sets of helpers addressing the serialization and deserialization of environment texture
  30966. * stored in a BabylonJS env file.
  30967. * Those files are usually stored as .env files.
  30968. */
  30969. class EnvironmentTextureTools {
  30970. /**
  30971. * Magic number identifying the env file.
  30972. */
  30973. private static _MagicBytes;
  30974. /**
  30975. * Gets the environment info from an env file.
  30976. * @param data The array buffer containing the .env bytes.
  30977. * @returns the environment file info (the json header) if successfully parsed.
  30978. */
  30979. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  30980. /**
  30981. * Creates an environment texture from a loaded cube texture.
  30982. * @param texture defines the cube texture to convert in env file
  30983. * @return a promise containing the environment data if succesfull.
  30984. */
  30985. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  30986. /**
  30987. * Creates a JSON representation of the spherical data.
  30988. * @param texture defines the texture containing the polynomials
  30989. * @return the JSON representation of the spherical info
  30990. */
  30991. private static _CreateEnvTextureIrradiance;
  30992. /**
  30993. * Uploads the texture info contained in the env file to the GPU.
  30994. * @param texture defines the internal texture to upload to
  30995. * @param arrayBuffer defines the buffer cotaining the data to load
  30996. * @param info defines the texture info retrieved through the GetEnvInfo method
  30997. * @returns a promise
  30998. */
  30999. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  31000. /**
  31001. * Uploads the levels of image data to the GPU.
  31002. * @param texture defines the internal texture to upload to
  31003. * @param imageData defines the array buffer views of image data [mipmap][face]
  31004. * @returns a promise
  31005. */
  31006. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  31007. /**
  31008. * Uploads spherical polynomials information to the texture.
  31009. * @param texture defines the texture we are trying to upload the information to
  31010. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  31011. */
  31012. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  31013. }
  31014. }
  31015. declare module BABYLON {
  31016. class FilesInput {
  31017. static FilesToLoad: {
  31018. [key: string]: File;
  31019. };
  31020. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  31021. private _engine;
  31022. private _currentScene;
  31023. private _sceneLoadedCallback;
  31024. private _progressCallback;
  31025. private _additionalRenderLoopLogicCallback;
  31026. private _textureLoadingCallback;
  31027. private _startingProcessingFilesCallback;
  31028. private _onReloadCallback;
  31029. private _errorCallback;
  31030. private _elementToMonitor;
  31031. private _sceneFileToLoad;
  31032. private _filesToLoad;
  31033. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  31034. private _dragEnterHandler;
  31035. private _dragOverHandler;
  31036. private _dropHandler;
  31037. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  31038. dispose(): void;
  31039. private renderFunction;
  31040. private drag;
  31041. private drop;
  31042. private _traverseFolder;
  31043. private _processFiles;
  31044. loadFiles(event: any): void;
  31045. private _processReload;
  31046. reload(): void;
  31047. }
  31048. }
  31049. declare module BABYLON {
  31050. /**
  31051. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31052. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31053. */
  31054. class KhronosTextureContainer {
  31055. arrayBuffer: any;
  31056. static HEADER_LEN: number;
  31057. static COMPRESSED_2D: number;
  31058. static COMPRESSED_3D: number;
  31059. static TEX_2D: number;
  31060. static TEX_3D: number;
  31061. glType: number;
  31062. glTypeSize: number;
  31063. glFormat: number;
  31064. glInternalFormat: number;
  31065. glBaseInternalFormat: number;
  31066. pixelWidth: number;
  31067. pixelHeight: number;
  31068. pixelDepth: number;
  31069. numberOfArrayElements: number;
  31070. numberOfFaces: number;
  31071. numberOfMipmapLevels: number;
  31072. bytesOfKeyValueData: number;
  31073. loadType: number;
  31074. /**
  31075. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  31076. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  31077. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  31078. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  31079. */
  31080. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  31081. switchEndainness(val: number): number;
  31082. /**
  31083. * Uploads KTX content to a Babylon Texture.
  31084. * It is assumed that the texture has already been created & is currently bound
  31085. * @hidden
  31086. */
  31087. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  31088. private _upload2DCompressedLevels;
  31089. }
  31090. }
  31091. declare module BABYLON {
  31092. /**
  31093. * A class serves as a medium between the observable and its observers
  31094. */
  31095. class EventState {
  31096. /**
  31097. * Create a new EventState
  31098. * @param mask defines the mask associated with this state
  31099. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  31100. * @param target defines the original target of the state
  31101. * @param currentTarget defines the current target of the state
  31102. */
  31103. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  31104. /**
  31105. * Initialize the current event state
  31106. * @param mask defines the mask associated with this state
  31107. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  31108. * @param target defines the original target of the state
  31109. * @param currentTarget defines the current target of the state
  31110. * @returns the current event state
  31111. */
  31112. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  31113. /**
  31114. * An Observer can set this property to true to prevent subsequent observers of being notified
  31115. */
  31116. skipNextObservers: boolean;
  31117. /**
  31118. * Get the mask value that were used to trigger the event corresponding to this EventState object
  31119. */
  31120. mask: number;
  31121. /**
  31122. * The object that originally notified the event
  31123. */
  31124. target?: any;
  31125. /**
  31126. * The current object in the bubbling phase
  31127. */
  31128. currentTarget?: any;
  31129. /**
  31130. * This will be populated with the return value of the last function that was executed.
  31131. * If it is the first function in the callback chain it will be the event data.
  31132. */
  31133. lastReturnValue?: any;
  31134. }
  31135. /**
  31136. * Represent an Observer registered to a given Observable object.
  31137. */
  31138. class Observer<T> {
  31139. /**
  31140. * Defines the callback to call when the observer is notified
  31141. */
  31142. callback: (eventData: T, eventState: EventState) => void;
  31143. /**
  31144. * Defines the mask of the observer (used to filter notifications)
  31145. */
  31146. mask: number;
  31147. /**
  31148. * Defines the current scope used to restore the JS context
  31149. */
  31150. scope: any;
  31151. /** @hidden */
  31152. _willBeUnregistered: boolean;
  31153. /**
  31154. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  31155. */
  31156. unregisterOnNextCall: boolean;
  31157. /**
  31158. * Creates a new observer
  31159. * @param callback defines the callback to call when the observer is notified
  31160. * @param mask defines the mask of the observer (used to filter notifications)
  31161. * @param scope defines the current scope used to restore the JS context
  31162. */
  31163. constructor(
  31164. /**
  31165. * Defines the callback to call when the observer is notified
  31166. */
  31167. callback: (eventData: T, eventState: EventState) => void,
  31168. /**
  31169. * Defines the mask of the observer (used to filter notifications)
  31170. */
  31171. mask: number,
  31172. /**
  31173. * Defines the current scope used to restore the JS context
  31174. */
  31175. scope?: any);
  31176. }
  31177. /**
  31178. * Represent a list of observers registered to multiple Observables object.
  31179. */
  31180. class MultiObserver<T> {
  31181. private _observers;
  31182. private _observables;
  31183. /**
  31184. * Release associated resources
  31185. */
  31186. dispose(): void;
  31187. /**
  31188. * Raise a callback when one of the observable will notify
  31189. * @param observables defines a list of observables to watch
  31190. * @param callback defines the callback to call on notification
  31191. * @param mask defines the mask used to filter notifications
  31192. * @param scope defines the current scope used to restore the JS context
  31193. * @returns the new MultiObserver
  31194. */
  31195. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  31196. }
  31197. /**
  31198. * The Observable class is a simple implementation of the Observable pattern.
  31199. *
  31200. * 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.
  31201. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  31202. * 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).
  31203. * 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.
  31204. */
  31205. class Observable<T> {
  31206. private _observers;
  31207. private _eventState;
  31208. private _onObserverAdded;
  31209. /**
  31210. * Creates a new observable
  31211. * @param onObserverAdded defines a callback to call when a new observer is added
  31212. */
  31213. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  31214. /**
  31215. * Create a new Observer with the specified callback
  31216. * @param callback the callback that will be executed for that Observer
  31217. * @param mask the mask used to filter observers
  31218. * @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.
  31219. * @param scope optional scope for the callback to be called from
  31220. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  31221. * @returns the new observer created for the callback
  31222. */
  31223. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  31224. /**
  31225. * Create a new Observer with the specified callback and unregisters after the next notification
  31226. * @param callback the callback that will be executed for that Observer
  31227. * @returns the new observer created for the callback
  31228. */
  31229. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  31230. /**
  31231. * Remove an Observer from the Observable object
  31232. * @param observer the instance of the Observer to remove
  31233. * @returns false if it doesn't belong to this Observable
  31234. */
  31235. remove(observer: Nullable<Observer<T>>): boolean;
  31236. /**
  31237. * Remove a callback from the Observable object
  31238. * @param callback the callback to remove
  31239. * @param scope optional scope. If used only the callbacks with this scope will be removed
  31240. * @returns false if it doesn't belong to this Observable
  31241. */
  31242. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  31243. private _deferUnregister;
  31244. private _remove;
  31245. /**
  31246. * Notify all Observers by calling their respective callback with the given data
  31247. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  31248. * @param eventData defines the data to send to all observers
  31249. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  31250. * @param target defines the original target of the state
  31251. * @param currentTarget defines the current target of the state
  31252. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  31253. */
  31254. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  31255. /**
  31256. * Calling this will execute each callback, expecting it to be a promise or return a value.
  31257. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  31258. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  31259. * and it is crucial that all callbacks will be executed.
  31260. * The order of the callbacks is kept, callbacks are not executed parallel.
  31261. *
  31262. * @param eventData The data to be sent to each callback
  31263. * @param mask is used to filter observers defaults to -1
  31264. * @param target defines the callback target (see EventState)
  31265. * @param currentTarget defines he current object in the bubbling phase
  31266. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  31267. */
  31268. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  31269. /**
  31270. * Notify a specific observer
  31271. * @param observer defines the observer to notify
  31272. * @param eventData defines the data to be sent to each callback
  31273. * @param mask is used to filter observers defaults to -1
  31274. */
  31275. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  31276. /**
  31277. * Gets a boolean indicating if the observable has at least one observer
  31278. * @returns true is the Observable has at least one Observer registered
  31279. */
  31280. hasObservers(): boolean;
  31281. /**
  31282. * Clear the list of observers
  31283. */
  31284. clear(): void;
  31285. /**
  31286. * Clone the current observable
  31287. * @returns a new observable
  31288. */
  31289. clone(): Observable<T>;
  31290. /**
  31291. * Does this observable handles observer registered with a given mask
  31292. * @param mask defines the mask to be tested
  31293. * @return whether or not one observer registered with the given mask is handeled
  31294. **/
  31295. hasSpecificMask(mask?: number): boolean;
  31296. }
  31297. }
  31298. declare module BABYLON {
  31299. /**
  31300. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31301. */
  31302. class PerformanceMonitor {
  31303. private _enabled;
  31304. private _rollingFrameTime;
  31305. private _lastFrameTimeMs;
  31306. /**
  31307. * constructor
  31308. * @param frameSampleSize The number of samples required to saturate the sliding window
  31309. */
  31310. constructor(frameSampleSize?: number);
  31311. /**
  31312. * Samples current frame
  31313. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31314. */
  31315. sampleFrame(timeMs?: number): void;
  31316. /**
  31317. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31318. * @return Average frame time in milliseconds
  31319. */
  31320. readonly averageFrameTime: number;
  31321. /**
  31322. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31323. * @return Frame time variance in milliseconds squared
  31324. */
  31325. readonly averageFrameTimeVariance: number;
  31326. /**
  31327. * Returns the frame time of the most recent frame
  31328. * @return Frame time in milliseconds
  31329. */
  31330. readonly instantaneousFrameTime: number;
  31331. /**
  31332. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31333. * @return Framerate in frames per second
  31334. */
  31335. readonly averageFPS: number;
  31336. /**
  31337. * Returns the average framerate in frames per second using the most recent frame time
  31338. * @return Framerate in frames per second
  31339. */
  31340. readonly instantaneousFPS: number;
  31341. /**
  31342. * Returns true if enough samples have been taken to completely fill the sliding window
  31343. * @return true if saturated
  31344. */
  31345. readonly isSaturated: boolean;
  31346. /**
  31347. * Enables contributions to the sliding window sample set
  31348. */
  31349. enable(): void;
  31350. /**
  31351. * Disables contributions to the sliding window sample set
  31352. * Samples will not be interpolated over the disabled period
  31353. */
  31354. disable(): void;
  31355. /**
  31356. * Returns true if sampling is enabled
  31357. * @return true if enabled
  31358. */
  31359. readonly isEnabled: boolean;
  31360. /**
  31361. * Resets performance monitor
  31362. */
  31363. reset(): void;
  31364. }
  31365. /**
  31366. * RollingAverage
  31367. *
  31368. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31369. */
  31370. class RollingAverage {
  31371. /**
  31372. * Current average
  31373. */
  31374. average: number;
  31375. /**
  31376. * Current variance
  31377. */
  31378. variance: number;
  31379. protected _samples: Array<number>;
  31380. protected _sampleCount: number;
  31381. protected _pos: number;
  31382. protected _m2: number;
  31383. /**
  31384. * constructor
  31385. * @param length The number of samples required to saturate the sliding window
  31386. */
  31387. constructor(length: number);
  31388. /**
  31389. * Adds a sample to the sample set
  31390. * @param v The sample value
  31391. */
  31392. add(v: number): void;
  31393. /**
  31394. * Returns previously added values or null if outside of history or outside the sliding window domain
  31395. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31396. * @return Value previously recorded with add() or null if outside of range
  31397. */
  31398. history(i: number): number;
  31399. /**
  31400. * Returns true if enough samples have been taken to completely fill the sliding window
  31401. * @return true if sample-set saturated
  31402. */
  31403. isSaturated(): boolean;
  31404. /**
  31405. * Resets the rolling average (equivalent to 0 samples taken so far)
  31406. */
  31407. reset(): void;
  31408. /**
  31409. * Wraps a value around the sample range boundaries
  31410. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31411. * @return Wrapped position in sample range
  31412. */
  31413. protected _wrapPosition(i: number): number;
  31414. }
  31415. }
  31416. declare module BABYLON {
  31417. /**
  31418. * Helper class that provides a small promise polyfill
  31419. */
  31420. class PromisePolyfill {
  31421. /**
  31422. * Static function used to check if the polyfill is required
  31423. * If this is the case then the function will inject the polyfill to window.Promise
  31424. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31425. */
  31426. static Apply(force?: boolean): void;
  31427. }
  31428. }
  31429. declare module BABYLON {
  31430. /**
  31431. * Defines the root class used to create scene optimization to use with SceneOptimizer
  31432. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31433. */
  31434. class SceneOptimization {
  31435. /**
  31436. * Defines the priority of this optimization (0 by default which means first in the list)
  31437. */
  31438. priority: number;
  31439. /**
  31440. * Gets a string describing the action executed by the current optimization
  31441. * @returns description string
  31442. */
  31443. getDescription(): string;
  31444. /**
  31445. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31446. * @param scene defines the current scene where to apply this optimization
  31447. * @param optimizer defines the current optimizer
  31448. * @returns true if everything that can be done was applied
  31449. */
  31450. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31451. /**
  31452. * Creates the SceneOptimization object
  31453. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  31454. * @param desc defines the description associated with the optimization
  31455. */
  31456. constructor(
  31457. /**
  31458. * Defines the priority of this optimization (0 by default which means first in the list)
  31459. */
  31460. priority?: number);
  31461. }
  31462. /**
  31463. * Defines an optimization used to reduce the size of render target textures
  31464. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31465. */
  31466. class TextureOptimization extends SceneOptimization {
  31467. /**
  31468. * Defines the priority of this optimization (0 by default which means first in the list)
  31469. */
  31470. priority: number;
  31471. /**
  31472. * 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
  31473. */
  31474. maximumSize: number;
  31475. /**
  31476. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  31477. */
  31478. step: number;
  31479. /**
  31480. * Gets a string describing the action executed by the current optimization
  31481. * @returns description string
  31482. */
  31483. getDescription(): string;
  31484. /**
  31485. * Creates the TextureOptimization object
  31486. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  31487. * @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
  31488. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  31489. */
  31490. constructor(
  31491. /**
  31492. * Defines the priority of this optimization (0 by default which means first in the list)
  31493. */
  31494. priority?: number,
  31495. /**
  31496. * 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
  31497. */
  31498. maximumSize?: number,
  31499. /**
  31500. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  31501. */
  31502. step?: number);
  31503. /**
  31504. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31505. * @param scene defines the current scene where to apply this optimization
  31506. * @param optimizer defines the current optimizer
  31507. * @returns true if everything that can be done was applied
  31508. */
  31509. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31510. }
  31511. /**
  31512. * Defines an optimization used to increase or decrease the rendering resolution
  31513. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31514. */
  31515. class HardwareScalingOptimization extends SceneOptimization {
  31516. /**
  31517. * Defines the priority of this optimization (0 by default which means first in the list)
  31518. */
  31519. priority: number;
  31520. /**
  31521. * Defines the maximum scale to use (2 by default)
  31522. */
  31523. maximumScale: number;
  31524. /**
  31525. * Defines the step to use between two passes (0.5 by default)
  31526. */
  31527. step: number;
  31528. private _currentScale;
  31529. private _directionOffset;
  31530. /**
  31531. * Gets a string describing the action executed by the current optimization
  31532. * @return description string
  31533. */
  31534. getDescription(): string;
  31535. /**
  31536. * Creates the HardwareScalingOptimization object
  31537. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  31538. * @param maximumScale defines the maximum scale to use (2 by default)
  31539. * @param step defines the step to use between two passes (0.5 by default)
  31540. */
  31541. constructor(
  31542. /**
  31543. * Defines the priority of this optimization (0 by default which means first in the list)
  31544. */
  31545. priority?: number,
  31546. /**
  31547. * Defines the maximum scale to use (2 by default)
  31548. */
  31549. maximumScale?: number,
  31550. /**
  31551. * Defines the step to use between two passes (0.5 by default)
  31552. */
  31553. step?: number);
  31554. /**
  31555. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31556. * @param scene defines the current scene where to apply this optimization
  31557. * @param optimizer defines the current optimizer
  31558. * @returns true if everything that can be done was applied
  31559. */
  31560. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31561. }
  31562. /**
  31563. * Defines an optimization used to remove shadows
  31564. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31565. */
  31566. class ShadowsOptimization extends SceneOptimization {
  31567. /**
  31568. * Gets a string describing the action executed by the current optimization
  31569. * @return description string
  31570. */
  31571. getDescription(): string;
  31572. /**
  31573. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31574. * @param scene defines the current scene where to apply this optimization
  31575. * @param optimizer defines the current optimizer
  31576. * @returns true if everything that can be done was applied
  31577. */
  31578. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31579. }
  31580. /**
  31581. * Defines an optimization used to turn post-processes off
  31582. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31583. */
  31584. class PostProcessesOptimization extends SceneOptimization {
  31585. /**
  31586. * Gets a string describing the action executed by the current optimization
  31587. * @return description string
  31588. */
  31589. getDescription(): string;
  31590. /**
  31591. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31592. * @param scene defines the current scene where to apply this optimization
  31593. * @param optimizer defines the current optimizer
  31594. * @returns true if everything that can be done was applied
  31595. */
  31596. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31597. }
  31598. /**
  31599. * Defines an optimization used to turn lens flares off
  31600. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31601. */
  31602. class LensFlaresOptimization extends SceneOptimization {
  31603. /**
  31604. * Gets a string describing the action executed by the current optimization
  31605. * @return description string
  31606. */
  31607. getDescription(): string;
  31608. /**
  31609. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31610. * @param scene defines the current scene where to apply this optimization
  31611. * @param optimizer defines the current optimizer
  31612. * @returns true if everything that can be done was applied
  31613. */
  31614. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31615. }
  31616. /**
  31617. * Defines an optimization based on user defined callback.
  31618. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31619. */
  31620. class CustomOptimization extends SceneOptimization {
  31621. /**
  31622. * Callback called to apply the custom optimization.
  31623. */
  31624. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  31625. /**
  31626. * Callback called to get custom description
  31627. */
  31628. onGetDescription: () => string;
  31629. /**
  31630. * Gets a string describing the action executed by the current optimization
  31631. * @returns description string
  31632. */
  31633. getDescription(): string;
  31634. /**
  31635. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31636. * @param scene defines the current scene where to apply this optimization
  31637. * @param optimizer defines the current optimizer
  31638. * @returns true if everything that can be done was applied
  31639. */
  31640. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31641. }
  31642. /**
  31643. * Defines an optimization used to turn particles off
  31644. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31645. */
  31646. class ParticlesOptimization extends SceneOptimization {
  31647. /**
  31648. * Gets a string describing the action executed by the current optimization
  31649. * @return description string
  31650. */
  31651. getDescription(): string;
  31652. /**
  31653. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31654. * @param scene defines the current scene where to apply this optimization
  31655. * @param optimizer defines the current optimizer
  31656. * @returns true if everything that can be done was applied
  31657. */
  31658. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31659. }
  31660. /**
  31661. * Defines an optimization used to turn render targets off
  31662. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31663. */
  31664. class RenderTargetsOptimization extends SceneOptimization {
  31665. /**
  31666. * Gets a string describing the action executed by the current optimization
  31667. * @return description string
  31668. */
  31669. getDescription(): string;
  31670. /**
  31671. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31672. * @param scene defines the current scene where to apply this optimization
  31673. * @param optimizer defines the current optimizer
  31674. * @returns true if everything that can be done was applied
  31675. */
  31676. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  31677. }
  31678. /**
  31679. * Defines an optimization used to merge meshes with compatible materials
  31680. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31681. */
  31682. class MergeMeshesOptimization extends SceneOptimization {
  31683. private static _UpdateSelectionTree;
  31684. /**
  31685. * Gets or sets a boolean which defines if optimization octree has to be updated
  31686. */
  31687. /**
  31688. * Gets or sets a boolean which defines if optimization octree has to be updated
  31689. */
  31690. static UpdateSelectionTree: boolean;
  31691. /**
  31692. * Gets a string describing the action executed by the current optimization
  31693. * @return description string
  31694. */
  31695. getDescription(): string;
  31696. private _canBeMerged;
  31697. /**
  31698. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  31699. * @param scene defines the current scene where to apply this optimization
  31700. * @param optimizer defines the current optimizer
  31701. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  31702. * @returns true if everything that can be done was applied
  31703. */
  31704. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  31705. }
  31706. /**
  31707. * Defines a list of options used by SceneOptimizer
  31708. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31709. */
  31710. class SceneOptimizerOptions {
  31711. /**
  31712. * Defines the target frame rate to reach (60 by default)
  31713. */
  31714. targetFrameRate: number;
  31715. /**
  31716. * Defines the interval between two checkes (2000ms by default)
  31717. */
  31718. trackerDuration: number;
  31719. /**
  31720. * Gets the list of optimizations to apply
  31721. */
  31722. optimizations: SceneOptimization[];
  31723. /**
  31724. * Creates a new list of options used by SceneOptimizer
  31725. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  31726. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  31727. */
  31728. constructor(
  31729. /**
  31730. * Defines the target frame rate to reach (60 by default)
  31731. */
  31732. targetFrameRate?: number,
  31733. /**
  31734. * Defines the interval between two checkes (2000ms by default)
  31735. */
  31736. trackerDuration?: number);
  31737. /**
  31738. * Add a new optimization
  31739. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  31740. * @returns the current SceneOptimizerOptions
  31741. */
  31742. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  31743. /**
  31744. * Add a new custom optimization
  31745. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  31746. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  31747. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  31748. * @returns the current SceneOptimizerOptions
  31749. */
  31750. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  31751. /**
  31752. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  31753. * @param targetFrameRate defines the target frame rate (60 by default)
  31754. * @returns a SceneOptimizerOptions object
  31755. */
  31756. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  31757. /**
  31758. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  31759. * @param targetFrameRate defines the target frame rate (60 by default)
  31760. * @returns a SceneOptimizerOptions object
  31761. */
  31762. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  31763. /**
  31764. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  31765. * @param targetFrameRate defines the target frame rate (60 by default)
  31766. * @returns a SceneOptimizerOptions object
  31767. */
  31768. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  31769. }
  31770. /**
  31771. * Class used to run optimizations in order to reach a target frame rate
  31772. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  31773. */
  31774. class SceneOptimizer implements IDisposable {
  31775. private _isRunning;
  31776. private _options;
  31777. private _scene;
  31778. private _currentPriorityLevel;
  31779. private _targetFrameRate;
  31780. private _trackerDuration;
  31781. private _currentFrameRate;
  31782. private _sceneDisposeObserver;
  31783. private _improvementMode;
  31784. /**
  31785. * Defines an observable called when the optimizer reaches the target frame rate
  31786. */
  31787. onSuccessObservable: Observable<SceneOptimizer>;
  31788. /**
  31789. * Defines an observable called when the optimizer enables an optimization
  31790. */
  31791. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  31792. /**
  31793. * Defines an observable called when the optimizer is not able to reach the target frame rate
  31794. */
  31795. onFailureObservable: Observable<SceneOptimizer>;
  31796. /**
  31797. * Gets a boolean indicating if the optimizer is in improvement mode
  31798. */
  31799. readonly isInImprovementMode: boolean;
  31800. /**
  31801. * Gets the current priority level (0 at start)
  31802. */
  31803. readonly currentPriorityLevel: number;
  31804. /**
  31805. * Gets the current frame rate checked by the SceneOptimizer
  31806. */
  31807. readonly currentFrameRate: number;
  31808. /**
  31809. * Gets or sets the current target frame rate (60 by default)
  31810. */
  31811. /**
  31812. * Gets or sets the current target frame rate (60 by default)
  31813. */
  31814. targetFrameRate: number;
  31815. /**
  31816. * Gets or sets the current interval between two checks (every 2000ms by default)
  31817. */
  31818. /**
  31819. * Gets or sets the current interval between two checks (every 2000ms by default)
  31820. */
  31821. trackerDuration: number;
  31822. /**
  31823. * Gets the list of active optimizations
  31824. */
  31825. readonly optimizations: SceneOptimization[];
  31826. /**
  31827. * Creates a new SceneOptimizer
  31828. * @param scene defines the scene to work on
  31829. * @param options defines the options to use with the SceneOptimizer
  31830. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  31831. * @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)
  31832. */
  31833. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  31834. /**
  31835. * Stops the current optimizer
  31836. */
  31837. stop(): void;
  31838. /**
  31839. * Reset the optimizer to initial step (current priority level = 0)
  31840. */
  31841. reset(): void;
  31842. /**
  31843. * Start the optimizer. By default it will try to reach a specific framerate
  31844. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  31845. */
  31846. start(): void;
  31847. private _checkCurrentState;
  31848. /**
  31849. * Release all resources
  31850. */
  31851. dispose(): void;
  31852. /**
  31853. * Helper function to create a SceneOptimizer with one single line of code
  31854. * @param scene defines the scene to work on
  31855. * @param options defines the options to use with the SceneOptimizer
  31856. * @param onSuccess defines a callback to call on success
  31857. * @param onFailure defines a callback to call on failure
  31858. * @returns the new SceneOptimizer object
  31859. */
  31860. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  31861. }
  31862. }
  31863. declare module BABYLON {
  31864. class SceneSerializer {
  31865. static ClearCache(): void;
  31866. static Serialize(scene: Scene): any;
  31867. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  31868. }
  31869. }
  31870. declare module BABYLON {
  31871. /**
  31872. * Defines an array and its length.
  31873. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  31874. */
  31875. interface ISmartArrayLike<T> {
  31876. /**
  31877. * The data of the array.
  31878. */
  31879. data: Array<T>;
  31880. /**
  31881. * The active length of the array.
  31882. */
  31883. length: number;
  31884. }
  31885. /**
  31886. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  31887. */
  31888. class SmartArray<T> implements ISmartArrayLike<T> {
  31889. /**
  31890. * The full set of data from the array.
  31891. */
  31892. data: Array<T>;
  31893. /**
  31894. * The active length of the array.
  31895. */
  31896. length: number;
  31897. protected _id: number;
  31898. /**
  31899. * Instantiates a Smart Array.
  31900. * @param capacity defines the default capacity of the array.
  31901. */
  31902. constructor(capacity: number);
  31903. /**
  31904. * Pushes a value at the end of the active data.
  31905. * @param value defines the object to push in the array.
  31906. */
  31907. push(value: T): void;
  31908. /**
  31909. * Iterates over the active data and apply the lambda to them.
  31910. * @param func defines the action to apply on each value.
  31911. */
  31912. forEach(func: (content: T) => void): void;
  31913. /**
  31914. * Sorts the full sets of data.
  31915. * @param compareFn defines the comparison function to apply.
  31916. */
  31917. sort(compareFn: (a: T, b: T) => number): void;
  31918. /**
  31919. * Resets the active data to an empty array.
  31920. */
  31921. reset(): void;
  31922. /**
  31923. * Releases all the data from the array as well as the array.
  31924. */
  31925. dispose(): void;
  31926. /**
  31927. * Concats the active data with a given array.
  31928. * @param array defines the data to concatenate with.
  31929. */
  31930. concat(array: any): void;
  31931. /**
  31932. * Returns the position of a value in the active data.
  31933. * @param value defines the value to find the index for
  31934. * @returns the index if found in the active data otherwise -1
  31935. */
  31936. indexOf(value: T): number;
  31937. /**
  31938. * Returns whether an element is part of the active data.
  31939. * @param value defines the value to look for
  31940. * @returns true if found in the active data otherwise false
  31941. */
  31942. contains(value: T): boolean;
  31943. private static _GlobalId;
  31944. }
  31945. /**
  31946. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  31947. * The data in this array can only be present once
  31948. */
  31949. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  31950. private _duplicateId;
  31951. /**
  31952. * Pushes a value at the end of the active data.
  31953. * THIS DOES NOT PREVENT DUPPLICATE DATA
  31954. * @param value defines the object to push in the array.
  31955. */
  31956. push(value: T): void;
  31957. /**
  31958. * Pushes a value at the end of the active data.
  31959. * If the data is already present, it won t be added again
  31960. * @param value defines the object to push in the array.
  31961. * @returns true if added false if it was already present
  31962. */
  31963. pushNoDuplicate(value: T): boolean;
  31964. /**
  31965. * Resets the active data to an empty array.
  31966. */
  31967. reset(): void;
  31968. /**
  31969. * Concats the active data with a given array.
  31970. * This ensures no dupplicate will be present in the result.
  31971. * @param array defines the data to concatenate with.
  31972. */
  31973. concatWithNoDuplicate(array: any): void;
  31974. }
  31975. }
  31976. declare module BABYLON {
  31977. /**
  31978. * This class implement a typical dictionary using a string as key and the generic type T as value.
  31979. * The underlying implementation relies on an associative array to ensure the best performances.
  31980. * The value can be anything including 'null' but except 'undefined'
  31981. */
  31982. class StringDictionary<T> {
  31983. /**
  31984. * This will clear this dictionary and copy the content from the 'source' one.
  31985. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  31986. * @param source the dictionary to take the content from and copy to this dictionary
  31987. */
  31988. copyFrom(source: StringDictionary<T>): void;
  31989. /**
  31990. * Get a value based from its key
  31991. * @param key the given key to get the matching value from
  31992. * @return the value if found, otherwise undefined is returned
  31993. */
  31994. get(key: string): T | undefined;
  31995. /**
  31996. * Get a value from its key or add it if it doesn't exist.
  31997. * This method will ensure you that a given key/data will be present in the dictionary.
  31998. * @param key the given key to get the matching value from
  31999. * @param factory the factory that will create the value if the key is not present in the dictionary.
  32000. * The factory will only be invoked if there's no data for the given key.
  32001. * @return the value corresponding to the key.
  32002. */
  32003. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  32004. /**
  32005. * Get a value from its key if present in the dictionary otherwise add it
  32006. * @param key the key to get the value from
  32007. * @param val if there's no such key/value pair in the dictionary add it with this value
  32008. * @return the value corresponding to the key
  32009. */
  32010. getOrAdd(key: string, val: T): T;
  32011. /**
  32012. * Check if there's a given key in the dictionary
  32013. * @param key the key to check for
  32014. * @return true if the key is present, false otherwise
  32015. */
  32016. contains(key: string): boolean;
  32017. /**
  32018. * Add a new key and its corresponding value
  32019. * @param key the key to add
  32020. * @param value the value corresponding to the key
  32021. * @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
  32022. */
  32023. add(key: string, value: T): boolean;
  32024. set(key: string, value: T): boolean;
  32025. /**
  32026. * Get the element of the given key and remove it from the dictionary
  32027. * @param key
  32028. */
  32029. getAndRemove(key: string): Nullable<T>;
  32030. /**
  32031. * Remove a key/value from the dictionary.
  32032. * @param key the key to remove
  32033. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32034. */
  32035. remove(key: string): boolean;
  32036. /**
  32037. * Clear the whole content of the dictionary
  32038. */
  32039. clear(): void;
  32040. readonly count: number;
  32041. /**
  32042. * Execute a callback on each key/val of the dictionary.
  32043. * Note that you can remove any element in this dictionary in the callback implementation
  32044. * @param callback the callback to execute on a given key/value pair
  32045. */
  32046. forEach(callback: (key: string, val: T) => void): void;
  32047. /**
  32048. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32049. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32050. * Note that you can remove any element in this dictionary in the callback implementation
  32051. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32052. */
  32053. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32054. private _count;
  32055. private _data;
  32056. }
  32057. }
  32058. declare module BABYLON {
  32059. class Tags {
  32060. static EnableFor(obj: any): void;
  32061. static DisableFor(obj: any): void;
  32062. static HasTags(obj: any): boolean;
  32063. static GetTags(obj: any, asString?: boolean): any;
  32064. static AddTagsTo(obj: any, tagsString: string): void;
  32065. static _AddTagTo(obj: any, tag: string): void;
  32066. static RemoveTagsFrom(obj: any, tagsString: string): void;
  32067. static _RemoveTagFrom(obj: any, tag: string): void;
  32068. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  32069. }
  32070. }
  32071. declare module BABYLON {
  32072. class TextureTools {
  32073. /**
  32074. * Uses the GPU to create a copy texture rescaled at a given size
  32075. * @param texture Texture to copy from
  32076. * @param width Desired width
  32077. * @param height Desired height
  32078. * @return Generated texture
  32079. */
  32080. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  32081. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  32082. private static _environmentBRDFBase64Texture;
  32083. }
  32084. }
  32085. declare module BABYLON {
  32086. class TGATools {
  32087. private static _TYPE_INDEXED;
  32088. private static _TYPE_RGB;
  32089. private static _TYPE_GREY;
  32090. private static _TYPE_RLE_INDEXED;
  32091. private static _TYPE_RLE_RGB;
  32092. private static _TYPE_RLE_GREY;
  32093. private static _ORIGIN_MASK;
  32094. private static _ORIGIN_SHIFT;
  32095. private static _ORIGIN_BL;
  32096. private static _ORIGIN_BR;
  32097. private static _ORIGIN_UL;
  32098. private static _ORIGIN_UR;
  32099. static GetTGAHeader(data: Uint8Array): any;
  32100. /**
  32101. * Uploads TGA content to a Babylon Texture
  32102. * @hidden
  32103. */
  32104. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  32105. 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;
  32106. 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;
  32107. 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;
  32108. 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;
  32109. 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;
  32110. 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;
  32111. }
  32112. }
  32113. declare module BABYLON {
  32114. interface IAnimatable {
  32115. animations: Array<Animation>;
  32116. }
  32117. /** Interface used by value gradients (color, factor, ...) */
  32118. interface IValueGradient {
  32119. /**
  32120. * Gets or sets the gradient value (between 0 and 1)
  32121. */
  32122. gradient: number;
  32123. }
  32124. /** Class used to store color4 gradient */
  32125. class ColorGradient implements IValueGradient {
  32126. /**
  32127. * Gets or sets the gradient value (between 0 and 1)
  32128. */
  32129. gradient: number;
  32130. /**
  32131. * Gets or sets first associated color
  32132. */
  32133. color1: Color4;
  32134. /**
  32135. * Gets or sets second associated color
  32136. */
  32137. color2?: Color4;
  32138. /**
  32139. * Will get a color picked randomly between color1 and color2.
  32140. * If color2 is undefined then color1 will be used
  32141. * @param result defines the target Color4 to store the result in
  32142. */
  32143. getColorToRef(result: Color4): void;
  32144. }
  32145. /** Class used to store color 3 gradient */
  32146. class Color3Gradient implements IValueGradient {
  32147. /**
  32148. * Gets or sets the gradient value (between 0 and 1)
  32149. */
  32150. gradient: number;
  32151. /**
  32152. * Gets or sets the associated color
  32153. */
  32154. color: Color3;
  32155. }
  32156. /** Class used to store factor gradient */
  32157. class FactorGradient implements IValueGradient {
  32158. /**
  32159. * Gets or sets the gradient value (between 0 and 1)
  32160. */
  32161. gradient: number;
  32162. /**
  32163. * Gets or sets first associated factor
  32164. */
  32165. factor1: number;
  32166. /**
  32167. * Gets or sets second associated factor
  32168. */
  32169. factor2?: number;
  32170. /**
  32171. * Will get a number picked randomly between factor1 and factor2.
  32172. * If factor2 is undefined then factor1 will be used
  32173. * @returns the picked number
  32174. */
  32175. getFactor(): number;
  32176. }
  32177. class LoadFileError extends Error {
  32178. request?: XMLHttpRequest | undefined;
  32179. private static _setPrototypeOf;
  32180. constructor(message: string, request?: XMLHttpRequest | undefined);
  32181. }
  32182. class RetryStrategy {
  32183. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  32184. }
  32185. interface IFileRequest {
  32186. /**
  32187. * Raised when the request is complete (success or error).
  32188. */
  32189. onCompleteObservable: Observable<IFileRequest>;
  32190. /**
  32191. * Aborts the request for a file.
  32192. */
  32193. abort: () => void;
  32194. }
  32195. class Tools {
  32196. static BaseUrl: string;
  32197. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  32198. /**
  32199. * Default behaviour for cors in the application.
  32200. * It can be a string if the expected behavior is identical in the entire app.
  32201. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32202. */
  32203. static CorsBehavior: string | ((url: string | string[]) => string);
  32204. static UseFallbackTexture: boolean;
  32205. /**
  32206. * Use this object to register external classes like custom textures or material
  32207. * to allow the laoders to instantiate them
  32208. */
  32209. static RegisteredExternalClasses: {
  32210. [key: string]: Object;
  32211. };
  32212. static fallbackTexture: string;
  32213. /**
  32214. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32215. * @param u defines the coordinate on X axis
  32216. * @param v defines the coordinate on Y axis
  32217. * @param width defines the width of the source data
  32218. * @param height defines the height of the source data
  32219. * @param pixels defines the source byte array
  32220. * @param color defines the output color
  32221. */
  32222. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  32223. /**
  32224. * Interpolates between a and b via alpha
  32225. * @param a The lower value (returned when alpha = 0)
  32226. * @param b The upper value (returned when alpha = 1)
  32227. * @param alpha The interpolation-factor
  32228. * @return The mixed value
  32229. */
  32230. static Mix(a: number, b: number, alpha: number): number;
  32231. static Instantiate(className: string): any;
  32232. /**
  32233. * Provides a slice function that will work even on IE
  32234. * @param data defines the array to slice
  32235. * @param start defines the start of the data (optional)
  32236. * @param end defines the end of the data (optional)
  32237. * @returns the new sliced array
  32238. */
  32239. static Slice<T>(data: T, start?: number, end?: number): T;
  32240. static SetImmediate(action: () => void): void;
  32241. static IsExponentOfTwo(value: number): boolean;
  32242. private static _tmpFloatArray;
  32243. /**
  32244. * Returns the nearest 32-bit single precision float representation of a Number
  32245. * @param value A Number. If the parameter is of a different type, it will get converted
  32246. * to a number or to NaN if it cannot be converted
  32247. * @returns number
  32248. */
  32249. static FloatRound(value: number): number;
  32250. /**
  32251. * Find the next highest power of two.
  32252. * @param x Number to start search from.
  32253. * @return Next highest power of two.
  32254. */
  32255. static CeilingPOT(x: number): number;
  32256. /**
  32257. * Find the next lowest power of two.
  32258. * @param x Number to start search from.
  32259. * @return Next lowest power of two.
  32260. */
  32261. static FloorPOT(x: number): number;
  32262. /**
  32263. * Find the nearest power of two.
  32264. * @param x Number to start search from.
  32265. * @return Next nearest power of two.
  32266. */
  32267. static NearestPOT(x: number): number;
  32268. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32269. static GetFilename(path: string): string;
  32270. /**
  32271. * Extracts the "folder" part of a path (everything before the filename).
  32272. * @param uri The URI to extract the info from
  32273. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32274. * @returns The "folder" part of the path
  32275. */
  32276. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32277. static GetDOMTextContent(element: HTMLElement): string;
  32278. static ToDegrees(angle: number): number;
  32279. static ToRadians(angle: number): number;
  32280. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32281. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  32282. minimum: Vector3;
  32283. maximum: Vector3;
  32284. };
  32285. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  32286. minimum: Vector3;
  32287. maximum: Vector3;
  32288. };
  32289. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  32290. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  32291. minimum: Vector2;
  32292. maximum: Vector2;
  32293. };
  32294. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32295. static GetPointerPrefix(): string;
  32296. /**
  32297. * @param func - the function to be called
  32298. * @param requester - the object that will request the next frame. Falls back to window.
  32299. */
  32300. static QueueNewFrame(func: () => void, requester?: any): number;
  32301. static RequestFullscreen(element: HTMLElement): void;
  32302. static ExitFullscreen(): void;
  32303. static SetCorsBehavior(url: string | string[], element: {
  32304. crossOrigin: string | null;
  32305. }): void;
  32306. static CleanUrl(url: string): string;
  32307. static PreprocessUrl: (url: string) => string;
  32308. /**
  32309. * Loads an image as an HTMLImageElement.
  32310. * @param input url string, ArrayBuffer, or Blob to load
  32311. * @param onLoad callback called when the image successfully loads
  32312. * @param onError callback called when the image fails to load
  32313. * @param database database for caching
  32314. * @returns the HTMLImageElement of the loaded image
  32315. */
  32316. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  32317. 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;
  32318. /**
  32319. * Load a script (identified by an url). When the url returns, the
  32320. * content of this file is added into a new script element, attached to the DOM (body element)
  32321. */
  32322. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  32323. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32324. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32325. static FileAsURL(content: string): string;
  32326. static Format(value: number, decimals?: number): string;
  32327. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32328. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32329. static IsEmpty(obj: any): boolean;
  32330. static RegisterTopRootEvents(events: {
  32331. name: string;
  32332. handler: Nullable<(e: FocusEvent) => any>;
  32333. }[]): void;
  32334. static UnregisterTopRootEvents(events: {
  32335. name: string;
  32336. handler: Nullable<(e: FocusEvent) => any>;
  32337. }[]): void;
  32338. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32339. /**
  32340. * Converts the canvas data to blob.
  32341. * This acts as a polyfill for browsers not supporting the to blob function.
  32342. * @param canvas Defines the canvas to extract the data from
  32343. * @param successCallback Defines the callback triggered once the data are available
  32344. * @param mimeType Defines the mime type of the result
  32345. */
  32346. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32347. /**
  32348. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32349. * @param successCallback Defines the callback triggered once the data are available
  32350. * @param mimeType Defines the mime type of the result
  32351. * @param fileName The filename to download. If present, the result will automatically be downloaded
  32352. */
  32353. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32354. /**
  32355. * Downloads a blob in the browser
  32356. * @param blob defines the blob to download
  32357. * @param fileName defines the name of the downloaded file
  32358. */
  32359. static Download(blob: Blob, fileName: string): void;
  32360. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32361. /**
  32362. * Generates an image screenshot from the specified camera.
  32363. *
  32364. * @param engine The engine to use for rendering
  32365. * @param camera The camera to use for rendering
  32366. * @param size This parameter can be set to a single number or to an object with the
  32367. * following (optional) properties: precision, width, height. If a single number is passed,
  32368. * it will be used for both width and height. If an object is passed, the screenshot size
  32369. * will be derived from the parameters. The precision property is a multiplier allowing
  32370. * rendering at a higher or lower resolution.
  32371. * @param successCallback The callback receives a single parameter which contains the
  32372. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32373. * src parameter of an <img> to display it.
  32374. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32375. * Check your browser for supported MIME types.
  32376. * @param samples Texture samples (default: 1)
  32377. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32378. * @param fileName A name for for the downloaded file.
  32379. * @constructor
  32380. */
  32381. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32382. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  32383. /**
  32384. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32385. * Be aware Math.random() could cause collisions, but:
  32386. * "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"
  32387. */
  32388. static RandomId(): string;
  32389. /**
  32390. * Test if the given uri is a base64 string.
  32391. * @param uri The uri to test
  32392. * @return True if the uri is a base64 string or false otherwise.
  32393. */
  32394. static IsBase64(uri: string): boolean;
  32395. /**
  32396. * Decode the given base64 uri.
  32397. * @param uri The uri to decode
  32398. * @return The decoded base64 data.
  32399. */
  32400. static DecodeBase64(uri: string): ArrayBuffer;
  32401. private static _NoneLogLevel;
  32402. private static _MessageLogLevel;
  32403. private static _WarningLogLevel;
  32404. private static _ErrorLogLevel;
  32405. private static _LogCache;
  32406. static errorsCount: number;
  32407. static OnNewCacheEntry: (entry: string) => void;
  32408. static readonly NoneLogLevel: number;
  32409. static readonly MessageLogLevel: number;
  32410. static readonly WarningLogLevel: number;
  32411. static readonly ErrorLogLevel: number;
  32412. static readonly AllLogLevel: number;
  32413. private static _AddLogEntry;
  32414. private static _FormatMessage;
  32415. private static _LogDisabled;
  32416. private static _LogEnabled;
  32417. private static _WarnDisabled;
  32418. private static _WarnEnabled;
  32419. private static _ErrorDisabled;
  32420. private static _ErrorEnabled;
  32421. static Log: (message: string) => void;
  32422. static Warn: (message: string) => void;
  32423. static Error: (message: string) => void;
  32424. static readonly LogCache: string;
  32425. static ClearLogCache(): void;
  32426. static LogLevels: number;
  32427. /**
  32428. * Check if the loaded document was accessed via `file:`-Protocol.
  32429. * @returns boolean
  32430. */
  32431. static IsFileURL(): boolean;
  32432. static IsWindowObjectExist(): boolean;
  32433. private static _PerformanceNoneLogLevel;
  32434. private static _PerformanceUserMarkLogLevel;
  32435. private static _PerformanceConsoleLogLevel;
  32436. private static _performance;
  32437. static readonly PerformanceNoneLogLevel: number;
  32438. static readonly PerformanceUserMarkLogLevel: number;
  32439. static readonly PerformanceConsoleLogLevel: number;
  32440. static PerformanceLogLevel: number;
  32441. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  32442. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  32443. static _StartUserMark(counterName: string, condition?: boolean): void;
  32444. static _EndUserMark(counterName: string, condition?: boolean): void;
  32445. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  32446. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  32447. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32448. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32449. static readonly Now: number;
  32450. /**
  32451. * This method will return the name of the class used to create the instance of the given object.
  32452. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32453. * @param object the object to get the class name from
  32454. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  32455. */
  32456. static GetClassName(object: any, isType?: boolean): string;
  32457. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32458. /**
  32459. * This method will return the name of the full name of the class, including its owning module (if any).
  32460. * 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).
  32461. * @param object the object to get the class name from
  32462. * @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.
  32463. */
  32464. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32465. /**
  32466. * 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.
  32467. * @param array
  32468. */
  32469. static arrayOrStringFeeder(array: any): (i: number) => number;
  32470. /**
  32471. * Compute the hashCode of a stream of number
  32472. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  32473. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  32474. * @return the hash code computed
  32475. */
  32476. static hashCodeFromStream(feeder: (index: number) => number): number;
  32477. /**
  32478. * Returns a promise that resolves after the given amount of time.
  32479. * @param delay Number of milliseconds to delay
  32480. * @returns Promise that resolves after the given amount of time
  32481. */
  32482. static DelayAsync(delay: number): Promise<void>;
  32483. /**
  32484. * Gets the current gradient from an array of IValueGradient
  32485. * @param ratio defines the current ratio to get
  32486. * @param gradients defines the array of IValueGradient
  32487. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32488. */
  32489. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32490. }
  32491. /**
  32492. * This class is used to track a performance counter which is number based.
  32493. * The user has access to many properties which give statistics of different nature
  32494. *
  32495. * The implementer can track two kinds of Performance Counter: time and count
  32496. * 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.
  32497. * 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.
  32498. */
  32499. class PerfCounter {
  32500. static Enabled: boolean;
  32501. /**
  32502. * Returns the smallest value ever
  32503. */
  32504. readonly min: number;
  32505. /**
  32506. * Returns the biggest value ever
  32507. */
  32508. readonly max: number;
  32509. /**
  32510. * Returns the average value since the performance counter is running
  32511. */
  32512. readonly average: number;
  32513. /**
  32514. * Returns the average value of the last second the counter was monitored
  32515. */
  32516. readonly lastSecAverage: number;
  32517. /**
  32518. * Returns the current value
  32519. */
  32520. readonly current: number;
  32521. readonly total: number;
  32522. readonly count: number;
  32523. constructor();
  32524. /**
  32525. * Call this method to start monitoring a new frame.
  32526. * 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.
  32527. */
  32528. fetchNewFrame(): void;
  32529. /**
  32530. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32531. * @param newCount the count value to add to the monitored count
  32532. * @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.
  32533. */
  32534. addCount(newCount: number, fetchResult: boolean): void;
  32535. /**
  32536. * Start monitoring this performance counter
  32537. */
  32538. beginMonitoring(): void;
  32539. /**
  32540. * Compute the time lapsed since the previous beginMonitoring() call.
  32541. * @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
  32542. */
  32543. endMonitoring(newFrame?: boolean): void;
  32544. private _fetchResult;
  32545. private _startMonitoringTime;
  32546. private _min;
  32547. private _max;
  32548. private _average;
  32549. private _current;
  32550. private _totalValueCount;
  32551. private _totalAccumulated;
  32552. private _lastSecAverage;
  32553. private _lastSecAccumulated;
  32554. private _lastSecTime;
  32555. private _lastSecValueCount;
  32556. }
  32557. /**
  32558. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32559. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32560. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32561. * @param name The name of the class, case should be preserved
  32562. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32563. */
  32564. function className(name: string, module?: string): (target: Object) => void;
  32565. /**
  32566. * An implementation of a loop for asynchronous functions.
  32567. */
  32568. class AsyncLoop {
  32569. iterations: number;
  32570. private _fn;
  32571. private _successCallback;
  32572. index: number;
  32573. private _done;
  32574. /**
  32575. * Constroctor.
  32576. * @param iterations the number of iterations.
  32577. * @param _fn the function to run each iteration
  32578. * @param _successCallback the callback that will be called upon succesful execution
  32579. * @param offset starting offset.
  32580. */
  32581. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  32582. /**
  32583. * Execute the next iteration. Must be called after the last iteration was finished.
  32584. */
  32585. executeNext(): void;
  32586. /**
  32587. * Break the loop and run the success callback.
  32588. */
  32589. breakLoop(): void;
  32590. /**
  32591. * Helper function
  32592. */
  32593. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  32594. /**
  32595. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32596. * @param iterations total number of iterations
  32597. * @param syncedIterations number of synchronous iterations in each async iteration.
  32598. * @param fn the function to call each iteration.
  32599. * @param callback a success call back that will be called when iterating stops.
  32600. * @param breakFunction a break condition (optional)
  32601. * @param timeout timeout settings for the setTimeout function. default - 0.
  32602. * @constructor
  32603. */
  32604. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  32605. }
  32606. }
  32607. interface HTMLCanvasElement {
  32608. /** Track wether a record is in progress */
  32609. isRecording: boolean;
  32610. /** Capture Stream method defined by some browsers */
  32611. captureStream(fps?: number): MediaStream;
  32612. }
  32613. interface MediaRecorder {
  32614. /** Starts recording */
  32615. start(timeSlice: number): void;
  32616. /** Stops recording */
  32617. stop(): void;
  32618. /** Event raised when an error arised. */
  32619. onerror: (event: ErrorEvent) => void;
  32620. /** Event raised when the recording stops. */
  32621. onstop: (event: Event) => void;
  32622. /** Event raised when a new chunk of data is available and should be tracked. */
  32623. ondataavailable: (event: Event) => void;
  32624. }
  32625. interface MediaRecorderOptions {
  32626. /** The mime type you want to use as the recording container for the new MediaRecorder */
  32627. mimeType?: string;
  32628. /** The chosen bitrate for the audio component of the media. */
  32629. audioBitsPerSecond?: number;
  32630. /** The chosen bitrate for the video component of the media. */
  32631. videoBitsPerSecond?: number;
  32632. /** 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. */
  32633. bitsPerSecond?: number;
  32634. }
  32635. interface MediaRecorderConstructor {
  32636. /**
  32637. * A reference to the prototype.
  32638. */
  32639. readonly prototype: MediaRecorder;
  32640. /**
  32641. * Creates a new MediaRecorder.
  32642. * @param stream Defines the stream to record.
  32643. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  32644. */
  32645. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  32646. }
  32647. /**
  32648. * MediaRecoreder object available in some browsers.
  32649. */
  32650. declare var MediaRecorder: MediaRecorderConstructor;
  32651. declare module BABYLON {
  32652. /**
  32653. * This represents the different options avilable for the video capture.
  32654. */
  32655. interface VideoRecorderOptions {
  32656. /** Defines the mime type of the video */
  32657. mimeType: string;
  32658. /** Defines the video the video should be recorded at */
  32659. fps: number;
  32660. /** Defines the chunk size for the recording data */
  32661. recordChunckSize: number;
  32662. }
  32663. /**
  32664. * This can helps recording videos from BabylonJS.
  32665. * This is based on the available WebRTC functionalities of the browser.
  32666. *
  32667. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  32668. */
  32669. class VideoRecorder {
  32670. private static readonly _defaultOptions;
  32671. /**
  32672. * Returns wehther or not the VideoRecorder is available in your browser.
  32673. * @param engine Defines the Babylon Engine to check the support for
  32674. * @returns true if supported otherwise false
  32675. */
  32676. static IsSupported(engine: Engine): boolean;
  32677. private readonly _options;
  32678. private _canvas;
  32679. private _mediaRecorder;
  32680. private _recordedChunks;
  32681. private _fileName;
  32682. private _resolve;
  32683. private _reject;
  32684. /**
  32685. * True wether a recording is already in progress.
  32686. */
  32687. readonly isRecording: boolean;
  32688. /**
  32689. * Create a new VideoCapture object which can help converting what you see in Babylon to
  32690. * a video file.
  32691. * @param engine Defines the BabylonJS Engine you wish to record
  32692. * @param options Defines options that can be used to customized the capture
  32693. */
  32694. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  32695. /**
  32696. * Stops the current recording before the default capture timeout passed in the startRecording
  32697. * functions.
  32698. */
  32699. stopRecording(): void;
  32700. /**
  32701. * Starts recording the canvas for a max duration specified in parameters.
  32702. * @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.
  32703. * @param maxDuration Defines the maximum recording time in seconds.
  32704. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  32705. * @return a promise callback at the end of the recording with the video data in Blob.
  32706. */
  32707. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  32708. /**
  32709. * Releases internal resources used during the recording.
  32710. */
  32711. dispose(): void;
  32712. private _handleDataAvailable;
  32713. private _handleError;
  32714. private _handleStop;
  32715. }
  32716. }
  32717. declare module BABYLON {
  32718. /**
  32719. * Defines the potential axis of a Joystick
  32720. */
  32721. enum JoystickAxis {
  32722. /** X axis */
  32723. X = 0,
  32724. /** Y axis */
  32725. Y = 1,
  32726. /** Z axis */
  32727. Z = 2
  32728. }
  32729. /**
  32730. * Class used to define virtual joystick (used in touch mode)
  32731. */
  32732. class VirtualJoystick {
  32733. /**
  32734. * Gets or sets a boolean indicating that left and right values must be inverted
  32735. */
  32736. reverseLeftRight: boolean;
  32737. /**
  32738. * Gets or sets a boolean indicating that up and down values must be inverted
  32739. */
  32740. reverseUpDown: boolean;
  32741. /**
  32742. * Gets the offset value for the position (ie. the change of the position value)
  32743. */
  32744. deltaPosition: Vector3;
  32745. /**
  32746. * Gets a boolean indicating if the virtual joystick was pressed
  32747. */
  32748. pressed: boolean;
  32749. private static _globalJoystickIndex;
  32750. private static vjCanvas;
  32751. private static vjCanvasContext;
  32752. private static vjCanvasWidth;
  32753. private static vjCanvasHeight;
  32754. private static halfWidth;
  32755. private _action;
  32756. private _axisTargetedByLeftAndRight;
  32757. private _axisTargetedByUpAndDown;
  32758. private _joystickSensibility;
  32759. private _inversedSensibility;
  32760. private _joystickPointerID;
  32761. private _joystickColor;
  32762. private _joystickPointerPos;
  32763. private _joystickPreviousPointerPos;
  32764. private _joystickPointerStartPos;
  32765. private _deltaJoystickVector;
  32766. private _leftJoystick;
  32767. private _touches;
  32768. private _onPointerDownHandlerRef;
  32769. private _onPointerMoveHandlerRef;
  32770. private _onPointerUpHandlerRef;
  32771. private _onResize;
  32772. /**
  32773. * Creates a new virtual joystick
  32774. * @param leftJoystick defines that the joystick is for left hand (false by default)
  32775. */
  32776. constructor(leftJoystick?: boolean);
  32777. /**
  32778. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  32779. * @param newJoystickSensibility defines the new sensibility
  32780. */
  32781. setJoystickSensibility(newJoystickSensibility: number): void;
  32782. private _onPointerDown;
  32783. private _onPointerMove;
  32784. private _onPointerUp;
  32785. /**
  32786. * Change the color of the virtual joystick
  32787. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  32788. */
  32789. setJoystickColor(newColor: string): void;
  32790. /**
  32791. * Defines a callback to call when the joystick is touched
  32792. * @param action defines the callback
  32793. */
  32794. setActionOnTouch(action: () => any): void;
  32795. /**
  32796. * Defines which axis you'd like to control for left & right
  32797. * @param axis defines the axis to use
  32798. */
  32799. setAxisForLeftRight(axis: JoystickAxis): void;
  32800. /**
  32801. * Defines which axis you'd like to control for up & down
  32802. * @param axis defines the axis to use
  32803. */
  32804. setAxisForUpDown(axis: JoystickAxis): void;
  32805. private _drawVirtualJoystick;
  32806. /**
  32807. * Release internal HTML canvas
  32808. */
  32809. releaseCanvas(): void;
  32810. }
  32811. }
  32812. declare module BABYLON {
  32813. /**
  32814. * Helper class to push actions to a pool of workers.
  32815. */
  32816. class WorkerPool implements IDisposable {
  32817. private _workerInfos;
  32818. private _pendingActions;
  32819. /**
  32820. * Constructor
  32821. * @param workers Array of workers to use for actions
  32822. */
  32823. constructor(workers: Array<Worker>);
  32824. /**
  32825. * Terminates all workers and clears any pending actions.
  32826. */
  32827. dispose(): void;
  32828. /**
  32829. * Pushes an action to the worker pool. If all the workers are active, the action will be
  32830. * pended until a worker has completed its action.
  32831. * @param action The action to perform. Call onComplete when the action is complete.
  32832. */
  32833. push(action: (worker: Worker, onComplete: () => void) => void): void;
  32834. private _execute;
  32835. }
  32836. }
  32837. declare module BABYLON {
  32838. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  32839. readonly name: string;
  32840. private _zoomStopsAnimation;
  32841. private _idleRotationSpeed;
  32842. private _idleRotationWaitTime;
  32843. private _idleRotationSpinupTime;
  32844. /**
  32845. * Sets the flag that indicates if user zooming should stop animation.
  32846. */
  32847. /**
  32848. * Gets the flag that indicates if user zooming should stop animation.
  32849. */
  32850. zoomStopsAnimation: boolean;
  32851. /**
  32852. * Sets the default speed at which the camera rotates around the model.
  32853. */
  32854. /**
  32855. * Gets the default speed at which the camera rotates around the model.
  32856. */
  32857. idleRotationSpeed: number;
  32858. /**
  32859. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  32860. */
  32861. /**
  32862. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  32863. */
  32864. idleRotationWaitTime: number;
  32865. /**
  32866. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  32867. */
  32868. /**
  32869. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  32870. */
  32871. idleRotationSpinupTime: number;
  32872. /**
  32873. * Gets a value indicating if the camera is currently rotating because of this behavior
  32874. */
  32875. readonly rotationInProgress: boolean;
  32876. private _onPrePointerObservableObserver;
  32877. private _onAfterCheckInputsObserver;
  32878. private _attachedCamera;
  32879. private _isPointerDown;
  32880. private _lastFrameTime;
  32881. private _lastInteractionTime;
  32882. private _cameraRotationSpeed;
  32883. init(): void;
  32884. attach(camera: ArcRotateCamera): void;
  32885. detach(): void;
  32886. /**
  32887. * Returns true if user is scrolling.
  32888. * @return true if user is scrolling.
  32889. */
  32890. private _userIsZooming;
  32891. private _lastFrameRadius;
  32892. private _shouldAnimationStopForInteraction;
  32893. /**
  32894. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  32895. */
  32896. private _applyUserInteraction;
  32897. private _userIsMoving;
  32898. }
  32899. }
  32900. declare module BABYLON {
  32901. /**
  32902. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  32903. */
  32904. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  32905. readonly name: string;
  32906. /**
  32907. * The easing function used by animations
  32908. */
  32909. static EasingFunction: BackEase;
  32910. /**
  32911. * The easing mode used by animations
  32912. */
  32913. static EasingMode: number;
  32914. /**
  32915. * The duration of the animation, in milliseconds
  32916. */
  32917. transitionDuration: number;
  32918. /**
  32919. * Length of the distance animated by the transition when lower radius is reached
  32920. */
  32921. lowerRadiusTransitionRange: number;
  32922. /**
  32923. * Length of the distance animated by the transition when upper radius is reached
  32924. */
  32925. upperRadiusTransitionRange: number;
  32926. private _autoTransitionRange;
  32927. /**
  32928. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  32929. */
  32930. /**
  32931. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  32932. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  32933. */
  32934. autoTransitionRange: boolean;
  32935. private _attachedCamera;
  32936. private _onAfterCheckInputsObserver;
  32937. private _onMeshTargetChangedObserver;
  32938. init(): void;
  32939. attach(camera: ArcRotateCamera): void;
  32940. detach(): void;
  32941. private _radiusIsAnimating;
  32942. private _radiusBounceTransition;
  32943. private _animatables;
  32944. private _cachedWheelPrecision;
  32945. /**
  32946. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  32947. * @param radiusLimit The limit to check against.
  32948. * @return Bool to indicate if at limit.
  32949. */
  32950. private _isRadiusAtLimit;
  32951. /**
  32952. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  32953. * @param radiusDelta The delta by which to animate to. Can be negative.
  32954. */
  32955. private _applyBoundRadiusAnimation;
  32956. /**
  32957. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  32958. */
  32959. protected _clearAnimationLocks(): void;
  32960. /**
  32961. * Stops and removes all animations that have been applied to the camera
  32962. */
  32963. stopAllAnimations(): void;
  32964. }
  32965. }
  32966. declare module BABYLON {
  32967. class FramingBehavior implements Behavior<ArcRotateCamera> {
  32968. readonly name: string;
  32969. private _mode;
  32970. private _radiusScale;
  32971. private _positionScale;
  32972. private _defaultElevation;
  32973. private _elevationReturnTime;
  32974. private _elevationReturnWaitTime;
  32975. private _zoomStopsAnimation;
  32976. private _framingTime;
  32977. /**
  32978. * The easing function used by animations
  32979. */
  32980. static EasingFunction: ExponentialEase;
  32981. /**
  32982. * The easing mode used by animations
  32983. */
  32984. static EasingMode: number;
  32985. /**
  32986. * Sets the current mode used by the behavior
  32987. */
  32988. /**
  32989. * Gets current mode used by the behavior.
  32990. */
  32991. mode: number;
  32992. /**
  32993. * Sets the scale applied to the radius (1 by default)
  32994. */
  32995. /**
  32996. * Gets the scale applied to the radius
  32997. */
  32998. radiusScale: number;
  32999. /**
  33000. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33001. */
  33002. /**
  33003. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33004. */
  33005. positionScale: number;
  33006. /**
  33007. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33008. * behaviour is triggered, in radians.
  33009. */
  33010. /**
  33011. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33012. * behaviour is triggered, in radians.
  33013. */
  33014. defaultElevation: number;
  33015. /**
  33016. * Sets the time (in milliseconds) taken to return to the default beta position.
  33017. * Negative value indicates camera should not return to default.
  33018. */
  33019. /**
  33020. * Gets the time (in milliseconds) taken to return to the default beta position.
  33021. * Negative value indicates camera should not return to default.
  33022. */
  33023. elevationReturnTime: number;
  33024. /**
  33025. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33026. */
  33027. /**
  33028. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33029. */
  33030. elevationReturnWaitTime: number;
  33031. /**
  33032. * Sets the flag that indicates if user zooming should stop animation.
  33033. */
  33034. /**
  33035. * Gets the flag that indicates if user zooming should stop animation.
  33036. */
  33037. zoomStopsAnimation: boolean;
  33038. /**
  33039. * Sets the transition time when framing the mesh, in milliseconds
  33040. */
  33041. /**
  33042. * Gets the transition time when framing the mesh, in milliseconds
  33043. */
  33044. framingTime: number;
  33045. private _onPrePointerObservableObserver;
  33046. private _onAfterCheckInputsObserver;
  33047. private _onMeshTargetChangedObserver;
  33048. private _attachedCamera;
  33049. private _isPointerDown;
  33050. private _lastInteractionTime;
  33051. init(): void;
  33052. attach(camera: ArcRotateCamera): void;
  33053. detach(): void;
  33054. private _animatables;
  33055. private _betaIsAnimating;
  33056. private _betaTransition;
  33057. private _radiusTransition;
  33058. private _vectorTransition;
  33059. /**
  33060. * Targets the given mesh and updates zoom level accordingly.
  33061. * @param mesh The mesh to target.
  33062. * @param radius Optional. If a cached radius position already exists, overrides default.
  33063. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33064. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33065. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33066. */
  33067. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33068. /**
  33069. * Targets the given mesh with its children and updates zoom level accordingly.
  33070. * @param mesh The mesh to target.
  33071. * @param radius Optional. If a cached radius position already exists, overrides default.
  33072. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33073. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33074. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33075. */
  33076. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33077. /**
  33078. * Targets the given meshes with their children and updates zoom level accordingly.
  33079. * @param meshes The mesh to target.
  33080. * @param radius Optional. If a cached radius position already exists, overrides default.
  33081. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33082. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33083. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33084. */
  33085. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33086. /**
  33087. * Targets the given mesh and updates zoom level accordingly.
  33088. * @param mesh The mesh to target.
  33089. * @param radius Optional. If a cached radius position already exists, overrides default.
  33090. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33091. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33092. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33093. */
  33094. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33095. /**
  33096. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  33097. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  33098. * frustum width.
  33099. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  33100. * to fully enclose the mesh in the viewing frustum.
  33101. */
  33102. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  33103. /**
  33104. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  33105. * is automatically returned to its default position (expected to be above ground plane).
  33106. */
  33107. private _maintainCameraAboveGround;
  33108. /**
  33109. * Returns the frustum slope based on the canvas ratio and camera FOV
  33110. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  33111. */
  33112. private _getFrustumSlope;
  33113. /**
  33114. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  33115. */
  33116. private _clearAnimationLocks;
  33117. /**
  33118. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  33119. */
  33120. private _applyUserInteraction;
  33121. /**
  33122. * Stops and removes all animations that have been applied to the camera
  33123. */
  33124. stopAllAnimations(): void;
  33125. /**
  33126. * Gets a value indicating if the user is moving the camera
  33127. */
  33128. readonly isUserIsMoving: boolean;
  33129. /**
  33130. * The camera can move all the way towards the mesh.
  33131. */
  33132. static IgnoreBoundsSizeMode: number;
  33133. /**
  33134. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  33135. */
  33136. static FitFrustumSidesMode: number;
  33137. }
  33138. }
  33139. declare module BABYLON {
  33140. /**
  33141. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  33142. */
  33143. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  33144. private ui;
  33145. /**
  33146. * The name of the behavior
  33147. */
  33148. name: string;
  33149. /**
  33150. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  33151. */
  33152. distanceAwayFromFace: number;
  33153. /**
  33154. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  33155. */
  33156. distanceAwayFromBottomOfFace: number;
  33157. private _faceVectors;
  33158. private _target;
  33159. private _scene;
  33160. private _onRenderObserver;
  33161. private _tmpMatrix;
  33162. private _tmpVector;
  33163. /**
  33164. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  33165. * @param ui The transform node that should be attched to the mesh
  33166. */
  33167. constructor(ui: BABYLON.TransformNode);
  33168. /**
  33169. * Initializes the behavior
  33170. */
  33171. init(): void;
  33172. private _closestFace;
  33173. private _zeroVector;
  33174. private _lookAtTmpMatrix;
  33175. private _lookAtToRef;
  33176. /**
  33177. * Attaches the AttachToBoxBehavior to the passed in mesh
  33178. * @param target The mesh that the specified node will be attached to
  33179. */
  33180. attach(target: BABYLON.Mesh): void;
  33181. /**
  33182. * Detaches the behavior from the mesh
  33183. */
  33184. detach(): void;
  33185. }
  33186. }
  33187. declare module BABYLON {
  33188. /**
  33189. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  33190. */
  33191. class FadeInOutBehavior implements Behavior<Mesh> {
  33192. /**
  33193. * Time in milliseconds to delay before fading in (Default: 0)
  33194. */
  33195. delay: number;
  33196. /**
  33197. * Time in milliseconds for the mesh to fade in (Default: 300)
  33198. */
  33199. fadeInTime: number;
  33200. private _millisecondsPerFrame;
  33201. private _hovered;
  33202. private _hoverValue;
  33203. private _ownerNode;
  33204. /**
  33205. * Instatiates the FadeInOutBehavior
  33206. */
  33207. constructor();
  33208. /**
  33209. * The name of the behavior
  33210. */
  33211. readonly name: string;
  33212. /**
  33213. * Initializes the behavior
  33214. */
  33215. init(): void;
  33216. /**
  33217. * Attaches the fade behavior on the passed in mesh
  33218. * @param ownerNode The mesh that will be faded in/out once attached
  33219. */
  33220. attach(ownerNode: Mesh): void;
  33221. /**
  33222. * Detaches the behavior from the mesh
  33223. */
  33224. detach(): void;
  33225. /**
  33226. * Triggers the mesh to begin fading in or out
  33227. * @param value if the object should fade in or out (true to fade in)
  33228. */
  33229. fadeIn(value: boolean): void;
  33230. private _update;
  33231. private _setAllVisibility;
  33232. }
  33233. }
  33234. declare module BABYLON {
  33235. /**
  33236. * A behavior that when attached to a mesh will allow the mesh to be scaled
  33237. */
  33238. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  33239. private _dragBehaviorA;
  33240. private _dragBehaviorB;
  33241. private _startDistance;
  33242. private _initialScale;
  33243. private _targetScale;
  33244. private _ownerNode;
  33245. private _sceneRenderObserver;
  33246. constructor();
  33247. /**
  33248. * The name of the behavior
  33249. */
  33250. readonly name: string;
  33251. /**
  33252. * Initializes the behavior
  33253. */
  33254. init(): void;
  33255. private _getCurrentDistance;
  33256. /**
  33257. * Attaches the scale behavior the passed in mesh
  33258. * @param ownerNode The mesh that will be scaled around once attached
  33259. */
  33260. attach(ownerNode: Mesh): void;
  33261. /**
  33262. * Detaches the behavior from the mesh
  33263. */
  33264. detach(): void;
  33265. }
  33266. }
  33267. declare module BABYLON {
  33268. /**
  33269. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  33270. */
  33271. class PointerDragBehavior implements Behavior<Mesh> {
  33272. private _attachedNode;
  33273. private _dragPlane;
  33274. private _scene;
  33275. private _pointerObserver;
  33276. private _beforeRenderObserver;
  33277. private static _planeScene;
  33278. /**
  33279. * 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)
  33280. */
  33281. maxDragAngle: number;
  33282. /**
  33283. * @hidden
  33284. */
  33285. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  33286. /**
  33287. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  33288. */
  33289. currentDraggingPointerID: number;
  33290. /**
  33291. * The last position where the pointer hit the drag plane in world space
  33292. */
  33293. lastDragPosition: Vector3;
  33294. /**
  33295. * If the behavior is currently in a dragging state
  33296. */
  33297. dragging: boolean;
  33298. /**
  33299. * 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)
  33300. */
  33301. dragDeltaRatio: number;
  33302. /**
  33303. * If the drag plane orientation should be updated during the dragging (Default: true)
  33304. */
  33305. updateDragPlane: boolean;
  33306. private _debugMode;
  33307. private _moving;
  33308. /**
  33309. * Fires each time the attached mesh is dragged with the pointer
  33310. * * delta between last drag position and current drag position in world space
  33311. * * dragDistance along the drag axis
  33312. * * dragPlaneNormal normal of the current drag plane used during the drag
  33313. * * dragPlanePoint in world space where the drag intersects the drag plane
  33314. */
  33315. onDragObservable: Observable<{
  33316. delta: Vector3;
  33317. dragPlanePoint: Vector3;
  33318. dragPlaneNormal: Vector3;
  33319. dragDistance: number;
  33320. pointerId: number;
  33321. }>;
  33322. /**
  33323. * Fires each time a drag begins (eg. mouse down on mesh)
  33324. */
  33325. onDragStartObservable: Observable<{
  33326. dragPlanePoint: Vector3;
  33327. pointerId: number;
  33328. }>;
  33329. /**
  33330. * Fires each time a drag ends (eg. mouse release after drag)
  33331. */
  33332. onDragEndObservable: Observable<{
  33333. dragPlanePoint: Vector3;
  33334. pointerId: number;
  33335. }>;
  33336. /**
  33337. * If the attached mesh should be moved when dragged
  33338. */
  33339. moveAttached: boolean;
  33340. /**
  33341. * If the drag behavior will react to drag events (Default: true)
  33342. */
  33343. enabled: boolean;
  33344. /**
  33345. * If camera controls should be detached during the drag
  33346. */
  33347. detachCameraControls: boolean;
  33348. /**
  33349. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  33350. */
  33351. useObjectOrienationForDragging: boolean;
  33352. private _options;
  33353. /**
  33354. * Creates a pointer drag behavior that can be attached to a mesh
  33355. * @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)
  33356. */
  33357. constructor(options?: {
  33358. dragAxis?: Vector3;
  33359. dragPlaneNormal?: Vector3;
  33360. });
  33361. /**
  33362. * The name of the behavior
  33363. */
  33364. readonly name: string;
  33365. /**
  33366. * Initializes the behavior
  33367. */
  33368. init(): void;
  33369. private _tmpVector;
  33370. private _alternatePickedPoint;
  33371. private _worldDragAxis;
  33372. private _targetPosition;
  33373. private _attachedElement;
  33374. /**
  33375. * Attaches the drag behavior the passed in mesh
  33376. * @param ownerNode The mesh that will be dragged around once attached
  33377. */
  33378. attach(ownerNode: Mesh): void;
  33379. releaseDrag(): void;
  33380. private _startDragRay;
  33381. private _lastPointerRay;
  33382. /**
  33383. * Simulates the start of a pointer drag event on the behavior
  33384. * @param pointerId pointerID of the pointer that should be simulated (Default: 1 for mouse pointer)
  33385. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  33386. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  33387. */
  33388. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  33389. private _startDrag;
  33390. private _dragDelta;
  33391. private _moveDrag;
  33392. private _pickWithRayOnDragPlane;
  33393. private _pointA;
  33394. private _pointB;
  33395. private _pointC;
  33396. private _lineA;
  33397. private _lineB;
  33398. private _localAxis;
  33399. private _lookAt;
  33400. private _updateDragPlanePosition;
  33401. /**
  33402. * Detaches the behavior from the mesh
  33403. */
  33404. detach(): void;
  33405. }
  33406. }
  33407. declare module BABYLON {
  33408. /**
  33409. * 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
  33410. */
  33411. class SixDofDragBehavior implements Behavior<Mesh> {
  33412. private static _virtualScene;
  33413. private _ownerNode;
  33414. private _sceneRenderObserver;
  33415. private _scene;
  33416. private _targetPosition;
  33417. private _virtualOriginMesh;
  33418. private _virtualDragMesh;
  33419. private _pointerObserver;
  33420. private _moving;
  33421. private _startingOrientation;
  33422. /**
  33423. * 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)
  33424. */
  33425. private zDragFactor;
  33426. /**
  33427. * If the behavior is currently in a dragging state
  33428. */
  33429. dragging: boolean;
  33430. /**
  33431. * 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)
  33432. */
  33433. dragDeltaRatio: number;
  33434. /**
  33435. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  33436. */
  33437. currentDraggingPointerID: number;
  33438. /**
  33439. * If camera controls should be detached during the drag
  33440. */
  33441. detachCameraControls: boolean;
  33442. constructor();
  33443. /**
  33444. * The name of the behavior
  33445. */
  33446. readonly name: string;
  33447. /**
  33448. * Initializes the behavior
  33449. */
  33450. init(): void;
  33451. /**
  33452. * Attaches the scale behavior the passed in mesh
  33453. * @param ownerNode The mesh that will be scaled around once attached
  33454. */
  33455. attach(ownerNode: Mesh): void;
  33456. /**
  33457. * Detaches the behavior from the mesh
  33458. */
  33459. detach(): void;
  33460. }
  33461. }
  33462. declare module BABYLON {
  33463. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  33464. camera: ArcRotateCamera;
  33465. gamepad: Nullable<Gamepad>;
  33466. private _onGamepadConnectedObserver;
  33467. private _onGamepadDisconnectedObserver;
  33468. gamepadRotationSensibility: number;
  33469. gamepadMoveSensibility: number;
  33470. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33471. detachControl(element: Nullable<HTMLElement>): void;
  33472. checkInputs(): void;
  33473. getClassName(): string;
  33474. getSimpleName(): string;
  33475. }
  33476. }
  33477. declare module BABYLON {
  33478. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  33479. camera: ArcRotateCamera;
  33480. private _keys;
  33481. keysUp: number[];
  33482. keysDown: number[];
  33483. keysLeft: number[];
  33484. keysRight: number[];
  33485. keysReset: number[];
  33486. panningSensibility: number;
  33487. zoomingSensibility: number;
  33488. useAltToZoom: boolean;
  33489. private _ctrlPressed;
  33490. private _altPressed;
  33491. private _onCanvasBlurObserver;
  33492. private _onKeyboardObserver;
  33493. private _engine;
  33494. private _scene;
  33495. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33496. detachControl(element: Nullable<HTMLElement>): void;
  33497. checkInputs(): void;
  33498. getClassName(): string;
  33499. getSimpleName(): string;
  33500. }
  33501. }
  33502. declare module BABYLON {
  33503. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  33504. camera: ArcRotateCamera;
  33505. private _wheel;
  33506. private _observer;
  33507. wheelPrecision: number;
  33508. /**
  33509. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  33510. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  33511. */
  33512. wheelDeltaPercentage: number;
  33513. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33514. detachControl(element: Nullable<HTMLElement>): void;
  33515. getClassName(): string;
  33516. getSimpleName(): string;
  33517. }
  33518. }
  33519. declare module BABYLON {
  33520. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  33521. camera: ArcRotateCamera;
  33522. buttons: number[];
  33523. angularSensibilityX: number;
  33524. angularSensibilityY: number;
  33525. pinchPrecision: number;
  33526. /**
  33527. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  33528. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  33529. */
  33530. pinchDeltaPercentage: number;
  33531. panningSensibility: number;
  33532. multiTouchPanning: boolean;
  33533. multiTouchPanAndZoom: boolean;
  33534. private _isPanClick;
  33535. pinchInwards: boolean;
  33536. private _pointerInput;
  33537. private _observer;
  33538. private _onMouseMove;
  33539. private _onGestureStart;
  33540. private _onGesture;
  33541. private _MSGestureHandler;
  33542. private _onLostFocus;
  33543. private _onContextMenu;
  33544. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33545. detachControl(element: Nullable<HTMLElement>): void;
  33546. getClassName(): string;
  33547. getSimpleName(): string;
  33548. }
  33549. }
  33550. declare module BABYLON {
  33551. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  33552. camera: ArcRotateCamera;
  33553. alphaCorrection: number;
  33554. betaCorrection: number;
  33555. gammaCorrection: number;
  33556. private _alpha;
  33557. private _gamma;
  33558. private _dirty;
  33559. private _deviceOrientationHandler;
  33560. constructor();
  33561. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33562. /** @hidden */
  33563. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  33564. checkInputs(): void;
  33565. detachControl(element: Nullable<HTMLElement>): void;
  33566. getClassName(): string;
  33567. getSimpleName(): string;
  33568. }
  33569. }
  33570. declare module BABYLON {
  33571. /**
  33572. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  33573. * Screen rotation is taken into account.
  33574. */
  33575. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  33576. private _camera;
  33577. private _screenOrientationAngle;
  33578. private _constantTranform;
  33579. private _screenQuaternion;
  33580. private _alpha;
  33581. private _beta;
  33582. private _gamma;
  33583. constructor();
  33584. camera: FreeCamera;
  33585. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33586. private _orientationChanged;
  33587. private _deviceOrientation;
  33588. detachControl(element: Nullable<HTMLElement>): void;
  33589. checkInputs(): void;
  33590. getClassName(): string;
  33591. getSimpleName(): string;
  33592. }
  33593. }
  33594. declare module BABYLON {
  33595. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  33596. camera: FreeCamera;
  33597. gamepad: Nullable<Gamepad>;
  33598. private _onGamepadConnectedObserver;
  33599. private _onGamepadDisconnectedObserver;
  33600. gamepadAngularSensibility: number;
  33601. gamepadMoveSensibility: number;
  33602. private _cameraTransform;
  33603. private _deltaTransform;
  33604. private _vector3;
  33605. private _vector2;
  33606. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33607. detachControl(element: Nullable<HTMLElement>): void;
  33608. checkInputs(): void;
  33609. getClassName(): string;
  33610. getSimpleName(): string;
  33611. }
  33612. }
  33613. declare module BABYLON {
  33614. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  33615. camera: FreeCamera;
  33616. private _keys;
  33617. private _onCanvasBlurObserver;
  33618. private _onKeyboardObserver;
  33619. private _engine;
  33620. private _scene;
  33621. keysUp: number[];
  33622. keysDown: number[];
  33623. keysLeft: number[];
  33624. keysRight: number[];
  33625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33626. detachControl(element: Nullable<HTMLElement>): void;
  33627. checkInputs(): void;
  33628. getClassName(): string;
  33629. /** @hidden */
  33630. _onLostFocus(e: FocusEvent): void;
  33631. getSimpleName(): string;
  33632. }
  33633. }
  33634. declare module BABYLON {
  33635. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  33636. touchEnabled: boolean;
  33637. camera: FreeCamera;
  33638. buttons: number[];
  33639. angularSensibility: number;
  33640. private _pointerInput;
  33641. private _onMouseMove;
  33642. private _observer;
  33643. private previousPosition;
  33644. constructor(touchEnabled?: boolean);
  33645. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33646. detachControl(element: Nullable<HTMLElement>): void;
  33647. getClassName(): string;
  33648. getSimpleName(): string;
  33649. }
  33650. }
  33651. declare module BABYLON {
  33652. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  33653. camera: FreeCamera;
  33654. private _offsetX;
  33655. private _offsetY;
  33656. private _pointerPressed;
  33657. private _pointerInput;
  33658. private _observer;
  33659. private _onLostFocus;
  33660. touchAngularSensibility: number;
  33661. touchMoveSensibility: number;
  33662. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33663. detachControl(element: Nullable<HTMLElement>): void;
  33664. checkInputs(): void;
  33665. getClassName(): string;
  33666. getSimpleName(): string;
  33667. }
  33668. }
  33669. declare module BABYLON {
  33670. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  33671. camera: FreeCamera;
  33672. private _leftjoystick;
  33673. private _rightjoystick;
  33674. getLeftJoystick(): VirtualJoystick;
  33675. getRightJoystick(): VirtualJoystick;
  33676. checkInputs(): void;
  33677. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33678. detachControl(element: Nullable<HTMLElement>): void;
  33679. getClassName(): string;
  33680. getSimpleName(): string;
  33681. }
  33682. }
  33683. declare module BABYLON {
  33684. /**
  33685. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  33686. */
  33687. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  33688. /**
  33689. * Creates a new AnaglyphArcRotateCamera
  33690. * @param name defines camera name
  33691. * @param alpha defines alpha angle (in radians)
  33692. * @param beta defines beta angle (in radians)
  33693. * @param radius defines radius
  33694. * @param target defines camera target
  33695. * @param interaxialDistance defines distance between each color axis
  33696. * @param scene defines the hosting scene
  33697. */
  33698. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  33699. /**
  33700. * Gets camera class name
  33701. * @returns AnaglyphArcRotateCamera
  33702. */
  33703. getClassName(): string;
  33704. }
  33705. }
  33706. declare module BABYLON {
  33707. /**
  33708. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  33709. */
  33710. class AnaglyphFreeCamera extends FreeCamera {
  33711. /**
  33712. * Creates a new AnaglyphFreeCamera
  33713. * @param name defines camera name
  33714. * @param position defines initial position
  33715. * @param interaxialDistance defines distance between each color axis
  33716. * @param scene defines the hosting scene
  33717. */
  33718. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  33719. /**
  33720. * Gets camera class name
  33721. * @returns AnaglyphFreeCamera
  33722. */
  33723. getClassName(): string;
  33724. }
  33725. }
  33726. declare module BABYLON {
  33727. /**
  33728. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  33729. */
  33730. class AnaglyphGamepadCamera extends GamepadCamera {
  33731. /**
  33732. * Creates a new AnaglyphGamepadCamera
  33733. * @param name defines camera name
  33734. * @param position defines initial position
  33735. * @param interaxialDistance defines distance between each color axis
  33736. * @param scene defines the hosting scene
  33737. */
  33738. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  33739. /**
  33740. * Gets camera class name
  33741. * @returns AnaglyphGamepadCamera
  33742. */
  33743. getClassName(): string;
  33744. }
  33745. }
  33746. declare module BABYLON {
  33747. /**
  33748. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  33749. */
  33750. class AnaglyphUniversalCamera extends UniversalCamera {
  33751. /**
  33752. * Creates a new AnaglyphUniversalCamera
  33753. * @param name defines camera name
  33754. * @param position defines initial position
  33755. * @param interaxialDistance defines distance between each color axis
  33756. * @param scene defines the hosting scene
  33757. */
  33758. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  33759. /**
  33760. * Gets camera class name
  33761. * @returns AnaglyphUniversalCamera
  33762. */
  33763. getClassName(): string;
  33764. }
  33765. }
  33766. declare module BABYLON {
  33767. /**
  33768. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  33769. */
  33770. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  33771. /**
  33772. * Creates a new StereoscopicArcRotateCamera
  33773. * @param name defines camera name
  33774. * @param alpha defines alpha angle (in radians)
  33775. * @param beta defines beta angle (in radians)
  33776. * @param radius defines radius
  33777. * @param target defines camera target
  33778. * @param interaxialDistance defines distance between each color axis
  33779. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33780. * @param scene defines the hosting scene
  33781. */
  33782. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33783. /**
  33784. * Gets camera class name
  33785. * @returns StereoscopicArcRotateCamera
  33786. */
  33787. getClassName(): string;
  33788. }
  33789. }
  33790. declare module BABYLON {
  33791. /**
  33792. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  33793. */
  33794. class StereoscopicFreeCamera extends FreeCamera {
  33795. /**
  33796. * Creates a new StereoscopicFreeCamera
  33797. * @param name defines camera name
  33798. * @param position defines initial position
  33799. * @param interaxialDistance defines distance between each color axis
  33800. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33801. * @param scene defines the hosting scene
  33802. */
  33803. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33804. /**
  33805. * Gets camera class name
  33806. * @returns StereoscopicFreeCamera
  33807. */
  33808. getClassName(): string;
  33809. }
  33810. }
  33811. declare module BABYLON {
  33812. /**
  33813. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  33814. */
  33815. class StereoscopicGamepadCamera extends GamepadCamera {
  33816. /**
  33817. * Creates a new StereoscopicGamepadCamera
  33818. * @param name defines camera name
  33819. * @param position defines initial position
  33820. * @param interaxialDistance defines distance between each color axis
  33821. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33822. * @param scene defines the hosting scene
  33823. */
  33824. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33825. /**
  33826. * Gets camera class name
  33827. * @returns StereoscopicGamepadCamera
  33828. */
  33829. getClassName(): string;
  33830. }
  33831. }
  33832. declare module BABYLON {
  33833. /**
  33834. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  33835. */
  33836. class StereoscopicUniversalCamera extends UniversalCamera {
  33837. /**
  33838. * Creates a new StereoscopicUniversalCamera
  33839. * @param name defines camera name
  33840. * @param position defines initial position
  33841. * @param interaxialDistance defines distance between each color axis
  33842. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  33843. * @param scene defines the hosting scene
  33844. */
  33845. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  33846. /**
  33847. * Gets camera class name
  33848. * @returns StereoscopicUniversalCamera
  33849. */
  33850. getClassName(): string;
  33851. }
  33852. }
  33853. declare module BABYLON {
  33854. class VRCameraMetrics {
  33855. hResolution: number;
  33856. vResolution: number;
  33857. hScreenSize: number;
  33858. vScreenSize: number;
  33859. vScreenCenter: number;
  33860. eyeToScreenDistance: number;
  33861. lensSeparationDistance: number;
  33862. interpupillaryDistance: number;
  33863. distortionK: number[];
  33864. chromaAbCorrection: number[];
  33865. postProcessScaleFactor: number;
  33866. lensCenterOffset: number;
  33867. compensateDistortion: boolean;
  33868. readonly aspectRatio: number;
  33869. readonly aspectRatioFov: number;
  33870. readonly leftHMatrix: Matrix;
  33871. readonly rightHMatrix: Matrix;
  33872. readonly leftPreViewMatrix: Matrix;
  33873. readonly rightPreViewMatrix: Matrix;
  33874. static GetDefault(): VRCameraMetrics;
  33875. }
  33876. }
  33877. declare module BABYLON {
  33878. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  33879. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  33880. getClassName(): string;
  33881. }
  33882. }
  33883. declare module BABYLON {
  33884. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  33885. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  33886. getClassName(): string;
  33887. }
  33888. }
  33889. declare module BABYLON {
  33890. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  33891. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  33892. getClassName(): string;
  33893. }
  33894. }
  33895. declare module BABYLON {
  33896. /**
  33897. * Options to modify the vr teleportation behavior.
  33898. */
  33899. interface VRTeleportationOptions {
  33900. /**
  33901. * The name of the mesh which should be used as the teleportation floor. (default: null)
  33902. */
  33903. floorMeshName?: string;
  33904. /**
  33905. * A list of meshes to be used as the teleportation floor. (default: empty)
  33906. */
  33907. floorMeshes?: Mesh[];
  33908. }
  33909. /**
  33910. * Options to modify the vr experience helper's behavior.
  33911. */
  33912. interface VRExperienceHelperOptions extends WebVROptions {
  33913. /**
  33914. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  33915. */
  33916. createDeviceOrientationCamera?: boolean;
  33917. /**
  33918. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  33919. */
  33920. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  33921. /**
  33922. * Uses the main button on the controller to toggle the laser casted. (default: true)
  33923. */
  33924. laserToggle?: boolean;
  33925. /**
  33926. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  33927. */
  33928. floorMeshes?: Mesh[];
  33929. }
  33930. /**
  33931. * Helps to quickly add VR support to an existing scene.
  33932. * See http://doc.babylonjs.com/how_to/webvr_helper
  33933. */
  33934. class VRExperienceHelper {
  33935. /** Options to modify the vr experience helper's behavior. */
  33936. webVROptions: VRExperienceHelperOptions;
  33937. private _scene;
  33938. private _position;
  33939. private _btnVR;
  33940. private _btnVRDisplayed;
  33941. private _webVRsupported;
  33942. private _webVRready;
  33943. private _webVRrequesting;
  33944. private _webVRpresenting;
  33945. private _hasEnteredVR;
  33946. private _fullscreenVRpresenting;
  33947. private _canvas;
  33948. private _webVRCamera;
  33949. private _vrDeviceOrientationCamera;
  33950. private _deviceOrientationCamera;
  33951. private _existingCamera;
  33952. private _onKeyDown;
  33953. private _onVrDisplayPresentChange;
  33954. private _onVRDisplayChanged;
  33955. private _onVRRequestPresentStart;
  33956. private _onVRRequestPresentComplete;
  33957. /**
  33958. * Observable raised when entering VR.
  33959. */
  33960. onEnteringVRObservable: Observable<VRExperienceHelper>;
  33961. /**
  33962. * Observable raised when exiting VR.
  33963. */
  33964. onExitingVRObservable: Observable<VRExperienceHelper>;
  33965. /**
  33966. * Observable raised when controller mesh is loaded.
  33967. */
  33968. onControllerMeshLoadedObservable: Observable<WebVRController>;
  33969. /** Return this.onEnteringVRObservable
  33970. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  33971. */
  33972. readonly onEnteringVR: Observable<VRExperienceHelper>;
  33973. /** Return this.onExitingVRObservable
  33974. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  33975. */
  33976. readonly onExitingVR: Observable<VRExperienceHelper>;
  33977. /** Return this.onControllerMeshLoadedObservable
  33978. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  33979. */
  33980. readonly onControllerMeshLoaded: Observable<WebVRController>;
  33981. private _rayLength;
  33982. private _useCustomVRButton;
  33983. private _teleportationRequested;
  33984. private _teleportActive;
  33985. private _floorMeshName;
  33986. private _floorMeshesCollection;
  33987. private _rotationAllowed;
  33988. private _teleportBackwardsVector;
  33989. private _teleportationTarget;
  33990. private _isDefaultTeleportationTarget;
  33991. private _postProcessMove;
  33992. private _teleportationFillColor;
  33993. private _teleportationBorderColor;
  33994. private _rotationAngle;
  33995. private _haloCenter;
  33996. private _cameraGazer;
  33997. private _padSensibilityUp;
  33998. private _padSensibilityDown;
  33999. private _leftController;
  34000. private _rightController;
  34001. /**
  34002. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  34003. */
  34004. onNewMeshSelected: Observable<AbstractMesh>;
  34005. /**
  34006. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  34007. */
  34008. onNewMeshPicked: Observable<PickingInfo>;
  34009. private _circleEase;
  34010. /**
  34011. * Observable raised before camera teleportation
  34012. */
  34013. onBeforeCameraTeleport: Observable<Vector3>;
  34014. /**
  34015. * Observable raised after camera teleportation
  34016. */
  34017. onAfterCameraTeleport: Observable<Vector3>;
  34018. /**
  34019. * Observable raised when current selected mesh gets unselected
  34020. */
  34021. onSelectedMeshUnselected: Observable<AbstractMesh>;
  34022. private _raySelectionPredicate;
  34023. /**
  34024. * To be optionaly changed by user to define custom ray selection
  34025. */
  34026. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  34027. /**
  34028. * To be optionaly changed by user to define custom selection logic (after ray selection)
  34029. */
  34030. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  34031. /**
  34032. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  34033. */
  34034. teleportationEnabled: boolean;
  34035. private _defaultHeight;
  34036. private _teleportationInitialized;
  34037. private _interactionsEnabled;
  34038. private _interactionsRequested;
  34039. private _displayGaze;
  34040. private _displayLaserPointer;
  34041. /**
  34042. * The mesh used to display where the user is going to teleport.
  34043. */
  34044. /**
  34045. * Sets the mesh to be used to display where the user is going to teleport.
  34046. */
  34047. teleportationTarget: Mesh;
  34048. /**
  34049. * The mesh used to display where the user is selecting, this mesh will be cloned and set as the gazeTracker for the left and right controller
  34050. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  34051. * See http://doc.babylonjs.com/resources/baking_transformations
  34052. */
  34053. gazeTrackerMesh: Mesh;
  34054. /**
  34055. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  34056. */
  34057. updateGazeTrackerScale: boolean;
  34058. /**
  34059. * The gaze tracking mesh corresponding to the left controller
  34060. */
  34061. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  34062. /**
  34063. * The gaze tracking mesh corresponding to the right controller
  34064. */
  34065. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  34066. /**
  34067. * If the ray of the gaze should be displayed.
  34068. */
  34069. /**
  34070. * Sets if the ray of the gaze should be displayed.
  34071. */
  34072. displayGaze: boolean;
  34073. /**
  34074. * If the ray of the LaserPointer should be displayed.
  34075. */
  34076. /**
  34077. * Sets if the ray of the LaserPointer should be displayed.
  34078. */
  34079. displayLaserPointer: boolean;
  34080. /**
  34081. * The deviceOrientationCamera used as the camera when not in VR.
  34082. */
  34083. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  34084. /**
  34085. * Based on the current WebVR support, returns the current VR camera used.
  34086. */
  34087. readonly currentVRCamera: Nullable<Camera>;
  34088. /**
  34089. * The webVRCamera which is used when in VR.
  34090. */
  34091. readonly webVRCamera: WebVRFreeCamera;
  34092. /**
  34093. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  34094. */
  34095. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  34096. private readonly _teleportationRequestInitiated;
  34097. /**
  34098. * Instantiates a VRExperienceHelper.
  34099. * Helps to quickly add VR support to an existing scene.
  34100. * @param scene The scene the VRExperienceHelper belongs to.
  34101. * @param webVROptions Options to modify the vr experience helper's behavior.
  34102. */
  34103. constructor(scene: Scene,
  34104. /** Options to modify the vr experience helper's behavior. */
  34105. webVROptions?: VRExperienceHelperOptions);
  34106. private _onDefaultMeshLoaded;
  34107. private _onResize;
  34108. private _onFullscreenChange;
  34109. /**
  34110. * Gets a value indicating if we are currently in VR mode.
  34111. */
  34112. readonly isInVRMode: boolean;
  34113. private onVrDisplayPresentChange;
  34114. private onVRDisplayChanged;
  34115. private moveButtonToBottomRight;
  34116. private displayVRButton;
  34117. private updateButtonVisibility;
  34118. /**
  34119. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  34120. * Otherwise, will use the fullscreen API.
  34121. */
  34122. enterVR(): void;
  34123. /**
  34124. * Attempt to exit VR, or fullscreen.
  34125. */
  34126. exitVR(): void;
  34127. /**
  34128. * The position of the vr experience helper.
  34129. */
  34130. /**
  34131. * Sets the position of the vr experience helper.
  34132. */
  34133. position: Vector3;
  34134. /**
  34135. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  34136. */
  34137. enableInteractions(): void;
  34138. private readonly _noControllerIsActive;
  34139. private beforeRender;
  34140. private _isTeleportationFloor;
  34141. /**
  34142. * Adds a floor mesh to be used for teleportation.
  34143. * @param floorMesh the mesh to be used for teleportation.
  34144. */
  34145. addFloorMesh(floorMesh: Mesh): void;
  34146. /**
  34147. * Removes a floor mesh from being used for teleportation.
  34148. * @param floorMesh the mesh to be removed.
  34149. */
  34150. removeFloorMesh(floorMesh: Mesh): void;
  34151. /**
  34152. * Enables interactions and teleportation using the VR controllers and gaze.
  34153. * @param vrTeleportationOptions options to modify teleportation behavior.
  34154. */
  34155. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  34156. private _onNewGamepadConnected;
  34157. private _tryEnableInteractionOnController;
  34158. private _onNewGamepadDisconnected;
  34159. private _enableInteractionOnController;
  34160. private _checkTeleportWithRay;
  34161. private _checkRotate;
  34162. private _checkTeleportBackwards;
  34163. private _enableTeleportationOnController;
  34164. private _createTeleportationCircles;
  34165. private _displayTeleportationTarget;
  34166. private _hideTeleportationTarget;
  34167. private _rotateCamera;
  34168. private _moveTeleportationSelectorTo;
  34169. private _workingVector;
  34170. private _workingQuaternion;
  34171. private _workingMatrix;
  34172. /**
  34173. * Teleports the users feet to the desired location
  34174. * @param location The location where the user's feet should be placed
  34175. */
  34176. teleportCamera(location: Vector3): void;
  34177. private _convertNormalToDirectionOfRay;
  34178. private _castRayAndSelectObject;
  34179. private _notifySelectedMeshUnselected;
  34180. /**
  34181. * Sets the color of the laser ray from the vr controllers.
  34182. * @param color new color for the ray.
  34183. */
  34184. changeLaserColor(color: Color3): void;
  34185. /**
  34186. * Sets the color of the ray from the vr headsets gaze.
  34187. * @param color new color for the ray.
  34188. */
  34189. changeGazeColor(color: Color3): void;
  34190. /**
  34191. * Exits VR and disposes of the vr experience helper
  34192. */
  34193. dispose(): void;
  34194. /**
  34195. * Gets the name of the VRExperienceHelper class
  34196. * @returns "VRExperienceHelper"
  34197. */
  34198. getClassName(): string;
  34199. }
  34200. }
  34201. declare module BABYLON {
  34202. /**
  34203. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  34204. * IMPORTANT!! The data is right-hand data.
  34205. * @export
  34206. * @interface DevicePose
  34207. */
  34208. interface DevicePose {
  34209. /**
  34210. * The position of the device, values in array are [x,y,z].
  34211. */
  34212. readonly position: Nullable<Float32Array>;
  34213. /**
  34214. * The linearVelocity of the device, values in array are [x,y,z].
  34215. */
  34216. readonly linearVelocity: Nullable<Float32Array>;
  34217. /**
  34218. * The linearAcceleration of the device, values in array are [x,y,z].
  34219. */
  34220. readonly linearAcceleration: Nullable<Float32Array>;
  34221. /**
  34222. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  34223. */
  34224. readonly orientation: Nullable<Float32Array>;
  34225. /**
  34226. * The angularVelocity of the device, values in array are [x,y,z].
  34227. */
  34228. readonly angularVelocity: Nullable<Float32Array>;
  34229. /**
  34230. * The angularAcceleration of the device, values in array are [x,y,z].
  34231. */
  34232. readonly angularAcceleration: Nullable<Float32Array>;
  34233. }
  34234. /**
  34235. * Interface representing a pose controlled object in Babylon.
  34236. * A pose controlled object has both regular pose values as well as pose values
  34237. * from an external device such as a VR head mounted display
  34238. */
  34239. interface PoseControlled {
  34240. /**
  34241. * The position of the object in babylon space.
  34242. */
  34243. position: Vector3;
  34244. /**
  34245. * The rotation quaternion of the object in babylon space.
  34246. */
  34247. rotationQuaternion: Quaternion;
  34248. /**
  34249. * The position of the device in babylon space.
  34250. */
  34251. devicePosition?: Vector3;
  34252. /**
  34253. * The rotation quaternion of the device in babylon space.
  34254. */
  34255. deviceRotationQuaternion: Quaternion;
  34256. /**
  34257. * The raw pose coming from the device.
  34258. */
  34259. rawPose: Nullable<DevicePose>;
  34260. /**
  34261. * The scale of the device to be used when translating from device space to babylon space.
  34262. */
  34263. deviceScaleFactor: number;
  34264. /**
  34265. * Updates the poseControlled values based on the input device pose.
  34266. * @param poseData the pose data to update the object with
  34267. */
  34268. updateFromDevice(poseData: DevicePose): void;
  34269. }
  34270. /**
  34271. * Set of options to customize the webVRCamera
  34272. */
  34273. interface WebVROptions {
  34274. /**
  34275. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  34276. */
  34277. trackPosition?: boolean;
  34278. /**
  34279. * Sets the scale of the vrDevice in babylon space. (default: 1)
  34280. */
  34281. positionScale?: number;
  34282. /**
  34283. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  34284. */
  34285. displayName?: string;
  34286. /**
  34287. * Should the native controller meshes be initialized. (default: true)
  34288. */
  34289. controllerMeshes?: boolean;
  34290. /**
  34291. * Creating a default HemiLight only on controllers. (default: true)
  34292. */
  34293. defaultLightingOnControllers?: boolean;
  34294. /**
  34295. * If you don't want to use the default VR button of the helper. (default: false)
  34296. */
  34297. useCustomVRButton?: boolean;
  34298. /**
  34299. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  34300. */
  34301. customVRButton?: HTMLButtonElement;
  34302. /**
  34303. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  34304. */
  34305. rayLength?: number;
  34306. /**
  34307. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  34308. */
  34309. defaultHeight?: number;
  34310. }
  34311. /**
  34312. * This represents a WebVR camera.
  34313. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  34314. * @example http://doc.babylonjs.com/how_to/webvr_camera
  34315. */
  34316. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  34317. private webVROptions;
  34318. /**
  34319. * @hidden
  34320. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  34321. */
  34322. _vrDevice: any;
  34323. /**
  34324. * The rawPose of the vrDevice.
  34325. */
  34326. rawPose: Nullable<DevicePose>;
  34327. private _onVREnabled;
  34328. private _specsVersion;
  34329. private _attached;
  34330. private _frameData;
  34331. protected _descendants: Array<Node>;
  34332. private _deviceRoomPosition;
  34333. /** @hidden */
  34334. _deviceRoomRotationQuaternion: Quaternion;
  34335. private _standingMatrix;
  34336. /**
  34337. * Represents device position in babylon space.
  34338. */
  34339. devicePosition: Vector3;
  34340. /**
  34341. * Represents device rotation in babylon space.
  34342. */
  34343. deviceRotationQuaternion: Quaternion;
  34344. /**
  34345. * The scale of the device to be used when translating from device space to babylon space.
  34346. */
  34347. deviceScaleFactor: number;
  34348. private _deviceToWorld;
  34349. private _worldToDevice;
  34350. /**
  34351. * References to the webVR controllers for the vrDevice.
  34352. */
  34353. controllers: Array<WebVRController>;
  34354. /**
  34355. * Emits an event when a controller is attached.
  34356. */
  34357. onControllersAttachedObservable: Observable<WebVRController[]>;
  34358. /**
  34359. * Emits an event when a controller's mesh has been loaded;
  34360. */
  34361. onControllerMeshLoadedObservable: Observable<WebVRController>;
  34362. /**
  34363. * Emits an event when the HMD's pose has been updated.
  34364. */
  34365. onPoseUpdatedFromDeviceObservable: Observable<any>;
  34366. private _poseSet;
  34367. /**
  34368. * If the rig cameras be used as parent instead of this camera.
  34369. */
  34370. rigParenting: boolean;
  34371. private _lightOnControllers;
  34372. private _defaultHeight?;
  34373. /**
  34374. * Instantiates a WebVRFreeCamera.
  34375. * @param name The name of the WebVRFreeCamera
  34376. * @param position The starting anchor position for the camera
  34377. * @param scene The scene the camera belongs to
  34378. * @param webVROptions a set of customizable options for the webVRCamera
  34379. */
  34380. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  34381. /**
  34382. * Gets the device distance from the ground in meters.
  34383. * @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.
  34384. */
  34385. deviceDistanceToRoomGround(): number;
  34386. /**
  34387. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  34388. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  34389. */
  34390. useStandingMatrix(callback?: (bool: boolean) => void): void;
  34391. /**
  34392. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  34393. * @returns A promise with a boolean set to if the standing matrix is supported.
  34394. */
  34395. useStandingMatrixAsync(): Promise<boolean>;
  34396. /**
  34397. * Disposes the camera
  34398. */
  34399. dispose(): void;
  34400. /**
  34401. * Gets a vrController by name.
  34402. * @param name The name of the controller to retreive
  34403. * @returns the controller matching the name specified or null if not found
  34404. */
  34405. getControllerByName(name: string): Nullable<WebVRController>;
  34406. private _leftController;
  34407. /**
  34408. * The controller corrisponding to the users left hand.
  34409. */
  34410. readonly leftController: Nullable<WebVRController>;
  34411. private _rightController;
  34412. /**
  34413. * The controller corrisponding to the users right hand.
  34414. */
  34415. readonly rightController: Nullable<WebVRController>;
  34416. /**
  34417. * Casts a ray forward from the vrCamera's gaze.
  34418. * @param length Length of the ray (default: 100)
  34419. * @returns the ray corrisponding to the gaze
  34420. */
  34421. getForwardRay(length?: number): Ray;
  34422. /**
  34423. * @hidden
  34424. * Updates the camera based on device's frame data
  34425. */
  34426. _checkInputs(): void;
  34427. /**
  34428. * Updates the poseControlled values based on the input device pose.
  34429. * @param poseData Pose coming from the device
  34430. */
  34431. updateFromDevice(poseData: DevicePose): void;
  34432. private _htmlElementAttached;
  34433. private _detachIfAttached;
  34434. /**
  34435. * WebVR's attach control will start broadcasting frames to the device.
  34436. * Note that in certain browsers (chrome for example) this function must be called
  34437. * within a user-interaction callback. Example:
  34438. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  34439. *
  34440. * @param element html element to attach the vrDevice to
  34441. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  34442. */
  34443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34444. /**
  34445. * Detaches the camera from the html element and disables VR
  34446. *
  34447. * @param element html element to detach from
  34448. */
  34449. detachControl(element: HTMLElement): void;
  34450. /**
  34451. * @returns the name of this class
  34452. */
  34453. getClassName(): string;
  34454. /**
  34455. * Calls resetPose on the vrDisplay
  34456. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  34457. */
  34458. resetToCurrentRotation(): void;
  34459. /**
  34460. * @hidden
  34461. * Updates the rig cameras (left and right eye)
  34462. */
  34463. _updateRigCameras(): void;
  34464. private _workingVector;
  34465. private _oneVector;
  34466. private _workingMatrix;
  34467. private updateCacheCalled;
  34468. private _correctPositionIfNotTrackPosition;
  34469. /**
  34470. * @hidden
  34471. * Updates the cached values of the camera
  34472. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  34473. */
  34474. _updateCache(ignoreParentClass?: boolean): void;
  34475. /**
  34476. * Updates the current device position and rotation in the babylon world
  34477. */
  34478. update(): void;
  34479. /**
  34480. * @hidden
  34481. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  34482. * @returns an identity matrix
  34483. */
  34484. _getViewMatrix(): Matrix;
  34485. private _tmpMatrix;
  34486. /**
  34487. * This function is called by the two RIG cameras.
  34488. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  34489. */
  34490. protected _getWebVRViewMatrix(): Matrix;
  34491. protected _getWebVRProjectionMatrix(): Matrix;
  34492. private _onGamepadConnectedObserver;
  34493. private _onGamepadDisconnectedObserver;
  34494. /**
  34495. * Initializes the controllers and their meshes
  34496. */
  34497. initControllers(): void;
  34498. }
  34499. }
  34500. declare module BABYLON {
  34501. interface IOctreeContainer<T> {
  34502. blocks: Array<OctreeBlock<T>>;
  34503. }
  34504. class Octree<T> {
  34505. maxDepth: number;
  34506. blocks: Array<OctreeBlock<T>>;
  34507. dynamicContent: T[];
  34508. private _maxBlockCapacity;
  34509. private _selectionContent;
  34510. private _creationFunc;
  34511. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  34512. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  34513. addMesh(entry: T): void;
  34514. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  34515. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  34516. intersectsRay(ray: Ray): SmartArray<T>;
  34517. 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;
  34518. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  34519. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  34520. }
  34521. }
  34522. declare module BABYLON {
  34523. class OctreeBlock<T> {
  34524. entries: T[];
  34525. blocks: Array<OctreeBlock<T>>;
  34526. private _depth;
  34527. private _maxDepth;
  34528. private _capacity;
  34529. private _minPoint;
  34530. private _maxPoint;
  34531. private _boundingVectors;
  34532. private _creationFunc;
  34533. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  34534. readonly capacity: number;
  34535. readonly minPoint: Vector3;
  34536. readonly maxPoint: Vector3;
  34537. addEntry(entry: T): void;
  34538. addEntries(entries: T[]): void;
  34539. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  34540. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  34541. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  34542. createInnerBlocks(): void;
  34543. }
  34544. }
  34545. declare module BABYLON {
  34546. interface Scene {
  34547. /**
  34548. * @hidden
  34549. * Backing Filed
  34550. */
  34551. _selectionOctree: Octree<AbstractMesh>;
  34552. /**
  34553. * Gets the octree used to boost mesh selection (picking)
  34554. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  34555. */
  34556. selectionOctree: Octree<AbstractMesh>;
  34557. /**
  34558. * Creates or updates the octree used to boost selection (picking)
  34559. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  34560. * @param maxCapacity defines the maximum capacity per leaf
  34561. * @param maxDepth defines the maximum depth of the octree
  34562. * @returns an octree of AbstractMesh
  34563. */
  34564. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  34565. }
  34566. interface AbstractMesh {
  34567. /**
  34568. * @hidden
  34569. * Backing Field
  34570. */
  34571. _submeshesOctree: Octree<SubMesh>;
  34572. /**
  34573. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  34574. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  34575. * @param maxCapacity defines the maximum size of each block (64 by default)
  34576. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  34577. * @returns the new octree
  34578. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  34579. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  34580. */
  34581. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  34582. }
  34583. /**
  34584. * Defines the octree scene component responsible to manage any octrees
  34585. * in a given scene.
  34586. */
  34587. class OctreeSceneComponent {
  34588. /**
  34589. * The component name helpfull to identify the component in the list of scene components.
  34590. */
  34591. readonly name: string;
  34592. /**
  34593. * The scene the component belongs to.
  34594. */
  34595. scene: Scene;
  34596. /**
  34597. * Indicates if the meshes have been checked to make sure they are isEnabled()
  34598. */
  34599. readonly checksIsEnabled: boolean;
  34600. /**
  34601. * Creates a new instance of the component for the given scene
  34602. * @param scene Defines the scene to register the component in
  34603. */
  34604. constructor(scene: Scene);
  34605. /**
  34606. * Registers the component in a given scene
  34607. */
  34608. register(): void;
  34609. /**
  34610. * Return the list of active meshes
  34611. * @returns the list of active meshes
  34612. */
  34613. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34614. /**
  34615. * Return the list of active sub meshes
  34616. * @param mesh The mesh to get the candidates sub meshes from
  34617. * @returns the list of active sub meshes
  34618. */
  34619. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34620. private _tempRay;
  34621. /**
  34622. * Return the list of sub meshes intersecting with a given local ray
  34623. * @param mesh defines the mesh to find the submesh for
  34624. * @param localRay defines the ray in local space
  34625. * @returns the list of intersecting sub meshes
  34626. */
  34627. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  34628. /**
  34629. * Return the list of sub meshes colliding with a collider
  34630. * @param mesh defines the mesh to find the submesh for
  34631. * @param collider defines the collider to evaluate the collision against
  34632. * @returns the list of colliding sub meshes
  34633. */
  34634. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  34635. /**
  34636. * Rebuilds the elements related to this component in case of
  34637. * context lost for instance.
  34638. */
  34639. rebuild(): void;
  34640. /**
  34641. * Disposes the component and the associated ressources.
  34642. */
  34643. dispose(): void;
  34644. }
  34645. }
  34646. declare module BABYLON {
  34647. interface Engine {
  34648. /**
  34649. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  34650. * @return the new query
  34651. */
  34652. createQuery(): WebGLQuery;
  34653. /**
  34654. * Delete and release a webGL query
  34655. * @param query defines the query to delete
  34656. * @return the current engine
  34657. */
  34658. deleteQuery(query: WebGLQuery): Engine;
  34659. /**
  34660. * Check if a given query has resolved and got its value
  34661. * @param query defines the query to check
  34662. * @returns true if the query got its value
  34663. */
  34664. isQueryResultAvailable(query: WebGLQuery): boolean;
  34665. /**
  34666. * Gets the value of a given query
  34667. * @param query defines the query to check
  34668. * @returns the value of the query
  34669. */
  34670. getQueryResult(query: WebGLQuery): number;
  34671. /**
  34672. * Initiates an occlusion query
  34673. * @param algorithmType defines the algorithm to use
  34674. * @param query defines the query to use
  34675. * @returns the current engine
  34676. * @see http://doc.babylonjs.com/features/occlusionquery
  34677. */
  34678. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  34679. /**
  34680. * Ends an occlusion query
  34681. * @see http://doc.babylonjs.com/features/occlusionquery
  34682. * @param algorithmType defines the algorithm to use
  34683. * @returns the current engine
  34684. */
  34685. endOcclusionQuery(algorithmType: number): Engine;
  34686. /**
  34687. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  34688. * Please note that only one query can be issued at a time
  34689. * @returns a time token used to track the time span
  34690. */
  34691. startTimeQuery(): Nullable<_TimeToken>;
  34692. /**
  34693. * Ends a time query
  34694. * @param token defines the token used to measure the time span
  34695. * @returns the time spent (in ns)
  34696. */
  34697. endTimeQuery(token: _TimeToken): int;
  34698. /** @hidden */
  34699. _currentNonTimestampToken: Nullable<_TimeToken>;
  34700. /** @hidden */
  34701. _createTimeQuery(): WebGLQuery;
  34702. /** @hidden */
  34703. _deleteTimeQuery(query: WebGLQuery): void;
  34704. /** @hidden */
  34705. _getGlAlgorithmType(algorithmType: number): number;
  34706. /** @hidden */
  34707. _getTimeQueryResult(query: WebGLQuery): any;
  34708. /** @hidden */
  34709. _getTimeQueryAvailability(query: WebGLQuery): any;
  34710. }
  34711. }
  34712. declare module BABYLON {
  34713. interface Engine {
  34714. /**
  34715. * Creates a webGL transform feedback object
  34716. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  34717. * @returns the webGL transform feedback object
  34718. */
  34719. createTransformFeedback(): WebGLTransformFeedback;
  34720. /**
  34721. * Delete a webGL transform feedback object
  34722. * @param value defines the webGL transform feedback object to delete
  34723. */
  34724. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  34725. /**
  34726. * Bind a webGL transform feedback object to the webgl context
  34727. * @param value defines the webGL transform feedback object to bind
  34728. */
  34729. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  34730. /**
  34731. * Begins a transform feedback operation
  34732. * @param usePoints defines if points or triangles must be used
  34733. */
  34734. beginTransformFeedback(usePoints: boolean): void;
  34735. /**
  34736. * Ends a transform feedback operation
  34737. */
  34738. endTransformFeedback(): void;
  34739. /**
  34740. * Specify the varyings to use with transform feedback
  34741. * @param program defines the associated webGL program
  34742. * @param value defines the list of strings representing the varying names
  34743. */
  34744. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  34745. /**
  34746. * Bind a webGL buffer for a transform feedback operation
  34747. * @param value defines the webGL buffer to bind
  34748. */
  34749. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  34750. }
  34751. }
  34752. declare module BABYLON {
  34753. /**
  34754. * Google Daydream controller
  34755. */
  34756. class DaydreamController extends WebVRController {
  34757. /**
  34758. * Base Url for the controller model.
  34759. */
  34760. static MODEL_BASE_URL: string;
  34761. /**
  34762. * File name for the controller model.
  34763. */
  34764. static MODEL_FILENAME: string;
  34765. /**
  34766. * Gamepad Id prefix used to identify Daydream Controller.
  34767. */
  34768. static readonly GAMEPAD_ID_PREFIX: string;
  34769. /**
  34770. * Creates a new DaydreamController from a gamepad
  34771. * @param vrGamepad the gamepad that the controller should be created from
  34772. */
  34773. constructor(vrGamepad: any);
  34774. /**
  34775. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34776. * @param scene scene in which to add meshes
  34777. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34778. */
  34779. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34780. /**
  34781. * Called once for each button that changed state since the last frame
  34782. * @param buttonIdx Which button index changed
  34783. * @param state New state of the button
  34784. * @param changes Which properties on the state changed since last frame
  34785. */
  34786. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34787. }
  34788. }
  34789. declare module BABYLON {
  34790. /**
  34791. * Gear VR Controller
  34792. */
  34793. class GearVRController extends WebVRController {
  34794. /**
  34795. * Base Url for the controller model.
  34796. */
  34797. static MODEL_BASE_URL: string;
  34798. /**
  34799. * File name for the controller model.
  34800. */
  34801. static MODEL_FILENAME: string;
  34802. private _maxRotationDistFromHeadset;
  34803. private _draggedRoomRotation;
  34804. private _tmpVector;
  34805. /**
  34806. * Gamepad Id prefix used to identify this controller.
  34807. */
  34808. static readonly GAMEPAD_ID_PREFIX: string;
  34809. private readonly _buttonIndexToObservableNameMap;
  34810. /**
  34811. * Creates a new GearVRController from a gamepad
  34812. * @param vrGamepad the gamepad that the controller should be created from
  34813. */
  34814. constructor(vrGamepad: any);
  34815. /**
  34816. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  34817. * @param poseData raw pose fromthe device
  34818. */
  34819. updateFromDevice(poseData: DevicePose): void;
  34820. /**
  34821. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34822. * @param scene scene in which to add meshes
  34823. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34824. */
  34825. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34826. /**
  34827. * Called once for each button that changed state since the last frame
  34828. * @param buttonIdx Which button index changed
  34829. * @param state New state of the button
  34830. * @param changes Which properties on the state changed since last frame
  34831. */
  34832. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34833. }
  34834. }
  34835. declare module BABYLON {
  34836. /**
  34837. * Generic Controller
  34838. */
  34839. class GenericController extends WebVRController {
  34840. /**
  34841. * Base Url for the controller model.
  34842. */
  34843. static readonly MODEL_BASE_URL: string;
  34844. /**
  34845. * File name for the controller model.
  34846. */
  34847. static readonly MODEL_FILENAME: string;
  34848. /**
  34849. * Creates a new GenericController from a gamepad
  34850. * @param vrGamepad the gamepad that the controller should be created from
  34851. */
  34852. constructor(vrGamepad: any);
  34853. /**
  34854. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34855. * @param scene scene in which to add meshes
  34856. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34857. */
  34858. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34859. /**
  34860. * Called once for each button that changed state since the last frame
  34861. * @param buttonIdx Which button index changed
  34862. * @param state New state of the button
  34863. * @param changes Which properties on the state changed since last frame
  34864. */
  34865. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34866. }
  34867. }
  34868. declare module BABYLON {
  34869. /**
  34870. * Oculus Touch Controller
  34871. */
  34872. class OculusTouchController extends WebVRController {
  34873. /**
  34874. * Base Url for the controller model.
  34875. */
  34876. static MODEL_BASE_URL: string;
  34877. /**
  34878. * File name for the left controller model.
  34879. */
  34880. static MODEL_LEFT_FILENAME: string;
  34881. /**
  34882. * File name for the right controller model.
  34883. */
  34884. static MODEL_RIGHT_FILENAME: string;
  34885. /**
  34886. * Fired when the secondary trigger on this controller is modified
  34887. */
  34888. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  34889. /**
  34890. * Fired when the thumb rest on this controller is modified
  34891. */
  34892. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  34893. /**
  34894. * Creates a new OculusTouchController from a gamepad
  34895. * @param vrGamepad the gamepad that the controller should be created from
  34896. */
  34897. constructor(vrGamepad: any);
  34898. /**
  34899. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34900. * @param scene scene in which to add meshes
  34901. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34902. */
  34903. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  34904. /**
  34905. * Fired when the A button on this controller is modified
  34906. */
  34907. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34908. /**
  34909. * Fired when the B button on this controller is modified
  34910. */
  34911. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34912. /**
  34913. * Fired when the X button on this controller is modified
  34914. */
  34915. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34916. /**
  34917. * Fired when the Y button on this controller is modified
  34918. */
  34919. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  34920. /**
  34921. * Called once for each button that changed state since the last frame
  34922. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  34923. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  34924. * 2) secondary trigger (same)
  34925. * 3) A (right) X (left), touch, pressed = value
  34926. * 4) B / Y
  34927. * 5) thumb rest
  34928. * @param buttonIdx Which button index changed
  34929. * @param state New state of the button
  34930. * @param changes Which properties on the state changed since last frame
  34931. */
  34932. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  34933. }
  34934. }
  34935. declare module BABYLON {
  34936. /**
  34937. * Defines the types of pose enabled controllers that are supported
  34938. */
  34939. enum PoseEnabledControllerType {
  34940. /**
  34941. * HTC Vive
  34942. */
  34943. VIVE = 0,
  34944. /**
  34945. * Oculus Rift
  34946. */
  34947. OCULUS = 1,
  34948. /**
  34949. * Windows mixed reality
  34950. */
  34951. WINDOWS = 2,
  34952. /**
  34953. * Samsung gear VR
  34954. */
  34955. GEAR_VR = 3,
  34956. /**
  34957. * Google Daydream
  34958. */
  34959. DAYDREAM = 4,
  34960. /**
  34961. * Generic
  34962. */
  34963. GENERIC = 5
  34964. }
  34965. /**
  34966. * Defines the MutableGamepadButton interface for the state of a gamepad button
  34967. */
  34968. interface MutableGamepadButton {
  34969. /**
  34970. * Value of the button/trigger
  34971. */
  34972. value: number;
  34973. /**
  34974. * If the button/trigger is currently touched
  34975. */
  34976. touched: boolean;
  34977. /**
  34978. * If the button/trigger is currently pressed
  34979. */
  34980. pressed: boolean;
  34981. }
  34982. /**
  34983. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  34984. * @hidden
  34985. */
  34986. interface ExtendedGamepadButton extends GamepadButton {
  34987. /**
  34988. * If the button/trigger is currently pressed
  34989. */
  34990. readonly pressed: boolean;
  34991. /**
  34992. * If the button/trigger is currently touched
  34993. */
  34994. readonly touched: boolean;
  34995. /**
  34996. * Value of the button/trigger
  34997. */
  34998. readonly value: number;
  34999. }
  35000. /**
  35001. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  35002. */
  35003. class PoseEnabledControllerHelper {
  35004. /**
  35005. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  35006. * @param vrGamepad the gamepad to initialized
  35007. * @returns a vr controller of the type the gamepad identified as
  35008. */
  35009. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  35010. }
  35011. /**
  35012. * Defines the PoseEnabledController object that contains state of a vr capable controller
  35013. */
  35014. class PoseEnabledController extends Gamepad implements PoseControlled {
  35015. private _deviceRoomPosition;
  35016. private _deviceRoomRotationQuaternion;
  35017. /**
  35018. * The device position in babylon space
  35019. */
  35020. devicePosition: Vector3;
  35021. /**
  35022. * The device rotation in babylon space
  35023. */
  35024. deviceRotationQuaternion: Quaternion;
  35025. /**
  35026. * The scale factor of the device in babylon space
  35027. */
  35028. deviceScaleFactor: number;
  35029. /**
  35030. * (Likely devicePosition should be used instead) The device position in its room space
  35031. */
  35032. position: Vector3;
  35033. /**
  35034. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  35035. */
  35036. rotationQuaternion: Quaternion;
  35037. /**
  35038. * The type of controller (Eg. Windows mixed reality)
  35039. */
  35040. controllerType: PoseEnabledControllerType;
  35041. protected _calculatedPosition: Vector3;
  35042. private _calculatedRotation;
  35043. /**
  35044. * The raw pose from the device
  35045. */
  35046. rawPose: DevicePose;
  35047. /**
  35048. * Internal, the mesh attached to the controller
  35049. * @hidden
  35050. */
  35051. _mesh: Nullable<AbstractMesh>;
  35052. private _poseControlledCamera;
  35053. private _leftHandSystemQuaternion;
  35054. /**
  35055. * Internal, matrix used to convert room space to babylon space
  35056. * @hidden
  35057. */
  35058. _deviceToWorld: Matrix;
  35059. /**
  35060. * Node to be used when casting a ray from the controller
  35061. * @hidden
  35062. */
  35063. _pointingPoseNode: Nullable<AbstractMesh>;
  35064. /**
  35065. * Name of the child mesh that can be used to cast a ray from the controller
  35066. */
  35067. static readonly POINTING_POSE: string;
  35068. /**
  35069. * Creates a new PoseEnabledController from a gamepad
  35070. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  35071. */
  35072. constructor(browserGamepad: any);
  35073. private _workingMatrix;
  35074. /**
  35075. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  35076. */
  35077. update(): void;
  35078. /**
  35079. * Updates only the pose device and mesh without doing any button event checking
  35080. */
  35081. protected _updatePoseAndMesh(): void;
  35082. /**
  35083. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  35084. * @param poseData raw pose fromthe device
  35085. */
  35086. updateFromDevice(poseData: DevicePose): void;
  35087. /**
  35088. * @hidden
  35089. */
  35090. _meshAttachedObservable: Observable<AbstractMesh>;
  35091. /**
  35092. * Attaches a mesh to the controller
  35093. * @param mesh the mesh to be attached
  35094. */
  35095. attachToMesh(mesh: AbstractMesh): void;
  35096. /**
  35097. * Attaches the controllers mesh to a camera
  35098. * @param camera the camera the mesh should be attached to
  35099. */
  35100. attachToPoseControlledCamera(camera: TargetCamera): void;
  35101. /**
  35102. * Disposes of the controller
  35103. */
  35104. dispose(): void;
  35105. /**
  35106. * The mesh that is attached to the controller
  35107. */
  35108. readonly mesh: Nullable<AbstractMesh>;
  35109. /**
  35110. * Gets the ray of the controller in the direction the controller is pointing
  35111. * @param length the length the resulting ray should be
  35112. * @returns a ray in the direction the controller is pointing
  35113. */
  35114. getForwardRay(length?: number): Ray;
  35115. }
  35116. }
  35117. declare module BABYLON {
  35118. /**
  35119. * Vive Controller
  35120. */
  35121. class ViveController extends WebVRController {
  35122. /**
  35123. * Base Url for the controller model.
  35124. */
  35125. static MODEL_BASE_URL: string;
  35126. /**
  35127. * File name for the controller model.
  35128. */
  35129. static MODEL_FILENAME: string;
  35130. /**
  35131. * Creates a new ViveController from a gamepad
  35132. * @param vrGamepad the gamepad that the controller should be created from
  35133. */
  35134. constructor(vrGamepad: any);
  35135. /**
  35136. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35137. * @param scene scene in which to add meshes
  35138. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35139. */
  35140. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  35141. /**
  35142. * Fired when the left button on this controller is modified
  35143. */
  35144. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  35145. /**
  35146. * Fired when the right button on this controller is modified
  35147. */
  35148. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  35149. /**
  35150. * Fired when the menu button on this controller is modified
  35151. */
  35152. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  35153. /**
  35154. * Called once for each button that changed state since the last frame
  35155. * Vive mapping:
  35156. * 0: touchpad
  35157. * 1: trigger
  35158. * 2: left AND right buttons
  35159. * 3: menu button
  35160. * @param buttonIdx Which button index changed
  35161. * @param state New state of the button
  35162. * @param changes Which properties on the state changed since last frame
  35163. */
  35164. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  35165. }
  35166. }
  35167. declare module BABYLON {
  35168. /**
  35169. * Defines the WebVRController object that represents controllers tracked in 3D space
  35170. */
  35171. abstract class WebVRController extends PoseEnabledController {
  35172. /**
  35173. * Internal, the default controller model for the controller
  35174. */
  35175. protected _defaultModel: AbstractMesh;
  35176. /**
  35177. * Fired when the trigger state has changed
  35178. */
  35179. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  35180. /**
  35181. * Fired when the main button state has changed
  35182. */
  35183. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  35184. /**
  35185. * Fired when the secondary button state has changed
  35186. */
  35187. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  35188. /**
  35189. * Fired when the pad state has changed
  35190. */
  35191. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  35192. /**
  35193. * Fired when controllers stick values have changed
  35194. */
  35195. onPadValuesChangedObservable: Observable<StickValues>;
  35196. /**
  35197. * Array of button availible on the controller
  35198. */
  35199. protected _buttons: Array<MutableGamepadButton>;
  35200. private _onButtonStateChange;
  35201. /**
  35202. * Fired when a controller button's state has changed
  35203. * @param callback the callback containing the button that was modified
  35204. */
  35205. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  35206. /**
  35207. * X and Y axis corrisponding to the controllers joystick
  35208. */
  35209. pad: StickValues;
  35210. /**
  35211. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  35212. */
  35213. hand: string;
  35214. /**
  35215. * The default controller model for the controller
  35216. */
  35217. readonly defaultModel: AbstractMesh;
  35218. /**
  35219. * Creates a new WebVRController from a gamepad
  35220. * @param vrGamepad the gamepad that the WebVRController should be created from
  35221. */
  35222. constructor(vrGamepad: any);
  35223. /**
  35224. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  35225. */
  35226. update(): void;
  35227. /**
  35228. * Function to be called when a button is modified
  35229. */
  35230. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  35231. /**
  35232. * Loads a mesh and attaches it to the controller
  35233. * @param scene the scene the mesh should be added to
  35234. * @param meshLoaded callback for when the mesh has been loaded
  35235. */
  35236. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  35237. private _setButtonValue;
  35238. private _changes;
  35239. private _checkChanges;
  35240. /**
  35241. * Disposes of th webVRCOntroller
  35242. */
  35243. dispose(): void;
  35244. }
  35245. }
  35246. declare module BABYLON {
  35247. /**
  35248. * Defines the WindowsMotionController object that the state of the windows motion controller
  35249. */
  35250. class WindowsMotionController extends WebVRController {
  35251. /**
  35252. * The base url used to load the left and right controller models
  35253. */
  35254. static MODEL_BASE_URL: string;
  35255. /**
  35256. * The name of the left controller model file
  35257. */
  35258. static MODEL_LEFT_FILENAME: string;
  35259. /**
  35260. * The name of the right controller model file
  35261. */
  35262. static MODEL_RIGHT_FILENAME: string;
  35263. /**
  35264. * The controller name prefix for this controller type
  35265. */
  35266. static readonly GAMEPAD_ID_PREFIX: string;
  35267. /**
  35268. * The controller id pattern for this controller type
  35269. */
  35270. private static readonly GAMEPAD_ID_PATTERN;
  35271. private _loadedMeshInfo;
  35272. private readonly _mapping;
  35273. /**
  35274. * Fired when the trackpad on this controller is clicked
  35275. */
  35276. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  35277. /**
  35278. * Fired when the trackpad on this controller is modified
  35279. */
  35280. onTrackpadValuesChangedObservable: Observable<StickValues>;
  35281. /**
  35282. * The current x and y values of this controller's trackpad
  35283. */
  35284. trackpad: StickValues;
  35285. /**
  35286. * Creates a new WindowsMotionController from a gamepad
  35287. * @param vrGamepad the gamepad that the controller should be created from
  35288. */
  35289. constructor(vrGamepad: any);
  35290. /**
  35291. * Fired when the trigger on this controller is modified
  35292. */
  35293. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  35294. /**
  35295. * Fired when the menu button on this controller is modified
  35296. */
  35297. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  35298. /**
  35299. * Fired when the grip button on this controller is modified
  35300. */
  35301. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  35302. /**
  35303. * Fired when the thumbstick button on this controller is modified
  35304. */
  35305. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  35306. /**
  35307. * Fired when the touchpad button on this controller is modified
  35308. */
  35309. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  35310. /**
  35311. * Fired when the touchpad values on this controller are modified
  35312. */
  35313. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  35314. private _updateTrackpad;
  35315. /**
  35316. * Called once per frame by the engine.
  35317. */
  35318. update(): void;
  35319. /**
  35320. * Called once for each button that changed state since the last frame
  35321. * @param buttonIdx Which button index changed
  35322. * @param state New state of the button
  35323. * @param changes Which properties on the state changed since last frame
  35324. */
  35325. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  35326. /**
  35327. * Moves the buttons on the controller mesh based on their current state
  35328. * @param buttonName the name of the button to move
  35329. * @param buttonValue the value of the button which determines the buttons new position
  35330. */
  35331. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  35332. /**
  35333. * Moves the axis on the controller mesh based on its current state
  35334. * @param axis the index of the axis
  35335. * @param axisValue the value of the axis which determines the meshes new position
  35336. * @hidden
  35337. */
  35338. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  35339. /**
  35340. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35341. * @param scene scene in which to add meshes
  35342. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35343. */
  35344. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  35345. /**
  35346. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  35347. * can be transformed by button presses and axes values, based on this._mapping.
  35348. *
  35349. * @param scene scene in which the meshes exist
  35350. * @param meshes list of meshes that make up the controller model to process
  35351. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  35352. */
  35353. private processModel;
  35354. private createMeshInfo;
  35355. /**
  35356. * Gets the ray of the controller in the direction the controller is pointing
  35357. * @param length the length the resulting ray should be
  35358. * @returns a ray in the direction the controller is pointing
  35359. */
  35360. getForwardRay(length?: number): Ray;
  35361. /**
  35362. * Disposes of the controller
  35363. */
  35364. dispose(): void;
  35365. }
  35366. }
  35367. declare module BABYLON {
  35368. /**
  35369. * Interface to implement to create a shadow generator compatible with BJS.
  35370. */
  35371. interface IShadowGenerator {
  35372. /**
  35373. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  35374. * @returns The render target texture if present otherwise, null
  35375. */
  35376. getShadowMap(): Nullable<RenderTargetTexture>;
  35377. /**
  35378. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  35379. * @returns The render target texture if the shadow map is present otherwise, null
  35380. */
  35381. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  35382. /**
  35383. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  35384. * @param subMesh The submesh we want to render in the shadow map
  35385. * @param useInstances Defines wether will draw in the map using instances
  35386. * @returns true if ready otherwise, false
  35387. */
  35388. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35389. /**
  35390. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  35391. * @param defines Defines of the material we want to update
  35392. * @param lightIndex Index of the light in the enabled light list of the material
  35393. */
  35394. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  35395. /**
  35396. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  35397. * defined in the generator but impacting the effect).
  35398. * It implies the unifroms available on the materials are the standard BJS ones.
  35399. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  35400. * @param effect The effect we are binfing the information for
  35401. */
  35402. bindShadowLight(lightIndex: string, effect: Effect): void;
  35403. /**
  35404. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  35405. * (eq to shadow prjection matrix * light transform matrix)
  35406. * @returns The transform matrix used to create the shadow map
  35407. */
  35408. getTransformMatrix(): Matrix;
  35409. /**
  35410. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  35411. * Cube and 2D textures for instance.
  35412. */
  35413. recreateShadowMap(): void;
  35414. /**
  35415. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  35416. * @param onCompiled Callback triggered at the and of the effects compilation
  35417. * @param options Sets of optional options forcing the compilation with different modes
  35418. */
  35419. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  35420. useInstances: boolean;
  35421. }>): void;
  35422. /**
  35423. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  35424. * @param options Sets of optional options forcing the compilation with different modes
  35425. * @returns A promise that resolves when the compilation completes
  35426. */
  35427. forceCompilationAsync(options?: Partial<{
  35428. useInstances: boolean;
  35429. }>): Promise<void>;
  35430. /**
  35431. * Serializes the shadow generator setup to a json object.
  35432. * @returns The serialized JSON object
  35433. */
  35434. serialize(): any;
  35435. /**
  35436. * Disposes the Shadow map and related Textures and effects.
  35437. */
  35438. dispose(): void;
  35439. }
  35440. /**
  35441. * Default implementation IShadowGenerator.
  35442. * This is the main object responsible of generating shadows in the framework.
  35443. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  35444. */
  35445. class ShadowGenerator implements IShadowGenerator {
  35446. /**
  35447. * Shadow generator mode None: no filtering applied.
  35448. */
  35449. static readonly FILTER_NONE: number;
  35450. /**
  35451. * Shadow generator mode ESM: Exponential Shadow Mapping.
  35452. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  35453. */
  35454. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  35455. /**
  35456. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  35457. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  35458. */
  35459. static readonly FILTER_POISSONSAMPLING: number;
  35460. /**
  35461. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  35462. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  35463. */
  35464. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  35465. /**
  35466. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  35467. * edge artifacts on steep falloff.
  35468. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  35469. */
  35470. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  35471. /**
  35472. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  35473. * edge artifacts on steep falloff.
  35474. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  35475. */
  35476. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  35477. /**
  35478. * Shadow generator mode PCF: Percentage Closer Filtering
  35479. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  35480. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  35481. */
  35482. static readonly FILTER_PCF: number;
  35483. /**
  35484. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  35485. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  35486. * Contact Hardening
  35487. */
  35488. static readonly FILTER_PCSS: number;
  35489. /**
  35490. * Reserved for PCF and PCSS
  35491. * Highest Quality.
  35492. *
  35493. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  35494. *
  35495. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  35496. */
  35497. static readonly QUALITY_HIGH: number;
  35498. /**
  35499. * Reserved for PCF and PCSS
  35500. * Good tradeoff for quality/perf cross devices
  35501. *
  35502. * Execute PCF on a 3*3 kernel.
  35503. *
  35504. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  35505. */
  35506. static readonly QUALITY_MEDIUM: number;
  35507. /**
  35508. * Reserved for PCF and PCSS
  35509. * The lowest quality but the fastest.
  35510. *
  35511. * Execute PCF on a 1*1 kernel.
  35512. *
  35513. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  35514. */
  35515. static readonly QUALITY_LOW: number;
  35516. private _bias;
  35517. /**
  35518. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  35519. */
  35520. /**
  35521. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  35522. */
  35523. bias: number;
  35524. private _normalBias;
  35525. /**
  35526. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  35527. */
  35528. /**
  35529. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  35530. */
  35531. normalBias: number;
  35532. private _blurBoxOffset;
  35533. /**
  35534. * Gets the blur box offset: offset applied during the blur pass.
  35535. * Only usefull if useKernelBlur = false
  35536. */
  35537. /**
  35538. * Sets the blur box offset: offset applied during the blur pass.
  35539. * Only usefull if useKernelBlur = false
  35540. */
  35541. blurBoxOffset: number;
  35542. private _blurScale;
  35543. /**
  35544. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  35545. * 2 means half of the size.
  35546. */
  35547. /**
  35548. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  35549. * 2 means half of the size.
  35550. */
  35551. blurScale: number;
  35552. private _blurKernel;
  35553. /**
  35554. * Gets the blur kernel: kernel size of the blur pass.
  35555. * Only usefull if useKernelBlur = true
  35556. */
  35557. /**
  35558. * Sets the blur kernel: kernel size of the blur pass.
  35559. * Only usefull if useKernelBlur = true
  35560. */
  35561. blurKernel: number;
  35562. private _useKernelBlur;
  35563. /**
  35564. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  35565. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  35566. */
  35567. /**
  35568. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  35569. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  35570. */
  35571. useKernelBlur: boolean;
  35572. private _depthScale;
  35573. /**
  35574. * Gets the depth scale used in ESM mode.
  35575. */
  35576. /**
  35577. * Sets the depth scale used in ESM mode.
  35578. * This can override the scale stored on the light.
  35579. */
  35580. depthScale: number;
  35581. private _filter;
  35582. /**
  35583. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  35584. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  35585. */
  35586. /**
  35587. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  35588. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  35589. */
  35590. filter: number;
  35591. /**
  35592. * Gets if the current filter is set to Poisson Sampling.
  35593. */
  35594. /**
  35595. * Sets the current filter to Poisson Sampling.
  35596. */
  35597. usePoissonSampling: boolean;
  35598. /**
  35599. * Gets if the current filter is set to VSM.
  35600. * DEPRECATED. Should use useExponentialShadowMap instead.
  35601. */
  35602. /**
  35603. * Sets the current filter is to VSM.
  35604. * DEPRECATED. Should use useExponentialShadowMap instead.
  35605. */
  35606. useVarianceShadowMap: boolean;
  35607. /**
  35608. * Gets if the current filter is set to blurred VSM.
  35609. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  35610. */
  35611. /**
  35612. * Sets the current filter is to blurred VSM.
  35613. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  35614. */
  35615. useBlurVarianceShadowMap: boolean;
  35616. /**
  35617. * Gets if the current filter is set to ESM.
  35618. */
  35619. /**
  35620. * Sets the current filter is to ESM.
  35621. */
  35622. useExponentialShadowMap: boolean;
  35623. /**
  35624. * Gets if the current filter is set to filtered ESM.
  35625. */
  35626. /**
  35627. * Gets if the current filter is set to filtered ESM.
  35628. */
  35629. useBlurExponentialShadowMap: boolean;
  35630. /**
  35631. * Gets if the current filter is set to "close ESM" (using the inverse of the
  35632. * exponential to prevent steep falloff artifacts).
  35633. */
  35634. /**
  35635. * Sets the current filter to "close ESM" (using the inverse of the
  35636. * exponential to prevent steep falloff artifacts).
  35637. */
  35638. useCloseExponentialShadowMap: boolean;
  35639. /**
  35640. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  35641. * exponential to prevent steep falloff artifacts).
  35642. */
  35643. /**
  35644. * Sets the current filter to filtered "close ESM" (using the inverse of the
  35645. * exponential to prevent steep falloff artifacts).
  35646. */
  35647. useBlurCloseExponentialShadowMap: boolean;
  35648. /**
  35649. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  35650. */
  35651. /**
  35652. * Sets the current filter to "PCF" (percentage closer filtering).
  35653. */
  35654. usePercentageCloserFiltering: boolean;
  35655. private _filteringQuality;
  35656. /**
  35657. * Gets the PCF or PCSS Quality.
  35658. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  35659. */
  35660. /**
  35661. * Sets the PCF or PCSS Quality.
  35662. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  35663. */
  35664. filteringQuality: number;
  35665. /**
  35666. * Gets if the current filter is set to "PCSS" (contact hardening).
  35667. */
  35668. /**
  35669. * Sets the current filter to "PCSS" (contact hardening).
  35670. */
  35671. useContactHardeningShadow: boolean;
  35672. private _contactHardeningLightSizeUVRatio;
  35673. /**
  35674. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  35675. * Using a ratio helps keeping shape stability independently of the map size.
  35676. *
  35677. * It does not account for the light projection as it was having too much
  35678. * instability during the light setup or during light position changes.
  35679. *
  35680. * Only valid if useContactHardeningShadow is true.
  35681. */
  35682. /**
  35683. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  35684. * Using a ratio helps keeping shape stability independently of the map size.
  35685. *
  35686. * It does not account for the light projection as it was having too much
  35687. * instability during the light setup or during light position changes.
  35688. *
  35689. * Only valid if useContactHardeningShadow is true.
  35690. */
  35691. contactHardeningLightSizeUVRatio: number;
  35692. private _darkness;
  35693. /**
  35694. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  35695. * 0 means strongest and 1 would means no shadow.
  35696. * @returns the darkness.
  35697. */
  35698. getDarkness(): number;
  35699. /**
  35700. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  35701. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  35702. * @returns the shadow generator allowing fluent coding.
  35703. */
  35704. setDarkness(darkness: number): ShadowGenerator;
  35705. private _transparencyShadow;
  35706. /**
  35707. * Sets the ability to have transparent shadow (boolean).
  35708. * @param transparent True if transparent else False
  35709. * @returns the shadow generator allowing fluent coding
  35710. */
  35711. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  35712. private _shadowMap;
  35713. private _shadowMap2;
  35714. /**
  35715. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  35716. * @returns The render target texture if present otherwise, null
  35717. */
  35718. getShadowMap(): Nullable<RenderTargetTexture>;
  35719. /**
  35720. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  35721. * @returns The render target texture if the shadow map is present otherwise, null
  35722. */
  35723. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  35724. /**
  35725. * Helper function to add a mesh and its descendants to the list of shadow casters.
  35726. * @param mesh Mesh to add
  35727. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  35728. * @returns the Shadow Generator itself
  35729. */
  35730. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  35731. /**
  35732. * Helper function to remove a mesh and its descendants from the list of shadow casters
  35733. * @param mesh Mesh to remove
  35734. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  35735. * @returns the Shadow Generator itself
  35736. */
  35737. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  35738. /**
  35739. * Controls the extent to which the shadows fade out at the edge of the frustum
  35740. * Used only by directionals and spots
  35741. */
  35742. frustumEdgeFalloff: number;
  35743. private _light;
  35744. /**
  35745. * Returns the associated light object.
  35746. * @returns the light generating the shadow
  35747. */
  35748. getLight(): IShadowLight;
  35749. /**
  35750. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  35751. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  35752. * It might on the other hand introduce peter panning.
  35753. */
  35754. forceBackFacesOnly: boolean;
  35755. private _scene;
  35756. private _lightDirection;
  35757. private _effect;
  35758. private _viewMatrix;
  35759. private _projectionMatrix;
  35760. private _transformMatrix;
  35761. private _cachedPosition;
  35762. private _cachedDirection;
  35763. private _cachedDefines;
  35764. private _currentRenderID;
  35765. private _boxBlurPostprocess;
  35766. private _kernelBlurXPostprocess;
  35767. private _kernelBlurYPostprocess;
  35768. private _blurPostProcesses;
  35769. private _mapSize;
  35770. private _currentFaceIndex;
  35771. private _currentFaceIndexCache;
  35772. private _textureType;
  35773. private _defaultTextureMatrix;
  35774. /**
  35775. * Creates a ShadowGenerator object.
  35776. * A ShadowGenerator is the required tool to use the shadows.
  35777. * Each light casting shadows needs to use its own ShadowGenerator.
  35778. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  35779. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  35780. * @param light The light object generating the shadows.
  35781. * @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.
  35782. */
  35783. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  35784. private _initializeGenerator;
  35785. private _initializeShadowMap;
  35786. private _initializeBlurRTTAndPostProcesses;
  35787. private _renderForShadowMap;
  35788. private _renderSubMeshForShadowMap;
  35789. private _applyFilterValues;
  35790. /**
  35791. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  35792. * @param onCompiled Callback triggered at the and of the effects compilation
  35793. * @param options Sets of optional options forcing the compilation with different modes
  35794. */
  35795. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  35796. useInstances: boolean;
  35797. }>): void;
  35798. /**
  35799. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  35800. * @param options Sets of optional options forcing the compilation with different modes
  35801. * @returns A promise that resolves when the compilation completes
  35802. */
  35803. forceCompilationAsync(options?: Partial<{
  35804. useInstances: boolean;
  35805. }>): Promise<void>;
  35806. /**
  35807. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  35808. * @param subMesh The submesh we want to render in the shadow map
  35809. * @param useInstances Defines wether will draw in the map using instances
  35810. * @returns true if ready otherwise, false
  35811. */
  35812. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35813. /**
  35814. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  35815. * @param defines Defines of the material we want to update
  35816. * @param lightIndex Index of the light in the enabled light list of the material
  35817. */
  35818. prepareDefines(defines: any, lightIndex: number): void;
  35819. /**
  35820. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  35821. * defined in the generator but impacting the effect).
  35822. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  35823. * @param effect The effect we are binfing the information for
  35824. */
  35825. bindShadowLight(lightIndex: string, effect: Effect): void;
  35826. /**
  35827. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  35828. * (eq to shadow prjection matrix * light transform matrix)
  35829. * @returns The transform matrix used to create the shadow map
  35830. */
  35831. getTransformMatrix(): Matrix;
  35832. /**
  35833. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  35834. * Cube and 2D textures for instance.
  35835. */
  35836. recreateShadowMap(): void;
  35837. private _disposeBlurPostProcesses;
  35838. private _disposeRTTandPostProcesses;
  35839. /**
  35840. * Disposes the ShadowGenerator.
  35841. * Returns nothing.
  35842. */
  35843. dispose(): void;
  35844. /**
  35845. * Serializes the shadow generator setup to a json object.
  35846. * @returns The serialized JSON object
  35847. */
  35848. serialize(): any;
  35849. /**
  35850. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  35851. * @param parsedShadowGenerator The JSON object to parse
  35852. * @param scene The scene to create the shadow map for
  35853. * @returns The parsed shadow generator
  35854. */
  35855. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  35856. }
  35857. }
  35858. declare module BABYLON {
  35859. /**
  35860. * Defines the shadow generator component responsible to manage any shadow generators
  35861. * in a given scene.
  35862. */
  35863. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  35864. /**
  35865. * The component name helpfull to identify the component in the list of scene components.
  35866. */
  35867. readonly name: string;
  35868. /**
  35869. * The scene the component belongs to.
  35870. */
  35871. scene: Scene;
  35872. /**
  35873. * Creates a new instance of the component for the given scene
  35874. * @param scene Defines the scene to register the component in
  35875. */
  35876. constructor(scene: Scene);
  35877. /**
  35878. * Registers the component in a given scene
  35879. */
  35880. register(): void;
  35881. /**
  35882. * Rebuilds the elements related to this component in case of
  35883. * context lost for instance.
  35884. */
  35885. rebuild(): void;
  35886. /**
  35887. * Serializes the component data to the specified json object
  35888. * @param serializationObject The object to serialize to
  35889. */
  35890. serialize(serializationObject: any): void;
  35891. /**
  35892. * Adds all the element from the container to the scene
  35893. * @param container the container holding the elements
  35894. */
  35895. addFromContainer(container: AbstractScene): void;
  35896. /**
  35897. * Removes all the elements in the container from the scene
  35898. * @param container contains the elements to remove
  35899. */
  35900. removeFromContainer(container: AbstractScene): void;
  35901. /**
  35902. * Rebuilds the elements related to this component in case of
  35903. * context lost for instance.
  35904. */
  35905. dispose(): void;
  35906. private _gatherRenderTargets;
  35907. }
  35908. }
  35909. declare module BABYLON {
  35910. }
  35911. declare module BABYLON {
  35912. /**
  35913. * Background material used to create an efficient environement around your scene.
  35914. */
  35915. class BackgroundMaterial extends PushMaterial {
  35916. /**
  35917. * Standard reflectance value at parallel view angle.
  35918. */
  35919. static StandardReflectance0: number;
  35920. /**
  35921. * Standard reflectance value at grazing angle.
  35922. */
  35923. static StandardReflectance90: number;
  35924. protected _primaryColor: Color3;
  35925. /**
  35926. * Key light Color (multiply against the environement texture)
  35927. */
  35928. primaryColor: Color3;
  35929. protected __perceptualColor: Nullable<Color3>;
  35930. /**
  35931. * Experimental Internal Use Only.
  35932. *
  35933. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  35934. * This acts as a helper to set the primary color to a more "human friendly" value.
  35935. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  35936. * output color as close as possible from the chosen value.
  35937. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  35938. * part of lighting setup.)
  35939. */
  35940. _perceptualColor: Nullable<Color3>;
  35941. protected _primaryColorShadowLevel: float;
  35942. /**
  35943. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  35944. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  35945. */
  35946. primaryColorShadowLevel: float;
  35947. protected _primaryColorHighlightLevel: float;
  35948. /**
  35949. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  35950. * The primary color is used at the level chosen to define what the white area would look.
  35951. */
  35952. primaryColorHighlightLevel: float;
  35953. protected _reflectionTexture: Nullable<BaseTexture>;
  35954. /**
  35955. * Reflection Texture used in the material.
  35956. * Should be author in a specific way for the best result (refer to the documentation).
  35957. */
  35958. reflectionTexture: Nullable<BaseTexture>;
  35959. protected _reflectionBlur: float;
  35960. /**
  35961. * Reflection Texture level of blur.
  35962. *
  35963. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  35964. * texture twice.
  35965. */
  35966. reflectionBlur: float;
  35967. protected _diffuseTexture: Nullable<BaseTexture>;
  35968. /**
  35969. * Diffuse Texture used in the material.
  35970. * Should be author in a specific way for the best result (refer to the documentation).
  35971. */
  35972. diffuseTexture: Nullable<BaseTexture>;
  35973. protected _shadowLights: Nullable<IShadowLight[]>;
  35974. /**
  35975. * Specify the list of lights casting shadow on the material.
  35976. * All scene shadow lights will be included if null.
  35977. */
  35978. shadowLights: Nullable<IShadowLight[]>;
  35979. protected _shadowLevel: float;
  35980. /**
  35981. * Helps adjusting the shadow to a softer level if required.
  35982. * 0 means black shadows and 1 means no shadows.
  35983. */
  35984. shadowLevel: float;
  35985. protected _sceneCenter: Vector3;
  35986. /**
  35987. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  35988. * It is usually zero but might be interesting to modify according to your setup.
  35989. */
  35990. sceneCenter: Vector3;
  35991. protected _opacityFresnel: boolean;
  35992. /**
  35993. * This helps specifying that the material is falling off to the sky box at grazing angle.
  35994. * This helps ensuring a nice transition when the camera goes under the ground.
  35995. */
  35996. opacityFresnel: boolean;
  35997. protected _reflectionFresnel: boolean;
  35998. /**
  35999. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  36000. * This helps adding a mirror texture on the ground.
  36001. */
  36002. reflectionFresnel: boolean;
  36003. protected _reflectionFalloffDistance: number;
  36004. /**
  36005. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  36006. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  36007. */
  36008. reflectionFalloffDistance: number;
  36009. protected _reflectionAmount: number;
  36010. /**
  36011. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  36012. */
  36013. reflectionAmount: number;
  36014. protected _reflectionReflectance0: number;
  36015. /**
  36016. * This specifies the weight of the reflection at grazing angle.
  36017. */
  36018. reflectionReflectance0: number;
  36019. protected _reflectionReflectance90: number;
  36020. /**
  36021. * This specifies the weight of the reflection at a perpendicular point of view.
  36022. */
  36023. reflectionReflectance90: number;
  36024. /**
  36025. * Sets the reflection reflectance fresnel values according to the default standard
  36026. * empirically know to work well :-)
  36027. */
  36028. reflectionStandardFresnelWeight: number;
  36029. protected _useRGBColor: boolean;
  36030. /**
  36031. * Helps to directly use the maps channels instead of their level.
  36032. */
  36033. useRGBColor: boolean;
  36034. protected _enableNoise: boolean;
  36035. /**
  36036. * This helps reducing the banding effect that could occur on the background.
  36037. */
  36038. enableNoise: boolean;
  36039. /**
  36040. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  36041. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  36042. * Recommended to be keep at 1.0 except for special cases.
  36043. */
  36044. fovMultiplier: number;
  36045. private _fovMultiplier;
  36046. /**
  36047. * Enable the FOV adjustment feature controlled by fovMultiplier.
  36048. */
  36049. useEquirectangularFOV: boolean;
  36050. private _maxSimultaneousLights;
  36051. /**
  36052. * Number of Simultaneous lights allowed on the material.
  36053. */
  36054. maxSimultaneousLights: int;
  36055. /**
  36056. * Default configuration related to image processing available in the Background Material.
  36057. */
  36058. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36059. /**
  36060. * Keep track of the image processing observer to allow dispose and replace.
  36061. */
  36062. private _imageProcessingObserver;
  36063. /**
  36064. * Attaches a new image processing configuration to the PBR Material.
  36065. * @param configuration (if null the scene configuration will be use)
  36066. */
  36067. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  36068. /**
  36069. * Gets the image processing configuration used either in this material.
  36070. */
  36071. /**
  36072. * Sets the Default image processing configuration used either in the this material.
  36073. *
  36074. * If sets to null, the scene one is in use.
  36075. */
  36076. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  36077. /**
  36078. * Gets wether the color curves effect is enabled.
  36079. */
  36080. /**
  36081. * Sets wether the color curves effect is enabled.
  36082. */
  36083. cameraColorCurvesEnabled: boolean;
  36084. /**
  36085. * Gets wether the color grading effect is enabled.
  36086. */
  36087. /**
  36088. * Gets wether the color grading effect is enabled.
  36089. */
  36090. cameraColorGradingEnabled: boolean;
  36091. /**
  36092. * Gets wether tonemapping is enabled or not.
  36093. */
  36094. /**
  36095. * Sets wether tonemapping is enabled or not
  36096. */
  36097. cameraToneMappingEnabled: boolean;
  36098. /**
  36099. * The camera exposure used on this material.
  36100. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  36101. * This corresponds to a photographic exposure.
  36102. */
  36103. /**
  36104. * The camera exposure used on this material.
  36105. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  36106. * This corresponds to a photographic exposure.
  36107. */
  36108. cameraExposure: float;
  36109. /**
  36110. * Gets The camera contrast used on this material.
  36111. */
  36112. /**
  36113. * Sets The camera contrast used on this material.
  36114. */
  36115. cameraContrast: float;
  36116. /**
  36117. * Gets the Color Grading 2D Lookup Texture.
  36118. */
  36119. /**
  36120. * Sets the Color Grading 2D Lookup Texture.
  36121. */
  36122. cameraColorGradingTexture: Nullable<BaseTexture>;
  36123. /**
  36124. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  36125. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  36126. * 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;
  36127. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  36128. */
  36129. /**
  36130. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  36131. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  36132. * 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;
  36133. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  36134. */
  36135. cameraColorCurves: Nullable<ColorCurves>;
  36136. /**
  36137. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  36138. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  36139. */
  36140. switchToBGR: boolean;
  36141. private _renderTargets;
  36142. private _reflectionControls;
  36143. private _white;
  36144. private _primaryShadowColor;
  36145. private _primaryHighlightColor;
  36146. /**
  36147. * Instantiates a Background Material in the given scene
  36148. * @param name The friendly name of the material
  36149. * @param scene The scene to add the material to
  36150. */
  36151. constructor(name: string, scene: Scene);
  36152. /**
  36153. * Gets a boolean indicating that current material needs to register RTT
  36154. */
  36155. readonly hasRenderTargetTextures: boolean;
  36156. /**
  36157. * The entire material has been created in order to prevent overdraw.
  36158. * @returns false
  36159. */
  36160. needAlphaTesting(): boolean;
  36161. /**
  36162. * The entire material has been created in order to prevent overdraw.
  36163. * @returns true if blending is enable
  36164. */
  36165. needAlphaBlending(): boolean;
  36166. /**
  36167. * Checks wether the material is ready to be rendered for a given mesh.
  36168. * @param mesh The mesh to render
  36169. * @param subMesh The submesh to check against
  36170. * @param useInstances Specify wether or not the material is used with instances
  36171. * @returns true if all the dependencies are ready (Textures, Effects...)
  36172. */
  36173. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  36174. /**
  36175. * Compute the primary color according to the chosen perceptual color.
  36176. */
  36177. private _computePrimaryColorFromPerceptualColor;
  36178. /**
  36179. * Compute the highlights and shadow colors according to their chosen levels.
  36180. */
  36181. private _computePrimaryColors;
  36182. /**
  36183. * Build the uniform buffer used in the material.
  36184. */
  36185. buildUniformLayout(): void;
  36186. /**
  36187. * Unbind the material.
  36188. */
  36189. unbind(): void;
  36190. /**
  36191. * Bind only the world matrix to the material.
  36192. * @param world The world matrix to bind.
  36193. */
  36194. bindOnlyWorldMatrix(world: Matrix): void;
  36195. /**
  36196. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  36197. * @param world The world matrix to bind.
  36198. * @param subMesh The submesh to bind for.
  36199. */
  36200. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  36201. /**
  36202. * Dispose the material.
  36203. * @param forceDisposeEffect Force disposal of the associated effect.
  36204. * @param forceDisposeTextures Force disposal of the associated textures.
  36205. */
  36206. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  36207. /**
  36208. * Clones the material.
  36209. * @param name The cloned name.
  36210. * @returns The cloned material.
  36211. */
  36212. clone(name: string): BackgroundMaterial;
  36213. /**
  36214. * Serializes the current material to its JSON representation.
  36215. * @returns The JSON representation.
  36216. */
  36217. serialize(): any;
  36218. /**
  36219. * Gets the class name of the material
  36220. * @returns "BackgroundMaterial"
  36221. */
  36222. getClassName(): string;
  36223. /**
  36224. * Parse a JSON input to create back a background material.
  36225. * @param source The JSON data to parse
  36226. * @param scene The scene to create the parsed material in
  36227. * @param rootUrl The root url of the assets the material depends upon
  36228. * @returns the instantiated BackgroundMaterial.
  36229. */
  36230. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  36231. }
  36232. }
  36233. declare module BABYLON {
  36234. /**
  36235. * The Physically based material base class of BJS.
  36236. *
  36237. * This offers the main features of a standard PBR material.
  36238. * For more information, please refer to the documentation :
  36239. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  36240. */
  36241. abstract class PBRBaseMaterial extends PushMaterial {
  36242. /**
  36243. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  36244. */
  36245. static readonly LIGHTFALLOFF_PHYSICAL: number;
  36246. /**
  36247. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  36248. * to enhance interoperability with other engines.
  36249. */
  36250. static readonly LIGHTFALLOFF_GLTF: number;
  36251. /**
  36252. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  36253. * to enhance interoperability with other materials.
  36254. */
  36255. static readonly LIGHTFALLOFF_STANDARD: number;
  36256. /**
  36257. * Intensity of the direct lights e.g. the four lights available in your scene.
  36258. * This impacts both the direct diffuse and specular highlights.
  36259. */
  36260. protected _directIntensity: number;
  36261. /**
  36262. * Intensity of the emissive part of the material.
  36263. * This helps controlling the emissive effect without modifying the emissive color.
  36264. */
  36265. protected _emissiveIntensity: number;
  36266. /**
  36267. * Intensity of the environment e.g. how much the environment will light the object
  36268. * either through harmonics for rough material or through the refelction for shiny ones.
  36269. */
  36270. protected _environmentIntensity: number;
  36271. /**
  36272. * This is a special control allowing the reduction of the specular highlights coming from the
  36273. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  36274. */
  36275. protected _specularIntensity: number;
  36276. /**
  36277. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  36278. */
  36279. private _lightingInfos;
  36280. /**
  36281. * Debug Control allowing disabling the bump map on this material.
  36282. */
  36283. protected _disableBumpMap: boolean;
  36284. /**
  36285. * AKA Diffuse Texture in standard nomenclature.
  36286. */
  36287. protected _albedoTexture: BaseTexture;
  36288. /**
  36289. * AKA Occlusion Texture in other nomenclature.
  36290. */
  36291. protected _ambientTexture: BaseTexture;
  36292. /**
  36293. * AKA Occlusion Texture Intensity in other nomenclature.
  36294. */
  36295. protected _ambientTextureStrength: number;
  36296. /**
  36297. * Defines how much the AO map is occluding the analytical lights (point spot...).
  36298. * 1 means it completely occludes it
  36299. * 0 mean it has no impact
  36300. */
  36301. protected _ambientTextureImpactOnAnalyticalLights: number;
  36302. /**
  36303. * Stores the alpha values in a texture.
  36304. */
  36305. protected _opacityTexture: BaseTexture;
  36306. /**
  36307. * Stores the reflection values in a texture.
  36308. */
  36309. protected _reflectionTexture: BaseTexture;
  36310. /**
  36311. * Stores the refraction values in a texture.
  36312. */
  36313. protected _refractionTexture: BaseTexture;
  36314. /**
  36315. * Stores the emissive values in a texture.
  36316. */
  36317. protected _emissiveTexture: BaseTexture;
  36318. /**
  36319. * AKA Specular texture in other nomenclature.
  36320. */
  36321. protected _reflectivityTexture: BaseTexture;
  36322. /**
  36323. * Used to switch from specular/glossiness to metallic/roughness workflow.
  36324. */
  36325. protected _metallicTexture: BaseTexture;
  36326. /**
  36327. * Specifies the metallic scalar of the metallic/roughness workflow.
  36328. * Can also be used to scale the metalness values of the metallic texture.
  36329. */
  36330. protected _metallic: Nullable<number>;
  36331. /**
  36332. * Specifies the roughness scalar of the metallic/roughness workflow.
  36333. * Can also be used to scale the roughness values of the metallic texture.
  36334. */
  36335. protected _roughness: Nullable<number>;
  36336. /**
  36337. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  36338. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  36339. */
  36340. protected _microSurfaceTexture: BaseTexture;
  36341. /**
  36342. * Stores surface normal data used to displace a mesh in a texture.
  36343. */
  36344. protected _bumpTexture: BaseTexture;
  36345. /**
  36346. * Stores the pre-calculated light information of a mesh in a texture.
  36347. */
  36348. protected _lightmapTexture: BaseTexture;
  36349. /**
  36350. * The color of a material in ambient lighting.
  36351. */
  36352. protected _ambientColor: Color3;
  36353. /**
  36354. * AKA Diffuse Color in other nomenclature.
  36355. */
  36356. protected _albedoColor: Color3;
  36357. /**
  36358. * AKA Specular Color in other nomenclature.
  36359. */
  36360. protected _reflectivityColor: Color3;
  36361. /**
  36362. * The color applied when light is reflected from a material.
  36363. */
  36364. protected _reflectionColor: Color3;
  36365. /**
  36366. * The color applied when light is emitted from a material.
  36367. */
  36368. protected _emissiveColor: Color3;
  36369. /**
  36370. * AKA Glossiness in other nomenclature.
  36371. */
  36372. protected _microSurface: number;
  36373. /**
  36374. * source material index of refraction (IOR)' / 'destination material IOR.
  36375. */
  36376. protected _indexOfRefraction: number;
  36377. /**
  36378. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  36379. */
  36380. protected _invertRefractionY: boolean;
  36381. /**
  36382. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  36383. * Materials half opaque for instance using refraction could benefit from this control.
  36384. */
  36385. protected _linkRefractionWithTransparency: boolean;
  36386. /**
  36387. * Specifies that the material will use the light map as a show map.
  36388. */
  36389. protected _useLightmapAsShadowmap: boolean;
  36390. /**
  36391. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  36392. * makes the reflect vector face the model (under horizon).
  36393. */
  36394. protected _useHorizonOcclusion: boolean;
  36395. /**
  36396. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  36397. * too much the area relying on ambient texture to define their ambient occlusion.
  36398. */
  36399. protected _useRadianceOcclusion: boolean;
  36400. /**
  36401. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  36402. */
  36403. protected _useAlphaFromAlbedoTexture: boolean;
  36404. /**
  36405. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  36406. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  36407. */
  36408. protected _useSpecularOverAlpha: boolean;
  36409. /**
  36410. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  36411. */
  36412. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  36413. /**
  36414. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  36415. */
  36416. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  36417. /**
  36418. * Specifies if the metallic texture contains the roughness information in its green channel.
  36419. */
  36420. protected _useRoughnessFromMetallicTextureGreen: boolean;
  36421. /**
  36422. * Specifies if the metallic texture contains the metallness information in its blue channel.
  36423. */
  36424. protected _useMetallnessFromMetallicTextureBlue: boolean;
  36425. /**
  36426. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  36427. */
  36428. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  36429. /**
  36430. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  36431. */
  36432. protected _useAmbientInGrayScale: boolean;
  36433. /**
  36434. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  36435. * The material will try to infer what glossiness each pixel should be.
  36436. */
  36437. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  36438. /**
  36439. * Defines the falloff type used in this material.
  36440. * It by default is Physical.
  36441. */
  36442. protected _lightFalloff: number;
  36443. /**
  36444. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  36445. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  36446. */
  36447. protected _useRadianceOverAlpha: boolean;
  36448. /**
  36449. * Allows using an object space normal map (instead of tangent space).
  36450. */
  36451. protected _useObjectSpaceNormalMap: boolean;
  36452. /**
  36453. * Allows using the bump map in parallax mode.
  36454. */
  36455. protected _useParallax: boolean;
  36456. /**
  36457. * Allows using the bump map in parallax occlusion mode.
  36458. */
  36459. protected _useParallaxOcclusion: boolean;
  36460. /**
  36461. * Controls the scale bias of the parallax mode.
  36462. */
  36463. protected _parallaxScaleBias: number;
  36464. /**
  36465. * If sets to true, disables all the lights affecting the material.
  36466. */
  36467. protected _disableLighting: boolean;
  36468. /**
  36469. * Number of Simultaneous lights allowed on the material.
  36470. */
  36471. protected _maxSimultaneousLights: number;
  36472. /**
  36473. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  36474. */
  36475. protected _invertNormalMapX: boolean;
  36476. /**
  36477. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  36478. */
  36479. protected _invertNormalMapY: boolean;
  36480. /**
  36481. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  36482. */
  36483. protected _twoSidedLighting: boolean;
  36484. /**
  36485. * Defines the alpha limits in alpha test mode.
  36486. */
  36487. protected _alphaCutOff: number;
  36488. /**
  36489. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  36490. */
  36491. protected _forceAlphaTest: boolean;
  36492. /**
  36493. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  36494. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  36495. */
  36496. protected _useAlphaFresnel: boolean;
  36497. /**
  36498. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  36499. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  36500. */
  36501. protected _useLinearAlphaFresnel: boolean;
  36502. /**
  36503. * The transparency mode of the material.
  36504. */
  36505. protected _transparencyMode: Nullable<number>;
  36506. /**
  36507. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  36508. * from cos thetav and roughness:
  36509. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  36510. */
  36511. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  36512. /**
  36513. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  36514. */
  36515. protected _forceIrradianceInFragment: boolean;
  36516. /**
  36517. * Force normal to face away from face.
  36518. */
  36519. protected _forceNormalForward: boolean;
  36520. /**
  36521. * Enables specular anti aliasing in the PBR shader.
  36522. * It will both interacts on the Geometry for analytical and IBL lighting.
  36523. * It also prefilter the roughness map based on the bump values.
  36524. */
  36525. protected _enableSpecularAntiAliasing: boolean;
  36526. /**
  36527. * Default configuration related to image processing available in the PBR Material.
  36528. */
  36529. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36530. /**
  36531. * Keep track of the image processing observer to allow dispose and replace.
  36532. */
  36533. private _imageProcessingObserver;
  36534. /**
  36535. * Attaches a new image processing configuration to the PBR Material.
  36536. * @param configuration
  36537. */
  36538. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  36539. /**
  36540. * Stores the available render targets.
  36541. */
  36542. private _renderTargets;
  36543. /**
  36544. * Sets the global ambient color for the material used in lighting calculations.
  36545. */
  36546. private _globalAmbientColor;
  36547. /**
  36548. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  36549. */
  36550. private _useLogarithmicDepth;
  36551. /**
  36552. * If set to true, no lighting calculations will be applied.
  36553. */
  36554. private _unlit;
  36555. /**
  36556. * Instantiates a new PBRMaterial instance.
  36557. *
  36558. * @param name The material name
  36559. * @param scene The scene the material will be use in.
  36560. */
  36561. constructor(name: string, scene: Scene);
  36562. /**
  36563. * Gets a boolean indicating that current material needs to register RTT
  36564. */
  36565. readonly hasRenderTargetTextures: boolean;
  36566. /**
  36567. * Gets the name of the material class.
  36568. */
  36569. getClassName(): string;
  36570. /**
  36571. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  36572. */
  36573. /**
  36574. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  36575. */
  36576. useLogarithmicDepth: boolean;
  36577. /**
  36578. * Gets the current transparency mode.
  36579. */
  36580. /**
  36581. * Sets the transparency mode of the material.
  36582. *
  36583. * | Value | Type | Description |
  36584. * | ----- | ----------------------------------- | ----------- |
  36585. * | 0 | OPAQUE | |
  36586. * | 1 | ALPHATEST | |
  36587. * | 2 | ALPHABLEND | |
  36588. * | 3 | ALPHATESTANDBLEND | |
  36589. *
  36590. */
  36591. transparencyMode: Nullable<number>;
  36592. /**
  36593. * Returns true if alpha blending should be disabled.
  36594. */
  36595. private readonly _disableAlphaBlending;
  36596. /**
  36597. * Specifies whether or not this material should be rendered in alpha blend mode.
  36598. */
  36599. needAlphaBlending(): boolean;
  36600. /**
  36601. * Specifies if the mesh will require alpha blending.
  36602. * @param mesh - BJS mesh.
  36603. */
  36604. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  36605. /**
  36606. * Specifies whether or not this material should be rendered in alpha test mode.
  36607. */
  36608. needAlphaTesting(): boolean;
  36609. /**
  36610. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  36611. */
  36612. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  36613. /**
  36614. * Gets the texture used for the alpha test.
  36615. */
  36616. getAlphaTestTexture(): BaseTexture;
  36617. /**
  36618. * Stores the reflectivity values based on metallic roughness workflow.
  36619. */
  36620. private static _scaledReflectivity;
  36621. /**
  36622. * Specifies that the submesh is ready to be used.
  36623. * @param mesh - BJS mesh.
  36624. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  36625. * @param useInstances - Specifies that instances should be used.
  36626. * @returns - boolean indicating that the submesh is ready or not.
  36627. */
  36628. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  36629. /**
  36630. * Specifies if the material uses metallic roughness workflow.
  36631. * @returns boolean specifiying if the material uses metallic roughness workflow.
  36632. */
  36633. isMetallicWorkflow(): boolean;
  36634. private _prepareEffect;
  36635. private _prepareDefines;
  36636. /**
  36637. * Force shader compilation
  36638. */
  36639. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  36640. clipPlane: boolean;
  36641. }>): void;
  36642. /**
  36643. * Initializes the uniform buffer layout for the shader.
  36644. */
  36645. buildUniformLayout(): void;
  36646. /**
  36647. * Unbinds the textures.
  36648. */
  36649. unbind(): void;
  36650. /**
  36651. * Binds the submesh data.
  36652. * @param world - The world matrix.
  36653. * @param mesh - The BJS mesh.
  36654. * @param subMesh - A submesh of the BJS mesh.
  36655. */
  36656. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  36657. /**
  36658. * Returns the animatable textures.
  36659. * @returns - Array of animatable textures.
  36660. */
  36661. getAnimatables(): IAnimatable[];
  36662. /**
  36663. * Returns the texture used for reflections.
  36664. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  36665. */
  36666. private _getReflectionTexture;
  36667. /**
  36668. * Returns the texture used for refraction or null if none is used.
  36669. * @returns - Refection texture if present. If no refraction texture and refraction
  36670. * is linked with transparency, returns environment texture. Otherwise, returns null.
  36671. */
  36672. private _getRefractionTexture;
  36673. /**
  36674. * Disposes the resources of the material.
  36675. * @param forceDisposeEffect - Forces the disposal of effects.
  36676. * @param forceDisposeTextures - Forces the disposal of all textures.
  36677. */
  36678. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  36679. }
  36680. }
  36681. declare module BABYLON {
  36682. /**
  36683. * The Physically based simple base material of BJS.
  36684. *
  36685. * This enables better naming and convention enforcements on top of the pbrMaterial.
  36686. * It is used as the base class for both the specGloss and metalRough conventions.
  36687. */
  36688. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  36689. /**
  36690. * Number of Simultaneous lights allowed on the material.
  36691. */
  36692. maxSimultaneousLights: number;
  36693. /**
  36694. * If sets to true, disables all the lights affecting the material.
  36695. */
  36696. disableLighting: boolean;
  36697. /**
  36698. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  36699. */
  36700. environmentTexture: BaseTexture;
  36701. /**
  36702. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  36703. */
  36704. invertNormalMapX: boolean;
  36705. /**
  36706. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  36707. */
  36708. invertNormalMapY: boolean;
  36709. /**
  36710. * Normal map used in the model.
  36711. */
  36712. normalTexture: BaseTexture;
  36713. /**
  36714. * Emissivie color used to self-illuminate the model.
  36715. */
  36716. emissiveColor: Color3;
  36717. /**
  36718. * Emissivie texture used to self-illuminate the model.
  36719. */
  36720. emissiveTexture: BaseTexture;
  36721. /**
  36722. * Occlusion Channel Strenght.
  36723. */
  36724. occlusionStrength: number;
  36725. /**
  36726. * Occlusion Texture of the material (adding extra occlusion effects).
  36727. */
  36728. occlusionTexture: BaseTexture;
  36729. /**
  36730. * Defines the alpha limits in alpha test mode.
  36731. */
  36732. alphaCutOff: number;
  36733. /**
  36734. * Gets the current double sided mode.
  36735. */
  36736. /**
  36737. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  36738. */
  36739. doubleSided: boolean;
  36740. lightmapTexture: BaseTexture;
  36741. useLightmapAsShadowmap: boolean;
  36742. /**
  36743. * Return the active textures of the material.
  36744. */
  36745. getActiveTextures(): BaseTexture[];
  36746. hasTexture(texture: BaseTexture): boolean;
  36747. /**
  36748. * Instantiates a new PBRMaterial instance.
  36749. *
  36750. * @param name The material name
  36751. * @param scene The scene the material will be use in.
  36752. */
  36753. constructor(name: string, scene: Scene);
  36754. getClassName(): string;
  36755. }
  36756. }
  36757. declare module BABYLON {
  36758. /**
  36759. * The Physically based material of BJS.
  36760. *
  36761. * This offers the main features of a standard PBR material.
  36762. * For more information, please refer to the documentation :
  36763. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  36764. */
  36765. class PBRMaterial extends PBRBaseMaterial {
  36766. /**
  36767. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  36768. */
  36769. static readonly PBRMATERIAL_OPAQUE: number;
  36770. /**
  36771. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  36772. */
  36773. static readonly PBRMATERIAL_ALPHATEST: number;
  36774. /**
  36775. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  36776. */
  36777. static readonly PBRMATERIAL_ALPHABLEND: number;
  36778. /**
  36779. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  36780. * They are also discarded below the alpha cutoff threshold to improve performances.
  36781. */
  36782. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  36783. /**
  36784. * Defines the default value of how much AO map is occluding the analytical lights
  36785. * (point spot...).
  36786. */
  36787. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  36788. /**
  36789. * Intensity of the direct lights e.g. the four lights available in your scene.
  36790. * This impacts both the direct diffuse and specular highlights.
  36791. */
  36792. directIntensity: number;
  36793. /**
  36794. * Intensity of the emissive part of the material.
  36795. * This helps controlling the emissive effect without modifying the emissive color.
  36796. */
  36797. emissiveIntensity: number;
  36798. /**
  36799. * Intensity of the environment e.g. how much the environment will light the object
  36800. * either through harmonics for rough material or through the refelction for shiny ones.
  36801. */
  36802. environmentIntensity: number;
  36803. /**
  36804. * This is a special control allowing the reduction of the specular highlights coming from the
  36805. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  36806. */
  36807. specularIntensity: number;
  36808. /**
  36809. * Debug Control allowing disabling the bump map on this material.
  36810. */
  36811. disableBumpMap: boolean;
  36812. /**
  36813. * AKA Diffuse Texture in standard nomenclature.
  36814. */
  36815. albedoTexture: BaseTexture;
  36816. /**
  36817. * AKA Occlusion Texture in other nomenclature.
  36818. */
  36819. ambientTexture: BaseTexture;
  36820. /**
  36821. * AKA Occlusion Texture Intensity in other nomenclature.
  36822. */
  36823. ambientTextureStrength: number;
  36824. /**
  36825. * Defines how much the AO map is occluding the analytical lights (point spot...).
  36826. * 1 means it completely occludes it
  36827. * 0 mean it has no impact
  36828. */
  36829. ambientTextureImpactOnAnalyticalLights: number;
  36830. /**
  36831. * Stores the alpha values in a texture.
  36832. */
  36833. opacityTexture: BaseTexture;
  36834. /**
  36835. * Stores the reflection values in a texture.
  36836. */
  36837. reflectionTexture: Nullable<BaseTexture>;
  36838. /**
  36839. * Stores the emissive values in a texture.
  36840. */
  36841. emissiveTexture: BaseTexture;
  36842. /**
  36843. * AKA Specular texture in other nomenclature.
  36844. */
  36845. reflectivityTexture: BaseTexture;
  36846. /**
  36847. * Used to switch from specular/glossiness to metallic/roughness workflow.
  36848. */
  36849. metallicTexture: BaseTexture;
  36850. /**
  36851. * Specifies the metallic scalar of the metallic/roughness workflow.
  36852. * Can also be used to scale the metalness values of the metallic texture.
  36853. */
  36854. metallic: Nullable<number>;
  36855. /**
  36856. * Specifies the roughness scalar of the metallic/roughness workflow.
  36857. * Can also be used to scale the roughness values of the metallic texture.
  36858. */
  36859. roughness: Nullable<number>;
  36860. /**
  36861. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  36862. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  36863. */
  36864. microSurfaceTexture: BaseTexture;
  36865. /**
  36866. * Stores surface normal data used to displace a mesh in a texture.
  36867. */
  36868. bumpTexture: BaseTexture;
  36869. /**
  36870. * Stores the pre-calculated light information of a mesh in a texture.
  36871. */
  36872. lightmapTexture: BaseTexture;
  36873. /**
  36874. * Stores the refracted light information in a texture.
  36875. */
  36876. refractionTexture: BaseTexture;
  36877. /**
  36878. * The color of a material in ambient lighting.
  36879. */
  36880. ambientColor: Color3;
  36881. /**
  36882. * AKA Diffuse Color in other nomenclature.
  36883. */
  36884. albedoColor: Color3;
  36885. /**
  36886. * AKA Specular Color in other nomenclature.
  36887. */
  36888. reflectivityColor: Color3;
  36889. /**
  36890. * The color reflected from the material.
  36891. */
  36892. reflectionColor: Color3;
  36893. /**
  36894. * The color emitted from the material.
  36895. */
  36896. emissiveColor: Color3;
  36897. /**
  36898. * AKA Glossiness in other nomenclature.
  36899. */
  36900. microSurface: number;
  36901. /**
  36902. * source material index of refraction (IOR)' / 'destination material IOR.
  36903. */
  36904. indexOfRefraction: number;
  36905. /**
  36906. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  36907. */
  36908. invertRefractionY: boolean;
  36909. /**
  36910. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  36911. * Materials half opaque for instance using refraction could benefit from this control.
  36912. */
  36913. linkRefractionWithTransparency: boolean;
  36914. useLightmapAsShadowmap: boolean;
  36915. /**
  36916. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  36917. */
  36918. useAlphaFromAlbedoTexture: boolean;
  36919. /**
  36920. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  36921. */
  36922. forceAlphaTest: boolean;
  36923. /**
  36924. * Defines the alpha limits in alpha test mode.
  36925. */
  36926. alphaCutOff: number;
  36927. /**
  36928. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  36929. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  36930. */
  36931. useSpecularOverAlpha: boolean;
  36932. /**
  36933. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  36934. */
  36935. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  36936. /**
  36937. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  36938. */
  36939. useRoughnessFromMetallicTextureAlpha: boolean;
  36940. /**
  36941. * Specifies if the metallic texture contains the roughness information in its green channel.
  36942. */
  36943. useRoughnessFromMetallicTextureGreen: boolean;
  36944. /**
  36945. * Specifies if the metallic texture contains the metallness information in its blue channel.
  36946. */
  36947. useMetallnessFromMetallicTextureBlue: boolean;
  36948. /**
  36949. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  36950. */
  36951. useAmbientOcclusionFromMetallicTextureRed: boolean;
  36952. /**
  36953. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  36954. */
  36955. useAmbientInGrayScale: boolean;
  36956. /**
  36957. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  36958. * The material will try to infer what glossiness each pixel should be.
  36959. */
  36960. useAutoMicroSurfaceFromReflectivityMap: boolean;
  36961. /**
  36962. * BJS is using an harcoded light falloff based on a manually sets up range.
  36963. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  36964. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  36965. */
  36966. /**
  36967. * BJS is using an harcoded light falloff based on a manually sets up range.
  36968. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  36969. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  36970. */
  36971. usePhysicalLightFalloff: boolean;
  36972. /**
  36973. * In order to support the falloff compatibility with gltf, a special mode has been added
  36974. * to reproduce the gltf light falloff.
  36975. */
  36976. /**
  36977. * In order to support the falloff compatibility with gltf, a special mode has been added
  36978. * to reproduce the gltf light falloff.
  36979. */
  36980. useGLTFLightFalloff: boolean;
  36981. /**
  36982. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  36983. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  36984. */
  36985. useRadianceOverAlpha: boolean;
  36986. /**
  36987. * Allows using an object space normal map (instead of tangent space).
  36988. */
  36989. useObjectSpaceNormalMap: boolean;
  36990. /**
  36991. * Allows using the bump map in parallax mode.
  36992. */
  36993. useParallax: boolean;
  36994. /**
  36995. * Allows using the bump map in parallax occlusion mode.
  36996. */
  36997. useParallaxOcclusion: boolean;
  36998. /**
  36999. * Controls the scale bias of the parallax mode.
  37000. */
  37001. parallaxScaleBias: number;
  37002. /**
  37003. * If sets to true, disables all the lights affecting the material.
  37004. */
  37005. disableLighting: boolean;
  37006. /**
  37007. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  37008. */
  37009. forceIrradianceInFragment: boolean;
  37010. /**
  37011. * Number of Simultaneous lights allowed on the material.
  37012. */
  37013. maxSimultaneousLights: number;
  37014. /**
  37015. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  37016. */
  37017. invertNormalMapX: boolean;
  37018. /**
  37019. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  37020. */
  37021. invertNormalMapY: boolean;
  37022. /**
  37023. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  37024. */
  37025. twoSidedLighting: boolean;
  37026. /**
  37027. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  37028. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  37029. */
  37030. useAlphaFresnel: boolean;
  37031. /**
  37032. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  37033. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  37034. */
  37035. useLinearAlphaFresnel: boolean;
  37036. /**
  37037. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  37038. * And/Or occlude the blended part.
  37039. */
  37040. environmentBRDFTexture: Nullable<BaseTexture>;
  37041. /**
  37042. * Force normal to face away from face.
  37043. */
  37044. forceNormalForward: boolean;
  37045. /**
  37046. * Enables specular anti aliasing in the PBR shader.
  37047. * It will both interacts on the Geometry for analytical and IBL lighting.
  37048. * It also prefilter the roughness map based on the bump values.
  37049. */
  37050. enableSpecularAntiAliasing: boolean;
  37051. /**
  37052. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  37053. * makes the reflect vector face the model (under horizon).
  37054. */
  37055. useHorizonOcclusion: boolean;
  37056. /**
  37057. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  37058. * too much the area relying on ambient texture to define their ambient occlusion.
  37059. */
  37060. useRadianceOcclusion: boolean;
  37061. /**
  37062. * If set to true, no lighting calculations will be applied.
  37063. */
  37064. unlit: boolean;
  37065. /**
  37066. * Gets the image processing configuration used either in this material.
  37067. */
  37068. /**
  37069. * Sets the Default image processing configuration used either in the this material.
  37070. *
  37071. * If sets to null, the scene one is in use.
  37072. */
  37073. imageProcessingConfiguration: ImageProcessingConfiguration;
  37074. /**
  37075. * Gets wether the color curves effect is enabled.
  37076. */
  37077. /**
  37078. * Sets wether the color curves effect is enabled.
  37079. */
  37080. cameraColorCurvesEnabled: boolean;
  37081. /**
  37082. * Gets wether the color grading effect is enabled.
  37083. */
  37084. /**
  37085. * Gets wether the color grading effect is enabled.
  37086. */
  37087. cameraColorGradingEnabled: boolean;
  37088. /**
  37089. * Gets wether tonemapping is enabled or not.
  37090. */
  37091. /**
  37092. * Sets wether tonemapping is enabled or not
  37093. */
  37094. cameraToneMappingEnabled: boolean;
  37095. /**
  37096. * The camera exposure used on this material.
  37097. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37098. * This corresponds to a photographic exposure.
  37099. */
  37100. /**
  37101. * The camera exposure used on this material.
  37102. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37103. * This corresponds to a photographic exposure.
  37104. */
  37105. cameraExposure: number;
  37106. /**
  37107. * Gets The camera contrast used on this material.
  37108. */
  37109. /**
  37110. * Sets The camera contrast used on this material.
  37111. */
  37112. cameraContrast: number;
  37113. /**
  37114. * Gets the Color Grading 2D Lookup Texture.
  37115. */
  37116. /**
  37117. * Sets the Color Grading 2D Lookup Texture.
  37118. */
  37119. cameraColorGradingTexture: Nullable<BaseTexture>;
  37120. /**
  37121. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37122. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37123. * 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;
  37124. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37125. */
  37126. /**
  37127. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37128. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37129. * 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;
  37130. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37131. */
  37132. cameraColorCurves: Nullable<ColorCurves>;
  37133. /**
  37134. * Instantiates a new PBRMaterial instance.
  37135. *
  37136. * @param name The material name
  37137. * @param scene The scene the material will be use in.
  37138. */
  37139. constructor(name: string, scene: Scene);
  37140. /**
  37141. * Returns the name of this material class.
  37142. */
  37143. getClassName(): string;
  37144. /**
  37145. * Returns an array of the actively used textures.
  37146. * @returns - Array of BaseTextures
  37147. */
  37148. getActiveTextures(): BaseTexture[];
  37149. /**
  37150. * Checks to see if a texture is used in the material.
  37151. * @param texture - Base texture to use.
  37152. * @returns - Boolean specifying if a texture is used in the material.
  37153. */
  37154. hasTexture(texture: BaseTexture): boolean;
  37155. /**
  37156. * Makes a duplicate of the current material.
  37157. * @param name - name to use for the new material.
  37158. */
  37159. clone(name: string): PBRMaterial;
  37160. /**
  37161. * Serializes this PBR Material.
  37162. * @returns - An object with the serialized material.
  37163. */
  37164. serialize(): any;
  37165. /**
  37166. * Parses a PBR Material from a serialized object.
  37167. * @param source - Serialized object.
  37168. * @param scene - BJS scene instance.
  37169. * @param rootUrl - url for the scene object
  37170. * @returns - PBRMaterial
  37171. */
  37172. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  37173. }
  37174. }
  37175. declare module BABYLON {
  37176. /**
  37177. * The PBR material of BJS following the metal roughness convention.
  37178. *
  37179. * This fits to the PBR convention in the GLTF definition:
  37180. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  37181. */
  37182. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  37183. /**
  37184. * The base color has two different interpretations depending on the value of metalness.
  37185. * When the material is a metal, the base color is the specific measured reflectance value
  37186. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  37187. * of the material.
  37188. */
  37189. baseColor: Color3;
  37190. /**
  37191. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  37192. * well as opacity information in the alpha channel.
  37193. */
  37194. baseTexture: BaseTexture;
  37195. /**
  37196. * Specifies the metallic scalar value of the material.
  37197. * Can also be used to scale the metalness values of the metallic texture.
  37198. */
  37199. metallic: number;
  37200. /**
  37201. * Specifies the roughness scalar value of the material.
  37202. * Can also be used to scale the roughness values of the metallic texture.
  37203. */
  37204. roughness: number;
  37205. /**
  37206. * Texture containing both the metallic value in the B channel and the
  37207. * roughness value in the G channel to keep better precision.
  37208. */
  37209. metallicRoughnessTexture: BaseTexture;
  37210. /**
  37211. * Instantiates a new PBRMetalRoughnessMaterial instance.
  37212. *
  37213. * @param name The material name
  37214. * @param scene The scene the material will be use in.
  37215. */
  37216. constructor(name: string, scene: Scene);
  37217. /**
  37218. * Return the currrent class name of the material.
  37219. */
  37220. getClassName(): string;
  37221. /**
  37222. * Return the active textures of the material.
  37223. */
  37224. getActiveTextures(): BaseTexture[];
  37225. /**
  37226. * Checks to see if a texture is used in the material.
  37227. * @param texture - Base texture to use.
  37228. * @returns - Boolean specifying if a texture is used in the material.
  37229. */
  37230. hasTexture(texture: BaseTexture): boolean;
  37231. /**
  37232. * Makes a duplicate of the current material.
  37233. * @param name - name to use for the new material.
  37234. */
  37235. clone(name: string): PBRMetallicRoughnessMaterial;
  37236. /**
  37237. * Serialize the material to a parsable JSON object.
  37238. */
  37239. serialize(): any;
  37240. /**
  37241. * Parses a JSON object correponding to the serialize function.
  37242. */
  37243. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  37244. }
  37245. }
  37246. declare module BABYLON {
  37247. /**
  37248. * The PBR material of BJS following the specular glossiness convention.
  37249. *
  37250. * This fits to the PBR convention in the GLTF definition:
  37251. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  37252. */
  37253. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  37254. /**
  37255. * Specifies the diffuse color of the material.
  37256. */
  37257. diffuseColor: Color3;
  37258. /**
  37259. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  37260. * channel.
  37261. */
  37262. diffuseTexture: BaseTexture;
  37263. /**
  37264. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  37265. */
  37266. specularColor: Color3;
  37267. /**
  37268. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  37269. */
  37270. glossiness: number;
  37271. /**
  37272. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  37273. */
  37274. specularGlossinessTexture: BaseTexture;
  37275. /**
  37276. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  37277. *
  37278. * @param name The material name
  37279. * @param scene The scene the material will be use in.
  37280. */
  37281. constructor(name: string, scene: Scene);
  37282. /**
  37283. * Return the currrent class name of the material.
  37284. */
  37285. getClassName(): string;
  37286. /**
  37287. * Return the active textures of the material.
  37288. */
  37289. getActiveTextures(): BaseTexture[];
  37290. /**
  37291. * Checks to see if a texture is used in the material.
  37292. * @param texture - Base texture to use.
  37293. * @returns - Boolean specifying if a texture is used in the material.
  37294. */
  37295. hasTexture(texture: BaseTexture): boolean;
  37296. /**
  37297. * Makes a duplicate of the current material.
  37298. * @param name - name to use for the new material.
  37299. */
  37300. clone(name: string): PBRSpecularGlossinessMaterial;
  37301. /**
  37302. * Serialize the material to a parsable JSON object.
  37303. */
  37304. serialize(): any;
  37305. /**
  37306. * Parses a JSON object correponding to the serialize function.
  37307. */
  37308. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  37309. }
  37310. }
  37311. declare module BABYLON {
  37312. class BaseTexture {
  37313. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  37314. name: string;
  37315. private _hasAlpha;
  37316. hasAlpha: boolean;
  37317. getAlphaFromRGB: boolean;
  37318. level: number;
  37319. coordinatesIndex: number;
  37320. private _coordinatesMode;
  37321. /**
  37322. * How a texture is mapped.
  37323. *
  37324. * | Value | Type | Description |
  37325. * | ----- | ----------------------------------- | ----------- |
  37326. * | 0 | EXPLICIT_MODE | |
  37327. * | 1 | SPHERICAL_MODE | |
  37328. * | 2 | PLANAR_MODE | |
  37329. * | 3 | CUBIC_MODE | |
  37330. * | 4 | PROJECTION_MODE | |
  37331. * | 5 | SKYBOX_MODE | |
  37332. * | 6 | INVCUBIC_MODE | |
  37333. * | 7 | EQUIRECTANGULAR_MODE | |
  37334. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  37335. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  37336. */
  37337. coordinatesMode: number;
  37338. /**
  37339. * | Value | Type | Description |
  37340. * | ----- | ------------------ | ----------- |
  37341. * | 0 | CLAMP_ADDRESSMODE | |
  37342. * | 1 | WRAP_ADDRESSMODE | |
  37343. * | 2 | MIRROR_ADDRESSMODE | |
  37344. */
  37345. wrapU: number;
  37346. /**
  37347. * | Value | Type | Description |
  37348. * | ----- | ------------------ | ----------- |
  37349. * | 0 | CLAMP_ADDRESSMODE | |
  37350. * | 1 | WRAP_ADDRESSMODE | |
  37351. * | 2 | MIRROR_ADDRESSMODE | |
  37352. */
  37353. wrapV: number;
  37354. /**
  37355. * | Value | Type | Description |
  37356. * | ----- | ------------------ | ----------- |
  37357. * | 0 | CLAMP_ADDRESSMODE | |
  37358. * | 1 | WRAP_ADDRESSMODE | |
  37359. * | 2 | MIRROR_ADDRESSMODE | |
  37360. */
  37361. wrapR: number;
  37362. anisotropicFilteringLevel: number;
  37363. isCube: boolean;
  37364. is3D: boolean;
  37365. gammaSpace: boolean;
  37366. /**
  37367. * Gets whether or not the texture contains RGBD data.
  37368. */
  37369. readonly isRGBD: boolean;
  37370. invertZ: boolean;
  37371. lodLevelInAlpha: boolean;
  37372. lodGenerationOffset: number;
  37373. lodGenerationScale: number;
  37374. isRenderTarget: boolean;
  37375. readonly uid: string;
  37376. toString(): string;
  37377. getClassName(): string;
  37378. animations: Animation[];
  37379. /**
  37380. * An event triggered when the texture is disposed.
  37381. */
  37382. onDisposeObservable: Observable<BaseTexture>;
  37383. private _onDisposeObserver;
  37384. onDispose: () => void;
  37385. delayLoadState: number;
  37386. private _scene;
  37387. /** @hidden */
  37388. _texture: Nullable<InternalTexture>;
  37389. private _uid;
  37390. readonly isBlocking: boolean;
  37391. constructor(scene: Nullable<Scene>);
  37392. getScene(): Nullable<Scene>;
  37393. getTextureMatrix(): Matrix;
  37394. getReflectionTextureMatrix(): Matrix;
  37395. getInternalTexture(): Nullable<InternalTexture>;
  37396. isReadyOrNotBlocking(): boolean;
  37397. isReady(): boolean;
  37398. private _cachedSize;
  37399. getSize(): ISize;
  37400. getBaseSize(): ISize;
  37401. scale(ratio: number): void;
  37402. readonly canRescale: boolean;
  37403. /** @hidden */
  37404. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  37405. /** @hidden */
  37406. _rebuild(): void;
  37407. delayLoad(): void;
  37408. clone(): Nullable<BaseTexture>;
  37409. readonly textureType: number;
  37410. readonly textureFormat: number;
  37411. /**
  37412. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  37413. * This will returns an RGBA array buffer containing either in values (0-255) or
  37414. * float values (0-1) depending of the underlying buffer type.
  37415. * @param faceIndex The face of the texture to read (in case of cube texture)
  37416. * @param level The LOD level of the texture to read (in case of Mip Maps)
  37417. * @returns The Array buffer containing the pixels data.
  37418. */
  37419. readPixels(faceIndex?: number, level?: number): Nullable<ArrayBufferView>;
  37420. releaseInternalTexture(): void;
  37421. sphericalPolynomial: Nullable<SphericalPolynomial>;
  37422. readonly _lodTextureHigh: Nullable<BaseTexture>;
  37423. readonly _lodTextureMid: Nullable<BaseTexture>;
  37424. readonly _lodTextureLow: Nullable<BaseTexture>;
  37425. dispose(): void;
  37426. serialize(): any;
  37427. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  37428. }
  37429. }
  37430. declare module BABYLON {
  37431. /**
  37432. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  37433. * It can help converting any input color in a desired output one. This can then be used to create effects
  37434. * from sepia, black and white to sixties or futuristic rendering...
  37435. *
  37436. * The only supported format is currently 3dl.
  37437. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  37438. */
  37439. class ColorGradingTexture extends BaseTexture {
  37440. /**
  37441. * The current texture matrix. (will always be identity in color grading texture)
  37442. */
  37443. private _textureMatrix;
  37444. /**
  37445. * The texture URL.
  37446. */
  37447. url: string;
  37448. /**
  37449. * Empty line regex stored for GC.
  37450. */
  37451. private static _noneEmptyLineRegex;
  37452. private _engine;
  37453. /**
  37454. * Instantiates a ColorGradingTexture from the following parameters.
  37455. *
  37456. * @param url The location of the color gradind data (currently only supporting 3dl)
  37457. * @param scene The scene the texture will be used in
  37458. */
  37459. constructor(url: string, scene: Scene);
  37460. /**
  37461. * Returns the texture matrix used in most of the material.
  37462. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  37463. */
  37464. getTextureMatrix(): Matrix;
  37465. /**
  37466. * Occurs when the file being loaded is a .3dl LUT file.
  37467. */
  37468. private load3dlTexture;
  37469. /**
  37470. * Starts the loading process of the texture.
  37471. */
  37472. private loadTexture;
  37473. /**
  37474. * Clones the color gradind texture.
  37475. */
  37476. clone(): ColorGradingTexture;
  37477. /**
  37478. * Called during delayed load for textures.
  37479. */
  37480. delayLoad(): void;
  37481. /**
  37482. * Parses a color grading texture serialized by Babylon.
  37483. * @param parsedTexture The texture information being parsedTexture
  37484. * @param scene The scene to load the texture in
  37485. * @param rootUrl The root url of the data assets to load
  37486. * @return A color gradind texture
  37487. */
  37488. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  37489. /**
  37490. * Serializes the LUT texture to json format.
  37491. */
  37492. serialize(): any;
  37493. }
  37494. }
  37495. declare module BABYLON {
  37496. class CubeTexture extends BaseTexture {
  37497. url: string;
  37498. /**
  37499. * Gets or sets the center of the bounding box associated with the cube texture
  37500. * It must define where the camera used to render the texture was set
  37501. */
  37502. boundingBoxPosition: Vector3;
  37503. private _boundingBoxSize;
  37504. /**
  37505. * Gets or sets the size of the bounding box associated with the cube texture
  37506. * When defined, the cubemap will switch to local mode
  37507. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37508. * @example https://www.babylonjs-playground.com/#RNASML
  37509. */
  37510. boundingBoxSize: Vector3;
  37511. protected _rotationY: number;
  37512. /**
  37513. * Sets texture matrix rotation angle around Y axis in radians.
  37514. */
  37515. /**
  37516. * Gets texture matrix rotation angle around Y axis radians.
  37517. */
  37518. rotationY: number;
  37519. private _noMipmap;
  37520. private _files;
  37521. private _extensions;
  37522. private _textureMatrix;
  37523. private _format;
  37524. private _createPolynomials;
  37525. /** @hidden */
  37526. readonly _prefiltered: boolean;
  37527. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  37528. /**
  37529. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  37530. * @param url defines the url of the prefiltered texture
  37531. * @param scene defines the scene the texture is attached to
  37532. * @param forcedExtension defines the extension of the file if different from the url
  37533. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  37534. * @return the prefiltered texture
  37535. */
  37536. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  37537. /**
  37538. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  37539. * as prefiltered data.
  37540. * @param rootUrl defines the url of the texture or the root name of the six images
  37541. * @param scene defines the scene the texture is attached to
  37542. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  37543. * @param noMipmap defines if mipmaps should be created or not
  37544. * @param files defines the six files to load for the different faces
  37545. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  37546. * @param onError defines a callback triggered in case of error during load
  37547. * @param format defines the internal format to use for the texture once loaded
  37548. * @param prefiltered defines whether or not the texture is created from prefiltered data
  37549. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  37550. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  37551. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  37552. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  37553. * @return the cube texture
  37554. */
  37555. 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);
  37556. delayLoad(): void;
  37557. getReflectionTextureMatrix(): Matrix;
  37558. setReflectionTextureMatrix(value: Matrix): void;
  37559. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  37560. clone(): CubeTexture;
  37561. }
  37562. }
  37563. declare module BABYLON {
  37564. /**
  37565. * A class extending {BABYLON.Texture} allowing drawing on a texture
  37566. * @see http://doc.babylonjs.com/how_to/dynamictexture
  37567. */
  37568. class DynamicTexture extends Texture {
  37569. private _generateMipMaps;
  37570. private _canvas;
  37571. private _context;
  37572. private _engine;
  37573. /**
  37574. * Creates a {BABYLON.DynamicTexture}
  37575. * @param name defines the name of the texture
  37576. * @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
  37577. * @param scene defines the scene where you want the texture
  37578. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  37579. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37580. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  37581. */
  37582. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  37583. /**
  37584. * Gets the current state of canRescale
  37585. */
  37586. readonly canRescale: boolean;
  37587. private _recreate;
  37588. /**
  37589. * Scales the texture
  37590. * @param ratio the scale factor to apply to both width and height
  37591. */
  37592. scale(ratio: number): void;
  37593. /**
  37594. * Resizes the texture
  37595. * @param width the new width
  37596. * @param height the new height
  37597. */
  37598. scaleTo(width: number, height: number): void;
  37599. /**
  37600. * Gets the context of the canvas used by the texture
  37601. * @returns the canvas context of the dynamic texture
  37602. */
  37603. getContext(): CanvasRenderingContext2D;
  37604. /**
  37605. * Clears the texture
  37606. */
  37607. clear(): void;
  37608. /**
  37609. * Updates the texture
  37610. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37611. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  37612. */
  37613. update(invertY?: boolean, premulAlpha?: boolean): void;
  37614. /**
  37615. * Draws text onto the texture
  37616. * @param text defines the text to be drawn
  37617. * @param x defines the placement of the text from the left
  37618. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  37619. * @param font defines the font to be used with font-style, font-size, font-name
  37620. * @param color defines the color used for the text
  37621. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  37622. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37623. * @param update defines whether texture is immediately update (default is true)
  37624. */
  37625. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  37626. /**
  37627. * Clones the texture
  37628. * @returns the clone of the texture.
  37629. */
  37630. clone(): DynamicTexture;
  37631. /**
  37632. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  37633. * @returns a serialized dynamic texture object
  37634. */
  37635. serialize(): any;
  37636. /** @hidden */
  37637. _rebuild(): void;
  37638. }
  37639. }
  37640. declare module BABYLON {
  37641. /**
  37642. * This represents a texture coming from an HDR input.
  37643. *
  37644. * The only supported format is currently panorama picture stored in RGBE format.
  37645. * Example of such files can be found on HDRLib: http://hdrlib.com/
  37646. */
  37647. class HDRCubeTexture extends BaseTexture {
  37648. private static _facesMapping;
  37649. private _generateHarmonics;
  37650. private _noMipmap;
  37651. private _textureMatrix;
  37652. private _size;
  37653. private _onLoad;
  37654. private _onError;
  37655. /**
  37656. * The texture URL.
  37657. */
  37658. url: string;
  37659. /**
  37660. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  37661. */
  37662. coordinatesMode: number;
  37663. protected _isBlocking: boolean;
  37664. /**
  37665. * Sets wether or not the texture is blocking during loading.
  37666. */
  37667. /**
  37668. * Gets wether or not the texture is blocking during loading.
  37669. */
  37670. isBlocking: boolean;
  37671. protected _rotationY: number;
  37672. /**
  37673. * Sets texture matrix rotation angle around Y axis in radians.
  37674. */
  37675. /**
  37676. * Gets texture matrix rotation angle around Y axis radians.
  37677. */
  37678. rotationY: number;
  37679. /**
  37680. * Gets or sets the center of the bounding box associated with the cube texture
  37681. * It must define where the camera used to render the texture was set
  37682. */
  37683. boundingBoxPosition: Vector3;
  37684. private _boundingBoxSize;
  37685. /**
  37686. * Gets or sets the size of the bounding box associated with the cube texture
  37687. * When defined, the cubemap will switch to local mode
  37688. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37689. * @example https://www.babylonjs-playground.com/#RNASML
  37690. */
  37691. boundingBoxSize: Vector3;
  37692. /**
  37693. * Instantiates an HDRTexture from the following parameters.
  37694. *
  37695. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  37696. * @param scene The scene the texture will be used in
  37697. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  37698. * @param noMipmap Forces to not generate the mipmap if true
  37699. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  37700. * @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)
  37701. * @param reserved Reserved flag for internal use.
  37702. */
  37703. 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>);
  37704. /**
  37705. * Occurs when the file is raw .hdr file.
  37706. */
  37707. private loadTexture;
  37708. clone(): HDRCubeTexture;
  37709. delayLoad(): void;
  37710. getReflectionTextureMatrix(): Matrix;
  37711. setReflectionTextureMatrix(value: Matrix): void;
  37712. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  37713. serialize(): any;
  37714. }
  37715. }
  37716. declare module BABYLON {
  37717. /**
  37718. * Class used to store data associated with WebGL texture data for the engine
  37719. * This class should not be used directly
  37720. */
  37721. class InternalTexture implements IInternalTextureTracker {
  37722. /**
  37723. * The source of the texture data is unknown
  37724. */
  37725. static DATASOURCE_UNKNOWN: number;
  37726. /**
  37727. * Texture data comes from an URL
  37728. */
  37729. static DATASOURCE_URL: number;
  37730. /**
  37731. * Texture data is only used for temporary storage
  37732. */
  37733. static DATASOURCE_TEMP: number;
  37734. /**
  37735. * Texture data comes from raw data (ArrayBuffer)
  37736. */
  37737. static DATASOURCE_RAW: number;
  37738. /**
  37739. * Texture content is dynamic (video or dynamic texture)
  37740. */
  37741. static DATASOURCE_DYNAMIC: number;
  37742. /**
  37743. * Texture content is generated by rendering to it
  37744. */
  37745. static DATASOURCE_RENDERTARGET: number;
  37746. /**
  37747. * Texture content is part of a multi render target process
  37748. */
  37749. static DATASOURCE_MULTIRENDERTARGET: number;
  37750. /**
  37751. * Texture data comes from a cube data file
  37752. */
  37753. static DATASOURCE_CUBE: number;
  37754. /**
  37755. * Texture data comes from a raw cube data
  37756. */
  37757. static DATASOURCE_CUBERAW: number;
  37758. /**
  37759. * Texture data come from a prefiltered cube data file
  37760. */
  37761. static DATASOURCE_CUBEPREFILTERED: number;
  37762. /**
  37763. * Texture content is raw 3D data
  37764. */
  37765. static DATASOURCE_RAW3D: number;
  37766. /**
  37767. * Texture content is a depth texture
  37768. */
  37769. static DATASOURCE_DEPTHTEXTURE: number;
  37770. /**
  37771. * Texture data comes from a raw cube data encoded with RGBD
  37772. */
  37773. static DATASOURCE_CUBERAW_RGBD: number;
  37774. /**
  37775. * Defines if the texture is ready
  37776. */
  37777. isReady: boolean;
  37778. /**
  37779. * Defines if the texture is a cube texture
  37780. */
  37781. isCube: boolean;
  37782. /**
  37783. * Defines if the texture contains 3D data
  37784. */
  37785. is3D: boolean;
  37786. /**
  37787. * Gets the URL used to load this texture
  37788. */
  37789. url: string;
  37790. /**
  37791. * Gets the sampling mode of the texture
  37792. */
  37793. samplingMode: number;
  37794. /**
  37795. * Gets a boolean indicating if the texture needs mipmaps generation
  37796. */
  37797. generateMipMaps: boolean;
  37798. /**
  37799. * Gets the number of samples used by the texture (WebGL2+ only)
  37800. */
  37801. samples: number;
  37802. /**
  37803. * Gets the type of the texture
  37804. */
  37805. type: number;
  37806. /**
  37807. * Gets the format of the texture
  37808. */
  37809. format: number;
  37810. /**
  37811. * Observable called when the texture is loaded
  37812. */
  37813. onLoadedObservable: Observable<InternalTexture>;
  37814. /**
  37815. * Gets the width of the texture
  37816. */
  37817. width: number;
  37818. /**
  37819. * Gets the height of the texture
  37820. */
  37821. height: number;
  37822. /**
  37823. * Gets the depth of the texture
  37824. */
  37825. depth: number;
  37826. /**
  37827. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37828. */
  37829. baseWidth: number;
  37830. /**
  37831. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37832. */
  37833. baseHeight: number;
  37834. /**
  37835. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37836. */
  37837. baseDepth: number;
  37838. /**
  37839. * Gets a boolean indicating if the texture is inverted on Y axis
  37840. */
  37841. invertY: boolean;
  37842. /**
  37843. * Gets or set the previous tracker in the list
  37844. */
  37845. previous: Nullable<IInternalTextureTracker>;
  37846. /**
  37847. * Gets or set the next tracker in the list
  37848. */
  37849. next: Nullable<IInternalTextureTracker>;
  37850. /** @hidden */
  37851. _initialSlot: number;
  37852. /** @hidden */
  37853. _designatedSlot: number;
  37854. /** @hidden */
  37855. _dataSource: number;
  37856. /** @hidden */
  37857. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  37858. /** @hidden */
  37859. _bufferView: Nullable<ArrayBufferView>;
  37860. /** @hidden */
  37861. _bufferViewArray: Nullable<ArrayBufferView[]>;
  37862. /** @hidden */
  37863. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  37864. /** @hidden */
  37865. _size: number;
  37866. /** @hidden */
  37867. _extension: string;
  37868. /** @hidden */
  37869. _files: Nullable<string[]>;
  37870. /** @hidden */
  37871. _workingCanvas: HTMLCanvasElement;
  37872. /** @hidden */
  37873. _workingContext: CanvasRenderingContext2D;
  37874. /** @hidden */
  37875. _framebuffer: Nullable<WebGLFramebuffer>;
  37876. /** @hidden */
  37877. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  37878. /** @hidden */
  37879. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  37880. /** @hidden */
  37881. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  37882. /** @hidden */
  37883. _attachments: Nullable<number[]>;
  37884. /** @hidden */
  37885. _cachedCoordinatesMode: Nullable<number>;
  37886. /** @hidden */
  37887. _cachedWrapU: Nullable<number>;
  37888. /** @hidden */
  37889. _cachedWrapV: Nullable<number>;
  37890. /** @hidden */
  37891. _cachedWrapR: Nullable<number>;
  37892. /** @hidden */
  37893. _cachedAnisotropicFilteringLevel: Nullable<number>;
  37894. /** @hidden */
  37895. _isDisabled: boolean;
  37896. /** @hidden */
  37897. _compression: Nullable<string>;
  37898. /** @hidden */
  37899. _generateStencilBuffer: boolean;
  37900. /** @hidden */
  37901. _generateDepthBuffer: boolean;
  37902. /** @hidden */
  37903. _comparisonFunction: number;
  37904. /** @hidden */
  37905. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  37906. /** @hidden */
  37907. _lodGenerationScale: number;
  37908. /** @hidden */
  37909. _lodGenerationOffset: number;
  37910. /** @hidden */
  37911. _lodTextureHigh: BaseTexture;
  37912. /** @hidden */
  37913. _lodTextureMid: BaseTexture;
  37914. /** @hidden */
  37915. _lodTextureLow: BaseTexture;
  37916. /** @hidden */
  37917. _isRGBD: boolean;
  37918. /** @hidden */
  37919. _webGLTexture: Nullable<WebGLTexture>;
  37920. /** @hidden */
  37921. _references: number;
  37922. private _engine;
  37923. /**
  37924. * Gets the Engine the texture belongs to.
  37925. * @returns The babylon engine
  37926. */
  37927. getEngine(): Engine;
  37928. /**
  37929. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  37930. */
  37931. readonly dataSource: number;
  37932. /**
  37933. * Creates a new InternalTexture
  37934. * @param engine defines the engine to use
  37935. * @param dataSource defines the type of data that will be used
  37936. */
  37937. constructor(engine: Engine, dataSource: number);
  37938. /**
  37939. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  37940. */
  37941. incrementReferences(): void;
  37942. /**
  37943. * Change the size of the texture (not the size of the content)
  37944. * @param width defines the new width
  37945. * @param height defines the new height
  37946. * @param depth defines the new depth (1 by default)
  37947. */
  37948. updateSize(width: int, height: int, depth?: int): void;
  37949. /** @hidden */
  37950. _rebuild(): void;
  37951. /** @hidden */
  37952. _swapAndDie(target: InternalTexture): void;
  37953. /**
  37954. * Dispose the current allocated resources
  37955. */
  37956. dispose(): void;
  37957. }
  37958. }
  37959. declare module BABYLON {
  37960. /**
  37961. * This represents the required contract to create a new type of texture loader.
  37962. */
  37963. interface IInternalTextureLoader {
  37964. /**
  37965. * Defines wether the loader supports cascade loading the different faces.
  37966. */
  37967. supportCascades: boolean;
  37968. /**
  37969. * This returns if the loader support the current file information.
  37970. * @param extension defines the file extension of the file being loaded
  37971. * @param textureFormatInUse defines the current compressed format in use iun the engine
  37972. * @param fallback defines the fallback internal texture if any
  37973. * @param isBase64 defines whether the texture is encoded as a base64
  37974. * @param isBuffer defines whether the texture data are stored as a buffer
  37975. * @returns true if the loader can load the specified file
  37976. */
  37977. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  37978. /**
  37979. * Transform the url before loading if required.
  37980. * @param rootUrl the url of the texture
  37981. * @param textureFormatInUse defines the current compressed format in use iun the engine
  37982. * @returns the transformed texture
  37983. */
  37984. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  37985. /**
  37986. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  37987. * @param rootUrl the url of the texture
  37988. * @param textureFormatInUse defines the current compressed format in use iun the engine
  37989. * @returns the fallback texture
  37990. */
  37991. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  37992. /**
  37993. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  37994. * @param data contains the texture data
  37995. * @param texture defines the BabylonJS internal texture
  37996. * @param createPolynomials will be true if polynomials have been requested
  37997. * @param onLoad defines the callback to trigger once the texture is ready
  37998. * @param onError defines the callback to trigger in case of error
  37999. */
  38000. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  38001. /**
  38002. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  38003. * @param data contains the texture data
  38004. * @param texture defines the BabylonJS internal texture
  38005. * @param callback defines the method to call once ready to upload
  38006. */
  38007. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  38008. }
  38009. }
  38010. declare module BABYLON {
  38011. /**
  38012. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  38013. */
  38014. interface IInternalTextureTracker {
  38015. /**
  38016. * Gets or set the previous tracker in the list
  38017. */
  38018. previous: Nullable<IInternalTextureTracker>;
  38019. /**
  38020. * Gets or set the next tracker in the list
  38021. */
  38022. next: Nullable<IInternalTextureTracker>;
  38023. }
  38024. /**
  38025. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  38026. */
  38027. class DummyInternalTextureTracker {
  38028. /**
  38029. * Gets or set the previous tracker in the list
  38030. */
  38031. previous: Nullable<IInternalTextureTracker>;
  38032. /**
  38033. * Gets or set the next tracker in the list
  38034. */
  38035. next: Nullable<IInternalTextureTracker>;
  38036. }
  38037. }
  38038. declare module BABYLON {
  38039. class MirrorTexture extends RenderTargetTexture {
  38040. private scene;
  38041. mirrorPlane: Plane;
  38042. private _transformMatrix;
  38043. private _mirrorMatrix;
  38044. private _savedViewMatrix;
  38045. private _blurX;
  38046. private _blurY;
  38047. private _adaptiveBlurKernel;
  38048. private _blurKernelX;
  38049. private _blurKernelY;
  38050. private _blurRatio;
  38051. blurRatio: number;
  38052. adaptiveBlurKernel: number;
  38053. blurKernel: number;
  38054. blurKernelX: number;
  38055. blurKernelY: number;
  38056. private _autoComputeBlurKernel;
  38057. protected _onRatioRescale(): void;
  38058. private _updateGammaSpace;
  38059. private _imageProcessingConfigChangeObserver;
  38060. constructor(name: string, size: number | {
  38061. width: number;
  38062. height: number;
  38063. } | {
  38064. ratio: number;
  38065. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  38066. private _preparePostProcesses;
  38067. clone(): MirrorTexture;
  38068. serialize(): any;
  38069. dispose(): void;
  38070. }
  38071. }
  38072. declare module BABYLON {
  38073. interface IMultiRenderTargetOptions {
  38074. generateMipMaps?: boolean;
  38075. types?: number[];
  38076. samplingModes?: number[];
  38077. generateDepthBuffer?: boolean;
  38078. generateStencilBuffer?: boolean;
  38079. generateDepthTexture?: boolean;
  38080. textureCount?: number;
  38081. doNotChangeAspectRatio?: boolean;
  38082. defaultType?: number;
  38083. }
  38084. class MultiRenderTarget extends RenderTargetTexture {
  38085. private _internalTextures;
  38086. private _textures;
  38087. readonly isSupported: boolean;
  38088. private _multiRenderTargetOptions;
  38089. readonly textures: Texture[];
  38090. readonly depthTexture: Texture;
  38091. wrapU: number;
  38092. wrapV: number;
  38093. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  38094. /** @hidden */
  38095. _rebuild(): void;
  38096. private _createInternalTextures;
  38097. private _createTextures;
  38098. samples: number;
  38099. resize(size: any): void;
  38100. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  38101. dispose(): void;
  38102. releaseInternalTextures(): void;
  38103. }
  38104. }
  38105. declare module BABYLON {
  38106. /**
  38107. * Raw cube texture where the raw buffers are passed in
  38108. */
  38109. class RawCubeTexture extends CubeTexture {
  38110. /**
  38111. * Creates a cube texture where the raw buffers are passed in.
  38112. * @param scene defines the scene the texture is attached to
  38113. * @param data defines the array of data to use to create each face
  38114. * @param size defines the size of the textures
  38115. * @param format defines the format of the data
  38116. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  38117. * @param generateMipMaps defines if the engine should generate the mip levels
  38118. * @param invertY defines if data must be stored with Y axis inverted
  38119. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  38120. * @param compression defines the compression used (null by default)
  38121. */
  38122. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  38123. /**
  38124. * Updates the raw cube texture.
  38125. * @param data defines the data to store
  38126. * @param format defines the data format
  38127. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  38128. * @param invertY defines if data must be stored with Y axis inverted
  38129. * @param compression defines the compression used (null by default)
  38130. * @param level defines which level of the texture to update
  38131. */
  38132. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  38133. /**
  38134. * Updates a raw cube texture with RGBD encoded data.
  38135. * @param data defines the array of data [mipmap][face] to use to create each face
  38136. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  38137. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  38138. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  38139. * @returns a promsie that resolves when the operation is complete
  38140. */
  38141. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  38142. /**
  38143. * Clones the raw cube texture.
  38144. * @return a new cube texture
  38145. */
  38146. clone(): CubeTexture;
  38147. /** @hidden */
  38148. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  38149. }
  38150. }
  38151. declare module BABYLON {
  38152. class RawTexture extends Texture {
  38153. format: number;
  38154. private _engine;
  38155. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  38156. update(data: ArrayBufferView): void;
  38157. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  38158. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  38159. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  38160. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  38161. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  38162. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  38163. }
  38164. }
  38165. declare module BABYLON {
  38166. /**
  38167. * Class used to store 3D textures containing user data
  38168. */
  38169. class RawTexture3D extends Texture {
  38170. /** Gets or sets the texture format to use */
  38171. format: number;
  38172. private _engine;
  38173. /**
  38174. * Create a new RawTexture3D
  38175. * @param data defines the data of the texture
  38176. * @param width defines the width of the texture
  38177. * @param height defines the height of the texture
  38178. * @param depth defines the depth of the texture
  38179. * @param format defines the texture format to use
  38180. * @param scene defines the hosting scene
  38181. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  38182. * @param invertY defines if texture must be stored with Y axis inverted
  38183. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  38184. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  38185. */
  38186. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  38187. /** Gets or sets the texture format to use */
  38188. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  38189. /**
  38190. * Update the texture with new data
  38191. * @param data defines the data to store in the texture
  38192. */
  38193. update(data: ArrayBufferView): void;
  38194. }
  38195. }
  38196. declare module BABYLON {
  38197. /**
  38198. * Creates a refraction texture used by refraction channel of the standard material.
  38199. * @param name the texture name
  38200. * @param size size of the underlying texture
  38201. * @param scene root scene
  38202. */
  38203. class RefractionTexture extends RenderTargetTexture {
  38204. refractionPlane: Plane;
  38205. depth: number;
  38206. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  38207. clone(): RefractionTexture;
  38208. serialize(): any;
  38209. }
  38210. }
  38211. declare module BABYLON {
  38212. class RenderTargetTexture extends Texture {
  38213. isCube: boolean;
  38214. static _REFRESHRATE_RENDER_ONCE: number;
  38215. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38216. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38217. static readonly REFRESHRATE_RENDER_ONCE: number;
  38218. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38219. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38220. /**
  38221. * Use this predicate to dynamically define the list of mesh you want to render.
  38222. * If set, the renderList property will be overwritten.
  38223. */
  38224. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  38225. private _renderList;
  38226. /**
  38227. * Use this list to define the list of mesh you want to render.
  38228. */
  38229. renderList: Nullable<Array<AbstractMesh>>;
  38230. private _hookArray;
  38231. renderParticles: boolean;
  38232. renderSprites: boolean;
  38233. coordinatesMode: number;
  38234. activeCamera: Nullable<Camera>;
  38235. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  38236. useCameraPostProcesses: boolean;
  38237. ignoreCameraViewport: boolean;
  38238. private _postProcessManager;
  38239. private _postProcesses;
  38240. private _resizeObserver;
  38241. /**
  38242. * An event triggered when the texture is unbind.
  38243. */
  38244. onBeforeBindObservable: Observable<RenderTargetTexture>;
  38245. /**
  38246. * An event triggered when the texture is unbind.
  38247. */
  38248. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  38249. private _onAfterUnbindObserver;
  38250. onAfterUnbind: () => void;
  38251. /**
  38252. * An event triggered before rendering the texture
  38253. */
  38254. onBeforeRenderObservable: Observable<number>;
  38255. private _onBeforeRenderObserver;
  38256. onBeforeRender: (faceIndex: number) => void;
  38257. /**
  38258. * An event triggered after rendering the texture
  38259. */
  38260. onAfterRenderObservable: Observable<number>;
  38261. private _onAfterRenderObserver;
  38262. onAfterRender: (faceIndex: number) => void;
  38263. /**
  38264. * An event triggered after the texture clear
  38265. */
  38266. onClearObservable: Observable<Engine>;
  38267. private _onClearObserver;
  38268. onClear: (Engine: Engine) => void;
  38269. clearColor: Color4;
  38270. protected _size: number | {
  38271. width: number;
  38272. height: number;
  38273. };
  38274. protected _initialSizeParameter: number | {
  38275. width: number;
  38276. height: number;
  38277. } | {
  38278. ratio: number;
  38279. };
  38280. protected _sizeRatio: Nullable<number>;
  38281. /** @hidden */
  38282. _generateMipMaps: boolean;
  38283. protected _renderingManager: RenderingManager;
  38284. /** @hidden */
  38285. _waitingRenderList: string[];
  38286. protected _doNotChangeAspectRatio: boolean;
  38287. protected _currentRefreshId: number;
  38288. protected _refreshRate: number;
  38289. protected _textureMatrix: Matrix;
  38290. protected _samples: number;
  38291. protected _renderTargetOptions: RenderTargetCreationOptions;
  38292. readonly renderTargetOptions: RenderTargetCreationOptions;
  38293. protected _engine: Engine;
  38294. protected _onRatioRescale(): void;
  38295. /**
  38296. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  38297. * It must define where the camera used to render the texture is set
  38298. */
  38299. boundingBoxPosition: Vector3;
  38300. private _boundingBoxSize;
  38301. /**
  38302. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  38303. * When defined, the cubemap will switch to local mode
  38304. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  38305. * @example https://www.babylonjs-playground.com/#RNASML
  38306. */
  38307. boundingBoxSize: Vector3;
  38308. /**
  38309. * In case the RTT has been created with a depth texture, get the associated
  38310. * depth texture.
  38311. * Otherwise, return null.
  38312. */
  38313. depthStencilTexture: Nullable<InternalTexture>;
  38314. /**
  38315. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  38316. * or used a shadow, depth texture...
  38317. * @param name The friendly name of the texture
  38318. * @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)
  38319. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  38320. * @param generateMipMaps True if mip maps need to be generated after render.
  38321. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  38322. * @param type The type of the buffer in the RTT (int, half float, float...)
  38323. * @param isCube True if a cube texture needs to be created
  38324. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  38325. * @param generateDepthBuffer True to generate a depth buffer
  38326. * @param generateStencilBuffer True to generate a stencil buffer
  38327. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  38328. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  38329. */
  38330. constructor(name: string, size: number | {
  38331. width: number;
  38332. height: number;
  38333. } | {
  38334. ratio: number;
  38335. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  38336. /**
  38337. * Creates a depth stencil texture.
  38338. * This is only available in WebGL 2 or with the depth texture extension available.
  38339. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  38340. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  38341. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  38342. */
  38343. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  38344. private _processSizeParameter;
  38345. samples: number;
  38346. resetRefreshCounter(): void;
  38347. refreshRate: number;
  38348. addPostProcess(postProcess: PostProcess): void;
  38349. clearPostProcesses(dispose?: boolean): void;
  38350. removePostProcess(postProcess: PostProcess): void;
  38351. /** @hidden */
  38352. _shouldRender(): boolean;
  38353. getRenderSize(): number;
  38354. getRenderWidth(): number;
  38355. getRenderHeight(): number;
  38356. readonly canRescale: boolean;
  38357. scale(ratio: number): void;
  38358. getReflectionTextureMatrix(): Matrix;
  38359. resize(size: number | {
  38360. width: number;
  38361. height: number;
  38362. } | {
  38363. ratio: number;
  38364. }): void;
  38365. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  38366. private _bestReflectionRenderTargetDimension;
  38367. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  38368. private renderToTarget;
  38369. /**
  38370. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38371. * This allowed control for front to back rendering or reversly depending of the special needs.
  38372. *
  38373. * @param renderingGroupId The rendering group id corresponding to its index
  38374. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38375. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38376. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38377. */
  38378. 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;
  38379. /**
  38380. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38381. *
  38382. * @param renderingGroupId The rendering group id corresponding to its index
  38383. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38384. */
  38385. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  38386. clone(): RenderTargetTexture;
  38387. serialize(): any;
  38388. disposeFramebufferObjects(): void;
  38389. dispose(): void;
  38390. /** @hidden */
  38391. _rebuild(): void;
  38392. /**
  38393. * Clear the info related to rendering groups preventing retention point in material dispose.
  38394. */
  38395. freeRenderingGroups(): void;
  38396. }
  38397. }
  38398. declare module BABYLON {
  38399. class Texture extends BaseTexture {
  38400. static NEAREST_SAMPLINGMODE: number;
  38401. static NEAREST_NEAREST_MIPLINEAR: number;
  38402. static BILINEAR_SAMPLINGMODE: number;
  38403. static LINEAR_LINEAR_MIPNEAREST: number;
  38404. static TRILINEAR_SAMPLINGMODE: number;
  38405. static LINEAR_LINEAR_MIPLINEAR: number;
  38406. static NEAREST_NEAREST_MIPNEAREST: number;
  38407. static NEAREST_LINEAR_MIPNEAREST: number;
  38408. static NEAREST_LINEAR_MIPLINEAR: number;
  38409. static NEAREST_LINEAR: number;
  38410. static NEAREST_NEAREST: number;
  38411. static LINEAR_NEAREST_MIPNEAREST: number;
  38412. static LINEAR_NEAREST_MIPLINEAR: number;
  38413. static LINEAR_LINEAR: number;
  38414. static LINEAR_NEAREST: number;
  38415. static EXPLICIT_MODE: number;
  38416. static SPHERICAL_MODE: number;
  38417. static PLANAR_MODE: number;
  38418. static CUBIC_MODE: number;
  38419. static PROJECTION_MODE: number;
  38420. static SKYBOX_MODE: number;
  38421. static INVCUBIC_MODE: number;
  38422. static EQUIRECTANGULAR_MODE: number;
  38423. static FIXED_EQUIRECTANGULAR_MODE: number;
  38424. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38425. static readonly CLAMP_ADDRESSMODE: number;
  38426. static readonly WRAP_ADDRESSMODE: number;
  38427. static readonly MIRROR_ADDRESSMODE: number;
  38428. /**
  38429. * 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
  38430. */
  38431. static UseSerializedUrlIfAny: boolean;
  38432. url: Nullable<string>;
  38433. uOffset: number;
  38434. vOffset: number;
  38435. uScale: number;
  38436. vScale: number;
  38437. uAng: number;
  38438. vAng: number;
  38439. wAng: number;
  38440. /**
  38441. * Defines the center of rotation (U)
  38442. */
  38443. uRotationCenter: number;
  38444. /**
  38445. * Defines the center of rotation (V)
  38446. */
  38447. vRotationCenter: number;
  38448. /**
  38449. * Defines the center of rotation (W)
  38450. */
  38451. wRotationCenter: number;
  38452. readonly noMipmap: boolean;
  38453. private _noMipmap;
  38454. /** @hidden */
  38455. _invertY: boolean;
  38456. private _rowGenerationMatrix;
  38457. private _cachedTextureMatrix;
  38458. private _projectionModeMatrix;
  38459. private _t0;
  38460. private _t1;
  38461. private _t2;
  38462. private _cachedUOffset;
  38463. private _cachedVOffset;
  38464. private _cachedUScale;
  38465. private _cachedVScale;
  38466. private _cachedUAng;
  38467. private _cachedVAng;
  38468. private _cachedWAng;
  38469. private _cachedProjectionMatrixId;
  38470. private _cachedCoordinatesMode;
  38471. /** @hidden */
  38472. _samplingMode: number;
  38473. /** @hidden */
  38474. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  38475. private _deleteBuffer;
  38476. protected _format: Nullable<number>;
  38477. private _delayedOnLoad;
  38478. private _delayedOnError;
  38479. protected _onLoadObservable: Nullable<Observable<Texture>>;
  38480. protected _isBlocking: boolean;
  38481. isBlocking: boolean;
  38482. readonly samplingMode: number;
  38483. 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);
  38484. /**
  38485. * Update the url (and optional buffer) of this texture if url was null during construction.
  38486. * @param url the url of the texture
  38487. * @param buffer the buffer of the texture (defaults to null)
  38488. */
  38489. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  38490. delayLoad(): void;
  38491. /**
  38492. * Default is Trilinear mode.
  38493. *
  38494. * | Value | Type | Description |
  38495. * | ----- | ------------------ | ----------- |
  38496. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  38497. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  38498. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  38499. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  38500. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  38501. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  38502. * | 7 | NEAREST_LINEAR | |
  38503. * | 8 | NEAREST_NEAREST | |
  38504. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  38505. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  38506. * | 11 | LINEAR_LINEAR | |
  38507. * | 12 | LINEAR_NEAREST | |
  38508. *
  38509. * > _mag_: magnification filter (close to the viewer)
  38510. * > _min_: minification filter (far from the viewer)
  38511. * > _mip_: filter used between mip map levels
  38512. *
  38513. */
  38514. updateSamplingMode(samplingMode: number): void;
  38515. private _prepareRowForTextureGeneration;
  38516. getTextureMatrix(): Matrix;
  38517. getReflectionTextureMatrix(): Matrix;
  38518. clone(): Texture;
  38519. readonly onLoadObservable: Observable<Texture>;
  38520. serialize(): any;
  38521. getClassName(): string;
  38522. dispose(): void;
  38523. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  38524. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  38525. 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;
  38526. }
  38527. }
  38528. declare module BABYLON {
  38529. /**
  38530. * Settings for finer control over video usage
  38531. */
  38532. interface VideoTextureSettings {
  38533. /**
  38534. * Applies `autoplay` to video, if specified
  38535. */
  38536. autoPlay?: boolean;
  38537. /**
  38538. * Applies `loop` to video, if specified
  38539. */
  38540. loop?: boolean;
  38541. /**
  38542. * Automatically updates internal texture from video at every frame in the render loop
  38543. */
  38544. autoUpdateTexture: boolean;
  38545. /**
  38546. * Image src displayed during the video loading or until the user interacts with the video.
  38547. */
  38548. poster?: string;
  38549. }
  38550. class VideoTexture extends Texture {
  38551. /**
  38552. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38553. */
  38554. readonly autoUpdateTexture: boolean;
  38555. /**
  38556. * The video instance used by the texture internally
  38557. */
  38558. readonly video: HTMLVideoElement;
  38559. private _onUserActionRequestedObservable;
  38560. readonly onUserActionRequestedObservable: Observable<Texture>;
  38561. private _generateMipMaps;
  38562. private _engine;
  38563. private _stillImageCaptured;
  38564. private _poster;
  38565. /**
  38566. * Creates a video texture.
  38567. * Sample : https://doc.babylonjs.com/how_to/video_texture
  38568. * @param {string | null} name optional name, will detect from video source, if not defined
  38569. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  38570. * @param {BABYLON.Scene} scene is obviously the current scene.
  38571. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38572. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  38573. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38574. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  38575. */
  38576. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38577. private _getName;
  38578. private _getVideo;
  38579. private _createInternalTexture;
  38580. private reset;
  38581. /**
  38582. * @hidden Internal method to initiate `update`.
  38583. */
  38584. _rebuild(): void;
  38585. /**
  38586. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38587. */
  38588. update(): void;
  38589. /**
  38590. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38591. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38592. */
  38593. updateTexture(isVisible: boolean): void;
  38594. protected _updateInternalTexture: (e?: Event | undefined) => void;
  38595. /**
  38596. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38597. * @param url New url.
  38598. */
  38599. updateURL(url: string): void;
  38600. dispose(): void;
  38601. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38602. minWidth: number;
  38603. maxWidth: number;
  38604. minHeight: number;
  38605. maxHeight: number;
  38606. deviceId: string;
  38607. }): void;
  38608. }
  38609. }
  38610. declare var DracoDecoderModule: any;
  38611. declare var WebAssembly: any;
  38612. declare module BABYLON {
  38613. /**
  38614. * Configuration for Draco compression
  38615. */
  38616. interface IDracoCompressionConfiguration {
  38617. /**
  38618. * Configuration for the decoder.
  38619. */
  38620. decoder?: {
  38621. /**
  38622. * The url to the WebAssembly module.
  38623. */
  38624. wasmUrl?: string;
  38625. /**
  38626. * The url to the WebAssembly binary.
  38627. */
  38628. wasmBinaryUrl?: string;
  38629. /**
  38630. * The url to the fallback JavaScript module.
  38631. */
  38632. fallbackUrl?: string;
  38633. };
  38634. }
  38635. /**
  38636. * Draco compression (https://google.github.io/draco/)
  38637. *
  38638. * This class wraps the Draco module.
  38639. *
  38640. * **Encoder**
  38641. *
  38642. * The encoder is not currently implemented.
  38643. *
  38644. * **Decoder**
  38645. *
  38646. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  38647. *
  38648. * To update the configuration, use the following code:
  38649. * ```javascript
  38650. * BABYLON.DracoCompression.Configuration = {
  38651. * decoder: {
  38652. * wasmUrl: "<url to the WebAssembly library>",
  38653. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  38654. * fallbackUrl: "<url to the fallback JavaScript library>",
  38655. * }
  38656. * };
  38657. * ```
  38658. *
  38659. * 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.
  38660. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  38661. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  38662. *
  38663. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  38664. * ```javascript
  38665. * var dracoCompression = new BABYLON.DracoCompression();
  38666. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  38667. * [BABYLON.VertexBuffer.PositionKind]: 0
  38668. * });
  38669. * ```
  38670. *
  38671. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  38672. */
  38673. class DracoCompression implements IDisposable {
  38674. private static _DecoderModulePromise;
  38675. /**
  38676. * The configuration. Defaults to the following urls:
  38677. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  38678. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  38679. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  38680. */
  38681. static Configuration: IDracoCompressionConfiguration;
  38682. /**
  38683. * Returns true if the decoder is available.
  38684. */
  38685. static readonly DecoderAvailable: boolean;
  38686. /**
  38687. * Constructor
  38688. */
  38689. constructor();
  38690. /**
  38691. * Stop all async operations and release resources.
  38692. */
  38693. dispose(): void;
  38694. /**
  38695. * Decode Draco compressed mesh data to vertex data.
  38696. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  38697. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  38698. * @returns A promise that resolves with the decoded vertex data
  38699. */
  38700. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  38701. [kind: string]: number;
  38702. }): Promise<VertexData>;
  38703. private static _GetDecoderModule;
  38704. private static _LoadScriptAsync;
  38705. private static _LoadFileAsync;
  38706. }
  38707. }
  38708. declare module BABYLON {
  38709. /**
  38710. * Particle emitter emitting particles from the inside of a box.
  38711. * It emits the particles randomly between 2 given directions.
  38712. */
  38713. class BoxParticleEmitter implements IParticleEmitterType {
  38714. /**
  38715. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  38716. */
  38717. direction1: Vector3;
  38718. /**
  38719. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  38720. */
  38721. direction2: Vector3;
  38722. /**
  38723. * 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.
  38724. */
  38725. minEmitBox: Vector3;
  38726. /**
  38727. * 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.
  38728. */
  38729. maxEmitBox: Vector3;
  38730. /**
  38731. * Creates a new instance BoxParticleEmitter
  38732. */
  38733. constructor();
  38734. /**
  38735. * Called by the particle System when the direction is computed for the created particle.
  38736. * @param worldMatrix is the world matrix of the particle system
  38737. * @param directionToUpdate is the direction vector to update with the result
  38738. * @param particle is the particle we are computed the direction for
  38739. */
  38740. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38741. /**
  38742. * Called by the particle System when the position is computed for the created particle.
  38743. * @param worldMatrix is the world matrix of the particle system
  38744. * @param positionToUpdate is the position vector to update with the result
  38745. * @param particle is the particle we are computed the position for
  38746. */
  38747. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38748. /**
  38749. * Clones the current emitter and returns a copy of it
  38750. * @returns the new emitter
  38751. */
  38752. clone(): BoxParticleEmitter;
  38753. /**
  38754. * Called by the GPUParticleSystem to setup the update shader
  38755. * @param effect defines the update shader
  38756. */
  38757. applyToShader(effect: Effect): void;
  38758. /**
  38759. * Returns a string to use to update the GPU particles update shader
  38760. * @returns a string containng the defines string
  38761. */
  38762. getEffectDefines(): string;
  38763. /**
  38764. * Returns the string "BoxParticleEmitter"
  38765. * @returns a string containing the class name
  38766. */
  38767. getClassName(): string;
  38768. /**
  38769. * Serializes the particle system to a JSON object.
  38770. * @returns the JSON object
  38771. */
  38772. serialize(): any;
  38773. /**
  38774. * Parse properties from a JSON object
  38775. * @param serializationObject defines the JSON object
  38776. */
  38777. parse(serializationObject: any): void;
  38778. }
  38779. }
  38780. declare module BABYLON {
  38781. /**
  38782. * Particle emitter emitting particles from the inside of a cone.
  38783. * It emits the particles alongside the cone volume from the base to the particle.
  38784. * The emission direction might be randomized.
  38785. */
  38786. class ConeParticleEmitter implements IParticleEmitterType {
  38787. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  38788. directionRandomizer: number;
  38789. private _radius;
  38790. private _angle;
  38791. private _height;
  38792. /**
  38793. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  38794. */
  38795. radiusRange: number;
  38796. /**
  38797. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  38798. */
  38799. heightRange: number;
  38800. /**
  38801. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  38802. */
  38803. emitFromSpawnPointOnly: boolean;
  38804. /**
  38805. * Gets or sets the radius of the emission cone
  38806. */
  38807. radius: number;
  38808. /**
  38809. * Gets or sets the angle of the emission cone
  38810. */
  38811. angle: number;
  38812. private _buildHeight;
  38813. /**
  38814. * Creates a new instance ConeParticleEmitter
  38815. * @param radius the radius of the emission cone (1 by default)
  38816. * @param angles the cone base angle (PI by default)
  38817. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  38818. */
  38819. constructor(radius?: number, angle?: number,
  38820. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  38821. directionRandomizer?: number);
  38822. /**
  38823. * Called by the particle System when the direction is computed for the created particle.
  38824. * @param worldMatrix is the world matrix of the particle system
  38825. * @param directionToUpdate is the direction vector to update with the result
  38826. * @param particle is the particle we are computed the direction for
  38827. */
  38828. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38829. /**
  38830. * Called by the particle System when the position is computed for the created particle.
  38831. * @param worldMatrix is the world matrix of the particle system
  38832. * @param positionToUpdate is the position vector to update with the result
  38833. * @param particle is the particle we are computed the position for
  38834. */
  38835. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38836. /**
  38837. * Clones the current emitter and returns a copy of it
  38838. * @returns the new emitter
  38839. */
  38840. clone(): ConeParticleEmitter;
  38841. /**
  38842. * Called by the GPUParticleSystem to setup the update shader
  38843. * @param effect defines the update shader
  38844. */
  38845. applyToShader(effect: Effect): void;
  38846. /**
  38847. * Returns a string to use to update the GPU particles update shader
  38848. * @returns a string containng the defines string
  38849. */
  38850. getEffectDefines(): string;
  38851. /**
  38852. * Returns the string "ConeParticleEmitter"
  38853. * @returns a string containing the class name
  38854. */
  38855. getClassName(): string;
  38856. /**
  38857. * Serializes the particle system to a JSON object.
  38858. * @returns the JSON object
  38859. */
  38860. serialize(): any;
  38861. /**
  38862. * Parse properties from a JSON object
  38863. * @param serializationObject defines the JSON object
  38864. */
  38865. parse(serializationObject: any): void;
  38866. }
  38867. }
  38868. declare module BABYLON {
  38869. /**
  38870. * Particle emitter emitting particles from the inside of a cylinder.
  38871. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  38872. */
  38873. class CylinderParticleEmitter implements IParticleEmitterType {
  38874. /**
  38875. * The radius of the emission cylinder.
  38876. */
  38877. radius: number;
  38878. /**
  38879. * The height of the emission cylinder.
  38880. */
  38881. height: number;
  38882. /**
  38883. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38884. */
  38885. radiusRange: number;
  38886. /**
  38887. * How much to randomize the particle direction [0-1].
  38888. */
  38889. directionRandomizer: number;
  38890. /**
  38891. * Creates a new instance CylinderParticleEmitter
  38892. * @param radius the radius of the emission cylinder (1 by default)
  38893. * @param height the height of the emission cylinder (1 by default)
  38894. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  38895. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  38896. */
  38897. constructor(
  38898. /**
  38899. * The radius of the emission cylinder.
  38900. */
  38901. radius?: number,
  38902. /**
  38903. * The height of the emission cylinder.
  38904. */
  38905. height?: number,
  38906. /**
  38907. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  38908. */
  38909. radiusRange?: number,
  38910. /**
  38911. * How much to randomize the particle direction [0-1].
  38912. */
  38913. directionRandomizer?: number);
  38914. /**
  38915. * Called by the particle System when the direction is computed for the created particle.
  38916. * @param worldMatrix is the world matrix of the particle system
  38917. * @param directionToUpdate is the direction vector to update with the result
  38918. * @param particle is the particle we are computed the direction for
  38919. */
  38920. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38921. /**
  38922. * Called by the particle System when the position is computed for the created particle.
  38923. * @param worldMatrix is the world matrix of the particle system
  38924. * @param positionToUpdate is the position vector to update with the result
  38925. * @param particle is the particle we are computed the position for
  38926. */
  38927. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  38928. /**
  38929. * Clones the current emitter and returns a copy of it
  38930. * @returns the new emitter
  38931. */
  38932. clone(): CylinderParticleEmitter;
  38933. /**
  38934. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  38935. * @param effect defines the update shader
  38936. */
  38937. applyToShader(effect: Effect): void;
  38938. /**
  38939. * Returns a string to use to update the GPU particles update shader
  38940. * @returns a string containng the defines string
  38941. */
  38942. getEffectDefines(): string;
  38943. /**
  38944. * Returns the string "CylinderParticleEmitter"
  38945. * @returns a string containing the class name
  38946. */
  38947. getClassName(): string;
  38948. /**
  38949. * Serializes the particle system to a JSON object.
  38950. * @returns the JSON object
  38951. */
  38952. serialize(): any;
  38953. /**
  38954. * Parse properties from a JSON object
  38955. * @param serializationObject defines the JSON object
  38956. */
  38957. parse(serializationObject: any): void;
  38958. }
  38959. /**
  38960. * Particle emitter emitting particles from the inside of a cylinder.
  38961. * It emits the particles randomly between two vectors.
  38962. */
  38963. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  38964. /**
  38965. * The min limit of the emission direction.
  38966. */
  38967. direction1: Vector3;
  38968. /**
  38969. * The max limit of the emission direction.
  38970. */
  38971. direction2: Vector3;
  38972. /**
  38973. * Creates a new instance CylinderDirectedParticleEmitter
  38974. * @param radius the radius of the emission cylinder (1 by default)
  38975. * @param height the height of the emission cylinder (1 by default)
  38976. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  38977. * @param direction1 the min limit of the emission direction (up vector by default)
  38978. * @param direction2 the max limit of the emission direction (up vector by default)
  38979. */
  38980. constructor(radius?: number, height?: number, radiusRange?: number,
  38981. /**
  38982. * The min limit of the emission direction.
  38983. */
  38984. direction1?: Vector3,
  38985. /**
  38986. * The max limit of the emission direction.
  38987. */
  38988. direction2?: Vector3);
  38989. /**
  38990. * Called by the particle System when the direction is computed for the created particle.
  38991. * @param worldMatrix is the world matrix of the particle system
  38992. * @param directionToUpdate is the direction vector to update with the result
  38993. * @param particle is the particle we are computed the direction for
  38994. */
  38995. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  38996. /**
  38997. * Clones the current emitter and returns a copy of it
  38998. * @returns the new emitter
  38999. */
  39000. clone(): CylinderDirectedParticleEmitter;
  39001. /**
  39002. * Called by the GPUParticleSystem to setup the update shader
  39003. * @param effect defines the update shader
  39004. */
  39005. applyToShader(effect: Effect): void;
  39006. /**
  39007. * Returns a string to use to update the GPU particles update shader
  39008. * @returns a string containng the defines string
  39009. */
  39010. getEffectDefines(): string;
  39011. /**
  39012. * Returns the string "CylinderDirectedParticleEmitter"
  39013. * @returns a string containing the class name
  39014. */
  39015. getClassName(): string;
  39016. /**
  39017. * Serializes the particle system to a JSON object.
  39018. * @returns the JSON object
  39019. */
  39020. serialize(): any;
  39021. /**
  39022. * Parse properties from a JSON object
  39023. * @param serializationObject defines the JSON object
  39024. */
  39025. parse(serializationObject: any): void;
  39026. }
  39027. }
  39028. declare module BABYLON {
  39029. /**
  39030. * Particle emitter emitting particles from the inside of a hemisphere.
  39031. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  39032. */
  39033. class HemisphericParticleEmitter implements IParticleEmitterType {
  39034. /**
  39035. * The radius of the emission hemisphere.
  39036. */
  39037. radius: number;
  39038. /**
  39039. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  39040. */
  39041. radiusRange: number;
  39042. /**
  39043. * How much to randomize the particle direction [0-1].
  39044. */
  39045. directionRandomizer: number;
  39046. /**
  39047. * Creates a new instance HemisphericParticleEmitter
  39048. * @param radius the radius of the emission hemisphere (1 by default)
  39049. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  39050. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  39051. */
  39052. constructor(
  39053. /**
  39054. * The radius of the emission hemisphere.
  39055. */
  39056. radius?: number,
  39057. /**
  39058. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  39059. */
  39060. radiusRange?: number,
  39061. /**
  39062. * How much to randomize the particle direction [0-1].
  39063. */
  39064. directionRandomizer?: number);
  39065. /**
  39066. * Called by the particle System when the direction is computed for the created particle.
  39067. * @param worldMatrix is the world matrix of the particle system
  39068. * @param directionToUpdate is the direction vector to update with the result
  39069. * @param particle is the particle we are computed the direction for
  39070. */
  39071. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  39072. /**
  39073. * Called by the particle System when the position is computed for the created particle.
  39074. * @param worldMatrix is the world matrix of the particle system
  39075. * @param positionToUpdate is the position vector to update with the result
  39076. * @param particle is the particle we are computed the position for
  39077. */
  39078. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  39079. /**
  39080. * Clones the current emitter and returns a copy of it
  39081. * @returns the new emitter
  39082. */
  39083. clone(): HemisphericParticleEmitter;
  39084. /**
  39085. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  39086. * @param effect defines the update shader
  39087. */
  39088. applyToShader(effect: Effect): void;
  39089. /**
  39090. * Returns a string to use to update the GPU particles update shader
  39091. * @returns a string containng the defines string
  39092. */
  39093. getEffectDefines(): string;
  39094. /**
  39095. * Returns the string "HemisphericParticleEmitter"
  39096. * @returns a string containing the class name
  39097. */
  39098. getClassName(): string;
  39099. /**
  39100. * Serializes the particle system to a JSON object.
  39101. * @returns the JSON object
  39102. */
  39103. serialize(): any;
  39104. /**
  39105. * Parse properties from a JSON object
  39106. * @param serializationObject defines the JSON object
  39107. */
  39108. parse(serializationObject: any): void;
  39109. }
  39110. }
  39111. declare module BABYLON {
  39112. /**
  39113. * Particle emitter represents a volume emitting particles.
  39114. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  39115. */
  39116. interface IParticleEmitterType {
  39117. /**
  39118. * Called by the particle System when the direction is computed for the created particle.
  39119. * @param worldMatrix is the world matrix of the particle system
  39120. * @param directionToUpdate is the direction vector to update with the result
  39121. * @param particle is the particle we are computed the direction for
  39122. */
  39123. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  39124. /**
  39125. * Called by the particle System when the position is computed for the created particle.
  39126. * @param worldMatrix is the world matrix of the particle system
  39127. * @param positionToUpdate is the position vector to update with the result
  39128. * @param particle is the particle we are computed the position for
  39129. */
  39130. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  39131. /**
  39132. * Clones the current emitter and returns a copy of it
  39133. * @returns the new emitter
  39134. */
  39135. clone(): IParticleEmitterType;
  39136. /**
  39137. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  39138. * @param effect defines the update shader
  39139. */
  39140. applyToShader(effect: Effect): void;
  39141. /**
  39142. * Returns a string to use to update the GPU particles update shader
  39143. * @returns the effect defines string
  39144. */
  39145. getEffectDefines(): string;
  39146. /**
  39147. * Returns a string representing the class name
  39148. * @returns a string containing the class name
  39149. */
  39150. getClassName(): string;
  39151. /**
  39152. * Serializes the particle system to a JSON object.
  39153. * @returns the JSON object
  39154. */
  39155. serialize(): any;
  39156. /**
  39157. * Parse properties from a JSON object
  39158. * @param serializationObject defines the JSON object
  39159. */
  39160. parse(serializationObject: any): void;
  39161. }
  39162. }
  39163. declare module BABYLON {
  39164. /**
  39165. * Particle emitter emitting particles from a point.
  39166. * It emits the particles randomly between 2 given directions.
  39167. */
  39168. class PointParticleEmitter implements IParticleEmitterType {
  39169. /**
  39170. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  39171. */
  39172. direction1: Vector3;
  39173. /**
  39174. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  39175. */
  39176. direction2: Vector3;
  39177. /**
  39178. * Creates a new instance PointParticleEmitter
  39179. */
  39180. constructor();
  39181. /**
  39182. * Called by the particle System when the direction is computed for the created particle.
  39183. * @param worldMatrix is the world matrix of the particle system
  39184. * @param directionToUpdate is the direction vector to update with the result
  39185. * @param particle is the particle we are computed the direction for
  39186. */
  39187. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  39188. /**
  39189. * Called by the particle System when the position is computed for the created particle.
  39190. * @param worldMatrix is the world matrix of the particle system
  39191. * @param positionToUpdate is the position vector to update with the result
  39192. * @param particle is the particle we are computed the position for
  39193. */
  39194. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  39195. /**
  39196. * Clones the current emitter and returns a copy of it
  39197. * @returns the new emitter
  39198. */
  39199. clone(): PointParticleEmitter;
  39200. /**
  39201. * Called by the GPUParticleSystem to setup the update shader
  39202. * @param effect defines the update shader
  39203. */
  39204. applyToShader(effect: Effect): void;
  39205. /**
  39206. * Returns a string to use to update the GPU particles update shader
  39207. * @returns a string containng the defines string
  39208. */
  39209. getEffectDefines(): string;
  39210. /**
  39211. * Returns the string "PointParticleEmitter"
  39212. * @returns a string containing the class name
  39213. */
  39214. getClassName(): string;
  39215. /**
  39216. * Serializes the particle system to a JSON object.
  39217. * @returns the JSON object
  39218. */
  39219. serialize(): any;
  39220. /**
  39221. * Parse properties from a JSON object
  39222. * @param serializationObject defines the JSON object
  39223. */
  39224. parse(serializationObject: any): void;
  39225. }
  39226. }
  39227. declare module BABYLON {
  39228. /**
  39229. * Particle emitter emitting particles from the inside of a sphere.
  39230. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  39231. */
  39232. class SphereParticleEmitter implements IParticleEmitterType {
  39233. /**
  39234. * The radius of the emission sphere.
  39235. */
  39236. radius: number;
  39237. /**
  39238. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  39239. */
  39240. radiusRange: number;
  39241. /**
  39242. * How much to randomize the particle direction [0-1].
  39243. */
  39244. directionRandomizer: number;
  39245. /**
  39246. * Creates a new instance SphereParticleEmitter
  39247. * @param radius the radius of the emission sphere (1 by default)
  39248. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  39249. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  39250. */
  39251. constructor(
  39252. /**
  39253. * The radius of the emission sphere.
  39254. */
  39255. radius?: number,
  39256. /**
  39257. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  39258. */
  39259. radiusRange?: number,
  39260. /**
  39261. * How much to randomize the particle direction [0-1].
  39262. */
  39263. directionRandomizer?: number);
  39264. /**
  39265. * Called by the particle System when the direction is computed for the created particle.
  39266. * @param worldMatrix is the world matrix of the particle system
  39267. * @param directionToUpdate is the direction vector to update with the result
  39268. * @param particle is the particle we are computed the direction for
  39269. */
  39270. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  39271. /**
  39272. * Called by the particle System when the position is computed for the created particle.
  39273. * @param worldMatrix is the world matrix of the particle system
  39274. * @param positionToUpdate is the position vector to update with the result
  39275. * @param particle is the particle we are computed the position for
  39276. */
  39277. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  39278. /**
  39279. * Clones the current emitter and returns a copy of it
  39280. * @returns the new emitter
  39281. */
  39282. clone(): SphereParticleEmitter;
  39283. /**
  39284. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  39285. * @param effect defines the update shader
  39286. */
  39287. applyToShader(effect: Effect): void;
  39288. /**
  39289. * Returns a string to use to update the GPU particles update shader
  39290. * @returns a string containng the defines string
  39291. */
  39292. getEffectDefines(): string;
  39293. /**
  39294. * Returns the string "SphereParticleEmitter"
  39295. * @returns a string containing the class name
  39296. */
  39297. getClassName(): string;
  39298. /**
  39299. * Serializes the particle system to a JSON object.
  39300. * @returns the JSON object
  39301. */
  39302. serialize(): any;
  39303. /**
  39304. * Parse properties from a JSON object
  39305. * @param serializationObject defines the JSON object
  39306. */
  39307. parse(serializationObject: any): void;
  39308. }
  39309. /**
  39310. * Particle emitter emitting particles from the inside of a sphere.
  39311. * It emits the particles randomly between two vectors.
  39312. */
  39313. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  39314. /**
  39315. * The min limit of the emission direction.
  39316. */
  39317. direction1: Vector3;
  39318. /**
  39319. * The max limit of the emission direction.
  39320. */
  39321. direction2: Vector3;
  39322. /**
  39323. * Creates a new instance SphereDirectedParticleEmitter
  39324. * @param radius the radius of the emission sphere (1 by default)
  39325. * @param direction1 the min limit of the emission direction (up vector by default)
  39326. * @param direction2 the max limit of the emission direction (up vector by default)
  39327. */
  39328. constructor(radius?: number,
  39329. /**
  39330. * The min limit of the emission direction.
  39331. */
  39332. direction1?: Vector3,
  39333. /**
  39334. * The max limit of the emission direction.
  39335. */
  39336. direction2?: Vector3);
  39337. /**
  39338. * Called by the particle System when the direction is computed for the created particle.
  39339. * @param worldMatrix is the world matrix of the particle system
  39340. * @param directionToUpdate is the direction vector to update with the result
  39341. * @param particle is the particle we are computed the direction for
  39342. */
  39343. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  39344. /**
  39345. * Clones the current emitter and returns a copy of it
  39346. * @returns the new emitter
  39347. */
  39348. clone(): SphereDirectedParticleEmitter;
  39349. /**
  39350. * Called by the GPUParticleSystem to setup the update shader
  39351. * @param effect defines the update shader
  39352. */
  39353. applyToShader(effect: Effect): void;
  39354. /**
  39355. * Returns a string to use to update the GPU particles update shader
  39356. * @returns a string containng the defines string
  39357. */
  39358. getEffectDefines(): string;
  39359. /**
  39360. * Returns the string "SphereDirectedParticleEmitter"
  39361. * @returns a string containing the class name
  39362. */
  39363. getClassName(): string;
  39364. /**
  39365. * Serializes the particle system to a JSON object.
  39366. * @returns the JSON object
  39367. */
  39368. serialize(): any;
  39369. /**
  39370. * Parse properties from a JSON object
  39371. * @param serializationObject defines the JSON object
  39372. */
  39373. parse(serializationObject: any): void;
  39374. }
  39375. }
  39376. declare module BABYLON {
  39377. class CannonJSPlugin implements IPhysicsEnginePlugin {
  39378. private _useDeltaForWorldStep;
  39379. world: any;
  39380. name: string;
  39381. private _physicsMaterials;
  39382. private _fixedTimeStep;
  39383. BJSCANNON: any;
  39384. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  39385. setGravity(gravity: Vector3): void;
  39386. setTimeStep(timeStep: number): void;
  39387. getTimeStep(): number;
  39388. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  39389. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  39390. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  39391. generatePhysicsBody(impostor: PhysicsImpostor): void;
  39392. private _processChildMeshes;
  39393. removePhysicsBody(impostor: PhysicsImpostor): void;
  39394. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  39395. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  39396. private _addMaterial;
  39397. private _checkWithEpsilon;
  39398. private _createShape;
  39399. private _createHeightmap;
  39400. private _minus90X;
  39401. private _plus90X;
  39402. private _tmpPosition;
  39403. private _tmpDeltaPosition;
  39404. private _tmpUnityRotation;
  39405. private _updatePhysicsBodyTransformation;
  39406. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  39407. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  39408. isSupported(): boolean;
  39409. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  39410. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  39411. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  39412. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  39413. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  39414. getBodyMass(impostor: PhysicsImpostor): number;
  39415. getBodyFriction(impostor: PhysicsImpostor): number;
  39416. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  39417. getBodyRestitution(impostor: PhysicsImpostor): number;
  39418. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  39419. sleepBody(impostor: PhysicsImpostor): void;
  39420. wakeUpBody(impostor: PhysicsImpostor): void;
  39421. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  39422. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  39423. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  39424. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  39425. getRadius(impostor: PhysicsImpostor): number;
  39426. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  39427. dispose(): void;
  39428. private _extendNamespace;
  39429. }
  39430. }
  39431. declare module BABYLON {
  39432. class OimoJSPlugin implements IPhysicsEnginePlugin {
  39433. world: any;
  39434. name: string;
  39435. BJSOIMO: any;
  39436. constructor(iterations?: number);
  39437. setGravity(gravity: Vector3): void;
  39438. setTimeStep(timeStep: number): void;
  39439. getTimeStep(): number;
  39440. private _tmpImpostorsArray;
  39441. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  39442. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  39443. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  39444. generatePhysicsBody(impostor: PhysicsImpostor): void;
  39445. private _tmpPositionVector;
  39446. removePhysicsBody(impostor: PhysicsImpostor): void;
  39447. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  39448. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  39449. isSupported(): boolean;
  39450. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  39451. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  39452. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  39453. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  39454. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  39455. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  39456. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  39457. getBodyMass(impostor: PhysicsImpostor): number;
  39458. getBodyFriction(impostor: PhysicsImpostor): number;
  39459. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  39460. getBodyRestitution(impostor: PhysicsImpostor): number;
  39461. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  39462. sleepBody(impostor: PhysicsImpostor): void;
  39463. wakeUpBody(impostor: PhysicsImpostor): void;
  39464. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  39465. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  39466. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  39467. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  39468. getRadius(impostor: PhysicsImpostor): number;
  39469. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  39470. dispose(): void;
  39471. }
  39472. }
  39473. declare module BABYLON {
  39474. /**
  39475. * This represents a set of one or more post processes in Babylon.
  39476. * A post process can be used to apply a shader to a texture after it is rendered.
  39477. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  39478. */
  39479. class PostProcessRenderEffect {
  39480. private _postProcesses;
  39481. private _getPostProcesses;
  39482. private _singleInstance;
  39483. private _cameras;
  39484. private _indicesForCamera;
  39485. /**
  39486. * Name of the effect
  39487. * @hidden
  39488. */
  39489. _name: string;
  39490. /**
  39491. * Instantiates a post process render effect.
  39492. * A post process can be used to apply a shader to a texture after it is rendered.
  39493. * @param engine The engine the effect is tied to
  39494. * @param name The name of the effect
  39495. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  39496. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  39497. */
  39498. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  39499. /**
  39500. * Checks if all the post processes in the effect are supported.
  39501. */
  39502. readonly isSupported: boolean;
  39503. /**
  39504. * Updates the current state of the effect
  39505. * @hidden
  39506. */
  39507. _update(): void;
  39508. /**
  39509. * Attaches the effect on cameras
  39510. * @param cameras The camera to attach to.
  39511. * @hidden
  39512. */
  39513. _attachCameras(cameras: Camera): void;
  39514. /**
  39515. * Attaches the effect on cameras
  39516. * @param cameras The camera to attach to.
  39517. * @hidden
  39518. */
  39519. _attachCameras(cameras: Camera[]): void;
  39520. /**
  39521. * Detatches the effect on cameras
  39522. * @param cameras The camera to detatch from.
  39523. * @hidden
  39524. */
  39525. _detachCameras(cameras: Camera): void;
  39526. /**
  39527. * Detatches the effect on cameras
  39528. * @param cameras The camera to detatch from.
  39529. * @hidden
  39530. */
  39531. _detachCameras(cameras: Camera[]): void;
  39532. /**
  39533. * Enables the effect on given cameras
  39534. * @param cameras The camera to enable.
  39535. * @hidden
  39536. */
  39537. _enable(cameras: Camera): void;
  39538. /**
  39539. * Enables the effect on given cameras
  39540. * @param cameras The camera to enable.
  39541. * @hidden
  39542. */
  39543. _enable(cameras: Nullable<Camera[]>): void;
  39544. /**
  39545. * Disables the effect on the given cameras
  39546. * @param cameras The camera to disable.
  39547. * @hidden
  39548. */
  39549. _disable(cameras: Camera): void;
  39550. /**
  39551. * Disables the effect on the given cameras
  39552. * @param cameras The camera to disable.
  39553. * @hidden
  39554. */
  39555. _disable(cameras: Nullable<Camera[]>): void;
  39556. /**
  39557. * Gets a list of the post processes contained in the effect.
  39558. * @param camera The camera to get the post processes on.
  39559. * @returns The list of the post processes in the effect.
  39560. */
  39561. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  39562. }
  39563. }
  39564. declare module BABYLON {
  39565. class PostProcessRenderPipeline {
  39566. private engine;
  39567. private _renderEffects;
  39568. private _renderEffectsForIsolatedPass;
  39569. protected _cameras: Camera[];
  39570. /** @hidden */
  39571. _name: string;
  39572. constructor(engine: Engine, name: string);
  39573. getClassName(): string;
  39574. readonly isSupported: boolean;
  39575. addEffect(renderEffect: PostProcessRenderEffect): void;
  39576. /** @hidden */
  39577. _rebuild(): void;
  39578. /** @hidden */
  39579. _enableEffect(renderEffectName: string, cameras: Camera): void;
  39580. /** @hidden */
  39581. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  39582. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  39583. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  39584. /** @hidden */
  39585. _attachCameras(cameras: Camera, unique: boolean): void;
  39586. /** @hidden */
  39587. _attachCameras(cameras: Camera[], unique: boolean): void;
  39588. /** @hidden */
  39589. _detachCameras(cameras: Camera): void;
  39590. /** @hidden */
  39591. _detachCameras(cameras: Nullable<Camera[]>): void;
  39592. /** @hidden */
  39593. _update(): void;
  39594. /** @hidden */
  39595. _reset(): void;
  39596. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  39597. dispose(): void;
  39598. }
  39599. }
  39600. declare module BABYLON {
  39601. class PostProcessRenderPipelineManager {
  39602. private _renderPipelines;
  39603. constructor();
  39604. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  39605. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  39606. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  39607. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  39608. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  39609. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  39610. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  39611. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  39612. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  39613. update(): void;
  39614. /** @hidden */
  39615. _rebuild(): void;
  39616. dispose(): void;
  39617. }
  39618. }
  39619. declare module BABYLON {
  39620. interface Scene {
  39621. /** @hidden (Backing field) */
  39622. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  39623. /**
  39624. * Gets the postprocess render pipeline manager
  39625. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  39626. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  39627. */
  39628. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  39629. }
  39630. /**
  39631. * Defines the Render Pipeline scene component responsible to rendering pipelines
  39632. */
  39633. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  39634. /**
  39635. * The component name helpfull to identify the component in the list of scene components.
  39636. */
  39637. readonly name: string;
  39638. /**
  39639. * The scene the component belongs to.
  39640. */
  39641. scene: Scene;
  39642. /**
  39643. * Creates a new instance of the component for the given scene
  39644. * @param scene Defines the scene to register the component in
  39645. */
  39646. constructor(scene: Scene);
  39647. /**
  39648. * Registers the component in a given scene
  39649. */
  39650. register(): void;
  39651. /**
  39652. * Rebuilds the elements related to this component in case of
  39653. * context lost for instance.
  39654. */
  39655. rebuild(): void;
  39656. /**
  39657. * Disposes the component and the associated ressources
  39658. */
  39659. dispose(): void;
  39660. private _gatherRenderTargets;
  39661. }
  39662. }
  39663. declare module BABYLON {
  39664. /**
  39665. * Helper class dealing with the extraction of spherical polynomial dataArray
  39666. * from a cube map.
  39667. */
  39668. class CubeMapToSphericalPolynomialTools {
  39669. private static FileFaces;
  39670. /**
  39671. * Converts a texture to the according Spherical Polynomial data.
  39672. * This extracts the first 3 orders only as they are the only one used in the lighting.
  39673. *
  39674. * @param texture The texture to extract the information from.
  39675. * @return The Spherical Polynomial data.
  39676. */
  39677. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  39678. /**
  39679. * Converts a cubemap to the according Spherical Polynomial data.
  39680. * This extracts the first 3 orders only as they are the only one used in the lighting.
  39681. *
  39682. * @param cubeInfo The Cube map to extract the information from.
  39683. * @return The Spherical Polynomial data.
  39684. */
  39685. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  39686. }
  39687. }
  39688. declare module BABYLON {
  39689. /**
  39690. * Header information of HDR texture files.
  39691. */
  39692. interface HDRInfo {
  39693. /**
  39694. * The height of the texture in pixels.
  39695. */
  39696. height: number;
  39697. /**
  39698. * The width of the texture in pixels.
  39699. */
  39700. width: number;
  39701. /**
  39702. * The index of the beginning of the data in the binary file.
  39703. */
  39704. dataPosition: number;
  39705. }
  39706. /**
  39707. * This groups tools to convert HDR texture to native colors array.
  39708. */
  39709. class HDRTools {
  39710. private static Ldexp;
  39711. private static Rgbe2float;
  39712. private static readStringLine;
  39713. /**
  39714. * Reads header information from an RGBE texture stored in a native array.
  39715. * More information on this format are available here:
  39716. * https://en.wikipedia.org/wiki/RGBE_image_format
  39717. *
  39718. * @param uint8array The binary file stored in native array.
  39719. * @return The header information.
  39720. */
  39721. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  39722. /**
  39723. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  39724. * This RGBE texture needs to store the information as a panorama.
  39725. *
  39726. * More information on this format are available here:
  39727. * https://en.wikipedia.org/wiki/RGBE_image_format
  39728. *
  39729. * @param buffer The binary file stored in an array buffer.
  39730. * @param size The expected size of the extracted cubemap.
  39731. * @return The Cube Map information.
  39732. */
  39733. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  39734. /**
  39735. * Returns the pixels data extracted from an RGBE texture.
  39736. * This pixels will be stored left to right up to down in the R G B order in one array.
  39737. *
  39738. * More information on this format are available here:
  39739. * https://en.wikipedia.org/wiki/RGBE_image_format
  39740. *
  39741. * @param uint8array The binary file stored in an array buffer.
  39742. * @param hdrInfo The header information of the file.
  39743. * @return The pixels data in RGB right to left up to down order.
  39744. */
  39745. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  39746. private static RGBE_ReadPixels_RLE;
  39747. }
  39748. }
  39749. declare module BABYLON {
  39750. /**
  39751. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  39752. */
  39753. interface CubeMapInfo {
  39754. /**
  39755. * The pixel array for the front face.
  39756. * This is stored in format, left to right, up to down format.
  39757. */
  39758. front: Nullable<ArrayBufferView>;
  39759. /**
  39760. * The pixel array for the back face.
  39761. * This is stored in format, left to right, up to down format.
  39762. */
  39763. back: Nullable<ArrayBufferView>;
  39764. /**
  39765. * The pixel array for the left face.
  39766. * This is stored in format, left to right, up to down format.
  39767. */
  39768. left: Nullable<ArrayBufferView>;
  39769. /**
  39770. * The pixel array for the right face.
  39771. * This is stored in format, left to right, up to down format.
  39772. */
  39773. right: Nullable<ArrayBufferView>;
  39774. /**
  39775. * The pixel array for the up face.
  39776. * This is stored in format, left to right, up to down format.
  39777. */
  39778. up: Nullable<ArrayBufferView>;
  39779. /**
  39780. * The pixel array for the down face.
  39781. * This is stored in format, left to right, up to down format.
  39782. */
  39783. down: Nullable<ArrayBufferView>;
  39784. /**
  39785. * The size of the cubemap stored.
  39786. *
  39787. * Each faces will be size * size pixels.
  39788. */
  39789. size: number;
  39790. /**
  39791. * The format of the texture.
  39792. *
  39793. * RGBA, RGB.
  39794. */
  39795. format: number;
  39796. /**
  39797. * The type of the texture data.
  39798. *
  39799. * UNSIGNED_INT, FLOAT.
  39800. */
  39801. type: number;
  39802. /**
  39803. * Specifies whether the texture is in gamma space.
  39804. */
  39805. gammaSpace: boolean;
  39806. }
  39807. /**
  39808. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  39809. */
  39810. class PanoramaToCubeMapTools {
  39811. private static FACE_FRONT;
  39812. private static FACE_BACK;
  39813. private static FACE_RIGHT;
  39814. private static FACE_LEFT;
  39815. private static FACE_DOWN;
  39816. private static FACE_UP;
  39817. /**
  39818. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  39819. *
  39820. * @param float32Array The source data.
  39821. * @param inputWidth The width of the input panorama.
  39822. * @param inputhHeight The height of the input panorama.
  39823. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  39824. * @return The cubemap data
  39825. */
  39826. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  39827. private static CreateCubemapTexture;
  39828. private static CalcProjectionSpherical;
  39829. }
  39830. }
  39831. declare module BABYLON {
  39832. }
  39833. declare module BABYLON {
  39834. }
  39835. declare module BABYLON {
  39836. }
  39837. declare module BABYLON {
  39838. }
  39839. declare module BABYLON {
  39840. class CustomProceduralTexture extends ProceduralTexture {
  39841. private _animate;
  39842. private _time;
  39843. private _config;
  39844. private _texturePath;
  39845. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  39846. private loadJson;
  39847. isReady(): boolean;
  39848. render(useCameraPostProcess?: boolean): void;
  39849. updateTextures(): void;
  39850. updateShaderUniforms(): void;
  39851. animate: boolean;
  39852. }
  39853. }
  39854. declare module BABYLON {
  39855. /**
  39856. * Class used to generate noise procedural textures
  39857. */
  39858. class NoiseProceduralTexture extends ProceduralTexture {
  39859. private _time;
  39860. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  39861. brightness: number;
  39862. /** Defines the number of octaves to process */
  39863. octaves: number;
  39864. /** Defines the level of persistence (0.8 by default) */
  39865. persistence: number;
  39866. /** Gets or sets animation speed factor (default is 1) */
  39867. animationSpeedFactor: number;
  39868. /**
  39869. * Creates a new NoiseProceduralTexture
  39870. * @param name defines the name fo the texture
  39871. * @param size defines the size of the texture (default is 256)
  39872. * @param scene defines the hosting scene
  39873. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  39874. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  39875. */
  39876. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  39877. private _updateShaderUniforms;
  39878. protected _getDefines(): string;
  39879. /** Generate the current state of the procedural texture */
  39880. render(useCameraPostProcess?: boolean): void;
  39881. /**
  39882. * Serializes this noise procedural texture
  39883. * @returns a serialized noise procedural texture object
  39884. */
  39885. serialize(): any;
  39886. /**
  39887. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  39888. * @param parsedTexture defines parsed texture data
  39889. * @param scene defines the current scene
  39890. * @param rootUrl defines the root URL containing noise procedural texture information
  39891. * @returns a parsed NoiseProceduralTexture
  39892. */
  39893. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  39894. }
  39895. }
  39896. declare module BABYLON {
  39897. class ProceduralTexture extends Texture {
  39898. isCube: boolean;
  39899. private _size;
  39900. /** @hidden */
  39901. _generateMipMaps: boolean;
  39902. isEnabled: boolean;
  39903. private _currentRefreshId;
  39904. private _refreshRate;
  39905. onGenerated: () => void;
  39906. private _vertexBuffers;
  39907. private _indexBuffer;
  39908. /** get the internal effect */
  39909. _effect: Effect;
  39910. private _uniforms;
  39911. private _samplers;
  39912. private _fragment;
  39913. /** @hidden */
  39914. _textures: {
  39915. [key: string]: Texture;
  39916. };
  39917. private _floats;
  39918. private _ints;
  39919. private _floatsArrays;
  39920. private _colors3;
  39921. private _colors4;
  39922. private _vectors2;
  39923. private _vectors3;
  39924. private _matrices;
  39925. private _fallbackTexture;
  39926. private _fallbackTextureUsed;
  39927. private _engine;
  39928. private _cachedDefines;
  39929. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  39930. private _createIndexBuffer;
  39931. /** @hidden */
  39932. _rebuild(): void;
  39933. reset(): void;
  39934. protected _getDefines(): string;
  39935. isReady(): boolean;
  39936. resetRefreshCounter(): void;
  39937. setFragment(fragment: any): void;
  39938. refreshRate: number;
  39939. /** @hidden */
  39940. _shouldRender(): boolean;
  39941. getRenderSize(): number;
  39942. resize(size: number, generateMipMaps: boolean): void;
  39943. private _checkUniform;
  39944. setTexture(name: string, texture: Texture): ProceduralTexture;
  39945. setFloat(name: string, value: number): ProceduralTexture;
  39946. /**
  39947. * Set the value of an uniform to an integer value
  39948. * @param name defines the name of the uniform
  39949. * @param value defines the value to set
  39950. * @returns the current procedural texture
  39951. */
  39952. setInt(name: string, value: number): ProceduralTexture;
  39953. setFloats(name: string, value: number[]): ProceduralTexture;
  39954. setColor3(name: string, value: Color3): ProceduralTexture;
  39955. setColor4(name: string, value: Color4): ProceduralTexture;
  39956. setVector2(name: string, value: Vector2): ProceduralTexture;
  39957. setVector3(name: string, value: Vector3): ProceduralTexture;
  39958. setMatrix(name: string, value: Matrix): ProceduralTexture;
  39959. render(useCameraPostProcess?: boolean): void;
  39960. clone(): ProceduralTexture;
  39961. dispose(): void;
  39962. }
  39963. }
  39964. declare module BABYLON {
  39965. interface AbstractScene {
  39966. /**
  39967. * The list of procedural textures added to the scene
  39968. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  39969. */
  39970. proceduralTextures: Array<ProceduralTexture>;
  39971. }
  39972. /**
  39973. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  39974. * in a given scene.
  39975. */
  39976. class ProceduralTextureSceneComponent implements ISceneComponent {
  39977. /**
  39978. * The component name helpfull to identify the component in the list of scene components.
  39979. */
  39980. readonly name: string;
  39981. /**
  39982. * The scene the component belongs to.
  39983. */
  39984. scene: Scene;
  39985. /**
  39986. * Creates a new instance of the component for the given scene
  39987. * @param scene Defines the scene to register the component in
  39988. */
  39989. constructor(scene: Scene);
  39990. /**
  39991. * Registers the component in a given scene
  39992. */
  39993. register(): void;
  39994. /**
  39995. * Rebuilds the elements related to this component in case of
  39996. * context lost for instance.
  39997. */
  39998. rebuild(): void;
  39999. /**
  40000. * Disposes the component and the associated ressources.
  40001. */
  40002. dispose(): void;
  40003. private _beforeClear;
  40004. }
  40005. }
  40006. declare module BABYLON {
  40007. /**
  40008. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  40009. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  40010. */
  40011. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  40012. private _scene;
  40013. private _camerasToBeAttached;
  40014. /**
  40015. * ID of the sharpen post process,
  40016. */
  40017. private readonly SharpenPostProcessId;
  40018. /**
  40019. * ID of the image processing post process;
  40020. */
  40021. readonly ImageProcessingPostProcessId: string;
  40022. /**
  40023. * ID of the Fast Approximate Anti-Aliasing post process;
  40024. */
  40025. readonly FxaaPostProcessId: string;
  40026. /**
  40027. * ID of the chromatic aberration post process,
  40028. */
  40029. private readonly ChromaticAberrationPostProcessId;
  40030. /**
  40031. * ID of the grain post process
  40032. */
  40033. private readonly GrainPostProcessId;
  40034. /**
  40035. * Sharpen post process which will apply a sharpen convolution to enhance edges
  40036. */
  40037. sharpen: SharpenPostProcess;
  40038. private _sharpenEffect;
  40039. private bloom;
  40040. /**
  40041. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  40042. */
  40043. depthOfField: DepthOfFieldEffect;
  40044. /**
  40045. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  40046. */
  40047. fxaa: FxaaPostProcess;
  40048. /**
  40049. * Image post processing pass used to perform operations such as tone mapping or color grading.
  40050. */
  40051. imageProcessing: ImageProcessingPostProcess;
  40052. /**
  40053. * Chromatic aberration post process which will shift rgb colors in the image
  40054. */
  40055. chromaticAberration: ChromaticAberrationPostProcess;
  40056. private _chromaticAberrationEffect;
  40057. /**
  40058. * Grain post process which add noise to the image
  40059. */
  40060. grain: GrainPostProcess;
  40061. private _grainEffect;
  40062. /**
  40063. * Glow post process which adds a glow to emmisive areas of the image
  40064. */
  40065. private _glowLayer;
  40066. /**
  40067. * Animations which can be used to tweak settings over a period of time
  40068. */
  40069. animations: Animation[];
  40070. private _imageProcessingConfigurationObserver;
  40071. private _sharpenEnabled;
  40072. private _bloomEnabled;
  40073. private _depthOfFieldEnabled;
  40074. private _depthOfFieldBlurLevel;
  40075. private _fxaaEnabled;
  40076. private _imageProcessingEnabled;
  40077. private _defaultPipelineTextureType;
  40078. private _bloomScale;
  40079. private _chromaticAberrationEnabled;
  40080. private _grainEnabled;
  40081. private _buildAllowed;
  40082. /**
  40083. * Enable or disable the sharpen process from the pipeline
  40084. */
  40085. sharpenEnabled: boolean;
  40086. private _resizeObserver;
  40087. private _hardwareScaleLevel;
  40088. private _bloomKernel;
  40089. /**
  40090. * Specifies the size of the bloom blur kernel, relative to the final output size
  40091. */
  40092. bloomKernel: number;
  40093. /**
  40094. * Specifies the weight of the bloom in the final rendering
  40095. */
  40096. private _bloomWeight;
  40097. /**
  40098. * Specifies the luma threshold for the area that will be blurred by the bloom
  40099. */
  40100. private _bloomThreshold;
  40101. private _hdr;
  40102. /**
  40103. * The strength of the bloom.
  40104. */
  40105. bloomWeight: number;
  40106. /**
  40107. * The strength of the bloom.
  40108. */
  40109. bloomThreshold: number;
  40110. /**
  40111. * The scale of the bloom, lower value will provide better performance.
  40112. */
  40113. bloomScale: number;
  40114. /**
  40115. * Enable or disable the bloom from the pipeline
  40116. */
  40117. bloomEnabled: boolean;
  40118. private _rebuildBloom;
  40119. /**
  40120. * If the depth of field is enabled.
  40121. */
  40122. depthOfFieldEnabled: boolean;
  40123. /**
  40124. * Blur level of the depth of field effect. (Higher blur will effect performance)
  40125. */
  40126. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  40127. /**
  40128. * If the anti aliasing is enabled.
  40129. */
  40130. fxaaEnabled: boolean;
  40131. private _samples;
  40132. /**
  40133. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  40134. */
  40135. samples: number;
  40136. /**
  40137. * If image processing is enabled.
  40138. */
  40139. imageProcessingEnabled: boolean;
  40140. /**
  40141. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  40142. */
  40143. glowLayerEnabled: boolean;
  40144. /**
  40145. * Enable or disable the chromaticAberration process from the pipeline
  40146. */
  40147. chromaticAberrationEnabled: boolean;
  40148. /**
  40149. * Enable or disable the grain process from the pipeline
  40150. */
  40151. grainEnabled: boolean;
  40152. /**
  40153. * @constructor
  40154. * @param {string} name - The rendering pipeline name (default: "")
  40155. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  40156. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  40157. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  40158. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  40159. */
  40160. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  40161. /**
  40162. * Force the compilation of the entire pipeline.
  40163. */
  40164. prepare(): void;
  40165. private _hasCleared;
  40166. private _prevPostProcess;
  40167. private _prevPrevPostProcess;
  40168. private _setAutoClearAndTextureSharing;
  40169. private _depthOfFieldSceneObserver;
  40170. private _buildPipeline;
  40171. private _disposePostProcesses;
  40172. /**
  40173. * Adds a camera to the pipeline
  40174. * @param camera the camera to be added
  40175. */
  40176. addCamera(camera: Camera): void;
  40177. /**
  40178. * Removes a camera from the pipeline
  40179. * @param camera the camera to remove
  40180. */
  40181. removeCamera(camera: Camera): void;
  40182. /**
  40183. * Dispose of the pipeline and stop all post processes
  40184. */
  40185. dispose(): void;
  40186. /**
  40187. * Serialize the rendering pipeline (Used when exporting)
  40188. * @returns the serialized object
  40189. */
  40190. serialize(): any;
  40191. /**
  40192. * Parse the serialized pipeline
  40193. * @param source Source pipeline.
  40194. * @param scene The scene to load the pipeline to.
  40195. * @param rootUrl The URL of the serialized pipeline.
  40196. * @returns An instantiated pipeline from the serialized object.
  40197. */
  40198. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  40199. }
  40200. }
  40201. declare module BABYLON {
  40202. class LensRenderingPipeline extends PostProcessRenderPipeline {
  40203. /**
  40204. * The chromatic aberration PostProcess id in the pipeline
  40205. */
  40206. LensChromaticAberrationEffect: string;
  40207. /**
  40208. * The highlights enhancing PostProcess id in the pipeline
  40209. */
  40210. HighlightsEnhancingEffect: string;
  40211. /**
  40212. * The depth-of-field PostProcess id in the pipeline
  40213. */
  40214. LensDepthOfFieldEffect: string;
  40215. private _scene;
  40216. private _depthTexture;
  40217. private _grainTexture;
  40218. private _chromaticAberrationPostProcess;
  40219. private _highlightsPostProcess;
  40220. private _depthOfFieldPostProcess;
  40221. private _edgeBlur;
  40222. private _grainAmount;
  40223. private _chromaticAberration;
  40224. private _distortion;
  40225. private _highlightsGain;
  40226. private _highlightsThreshold;
  40227. private _dofDistance;
  40228. private _dofAperture;
  40229. private _dofDarken;
  40230. private _dofPentagon;
  40231. private _blurNoise;
  40232. /**
  40233. * @constructor
  40234. *
  40235. * Effect parameters are as follow:
  40236. * {
  40237. * chromatic_aberration: number; // from 0 to x (1 for realism)
  40238. * edge_blur: number; // from 0 to x (1 for realism)
  40239. * distortion: number; // from 0 to x (1 for realism)
  40240. * grain_amount: number; // from 0 to 1
  40241. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  40242. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  40243. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  40244. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  40245. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  40246. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  40247. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  40248. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  40249. * }
  40250. * Note: if an effect parameter is unset, effect is disabled
  40251. *
  40252. * @param {string} name - The rendering pipeline name
  40253. * @param {object} parameters - An object containing all parameters (see above)
  40254. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  40255. * @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)
  40256. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  40257. */
  40258. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  40259. setEdgeBlur(amount: number): void;
  40260. disableEdgeBlur(): void;
  40261. setGrainAmount(amount: number): void;
  40262. disableGrain(): void;
  40263. setChromaticAberration(amount: number): void;
  40264. disableChromaticAberration(): void;
  40265. setEdgeDistortion(amount: number): void;
  40266. disableEdgeDistortion(): void;
  40267. setFocusDistance(amount: number): void;
  40268. disableDepthOfField(): void;
  40269. setAperture(amount: number): void;
  40270. setDarkenOutOfFocus(amount: number): void;
  40271. enablePentagonBokeh(): void;
  40272. disablePentagonBokeh(): void;
  40273. enableNoiseBlur(): void;
  40274. disableNoiseBlur(): void;
  40275. setHighlightsGain(amount: number): void;
  40276. setHighlightsThreshold(amount: number): void;
  40277. disableHighlights(): void;
  40278. /**
  40279. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  40280. */
  40281. dispose(disableDepthRender?: boolean): void;
  40282. private _createChromaticAberrationPostProcess;
  40283. private _createHighlightsPostProcess;
  40284. private _createDepthOfFieldPostProcess;
  40285. private _createGrainTexture;
  40286. }
  40287. }
  40288. declare module BABYLON {
  40289. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  40290. /**
  40291. * The PassPostProcess id in the pipeline that contains the original scene color
  40292. */
  40293. SSAOOriginalSceneColorEffect: string;
  40294. /**
  40295. * The SSAO PostProcess id in the pipeline
  40296. */
  40297. SSAORenderEffect: string;
  40298. /**
  40299. * The horizontal blur PostProcess id in the pipeline
  40300. */
  40301. SSAOBlurHRenderEffect: string;
  40302. /**
  40303. * The vertical blur PostProcess id in the pipeline
  40304. */
  40305. SSAOBlurVRenderEffect: string;
  40306. /**
  40307. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  40308. */
  40309. SSAOCombineRenderEffect: string;
  40310. /**
  40311. * The output strength of the SSAO post-process. Default value is 1.0.
  40312. */
  40313. totalStrength: number;
  40314. /**
  40315. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  40316. */
  40317. maxZ: number;
  40318. /**
  40319. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  40320. */
  40321. minZAspect: number;
  40322. private _samples;
  40323. /**
  40324. * Number of samples used for the SSAO calculations. Default value is 8
  40325. */
  40326. samples: number;
  40327. private _textureSamples;
  40328. /**
  40329. * Number of samples to use for antialiasing
  40330. */
  40331. textureSamples: number;
  40332. /**
  40333. * Ratio object used for SSAO ratio and blur ratio
  40334. */
  40335. private _ratio;
  40336. /**
  40337. * Dynamically generated sphere sampler.
  40338. */
  40339. private _sampleSphere;
  40340. /**
  40341. * Blur filter offsets
  40342. */
  40343. private _samplerOffsets;
  40344. /**
  40345. * Are we using bilateral blur ?
  40346. */
  40347. private _expensiveBlur;
  40348. expensiveBlur: boolean;
  40349. /**
  40350. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  40351. */
  40352. radius: number;
  40353. /**
  40354. * The base color of the SSAO post-process
  40355. * The final result is "base + ssao" between [0, 1]
  40356. */
  40357. base: number;
  40358. /**
  40359. * Support test.
  40360. */
  40361. static readonly IsSupported: boolean;
  40362. private _scene;
  40363. private _depthTexture;
  40364. private _normalTexture;
  40365. private _randomTexture;
  40366. private _originalColorPostProcess;
  40367. private _ssaoPostProcess;
  40368. private _blurHPostProcess;
  40369. private _blurVPostProcess;
  40370. private _ssaoCombinePostProcess;
  40371. private _firstUpdate;
  40372. /**
  40373. * @constructor
  40374. * @param {string} name - The rendering pipeline name
  40375. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  40376. * @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 }
  40377. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  40378. */
  40379. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  40380. /**
  40381. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  40382. */
  40383. dispose(disableGeometryBufferRenderer?: boolean): void;
  40384. private _createBlurPostProcess;
  40385. /** @hidden */
  40386. _rebuild(): void;
  40387. private _bits;
  40388. private _radicalInverse_VdC;
  40389. private _hammersley;
  40390. private _hemisphereSample_uniform;
  40391. private _generateHemisphere;
  40392. private _createSSAOPostProcess;
  40393. private _createSSAOCombinePostProcess;
  40394. private _createRandomTexture;
  40395. /**
  40396. * Serialize the rendering pipeline (Used when exporting)
  40397. * @returns the serialized object
  40398. */
  40399. serialize(): any;
  40400. /**
  40401. * Parse the serialized pipeline
  40402. * @param source Source pipeline.
  40403. * @param scene The scene to load the pipeline to.
  40404. * @param rootUrl The URL of the serialized pipeline.
  40405. * @returns An instantiated pipeline from the serialized object.
  40406. */
  40407. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  40408. }
  40409. }
  40410. declare module BABYLON {
  40411. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  40412. /**
  40413. * The PassPostProcess id in the pipeline that contains the original scene color
  40414. */
  40415. SSAOOriginalSceneColorEffect: string;
  40416. /**
  40417. * The SSAO PostProcess id in the pipeline
  40418. */
  40419. SSAORenderEffect: string;
  40420. /**
  40421. * The horizontal blur PostProcess id in the pipeline
  40422. */
  40423. SSAOBlurHRenderEffect: string;
  40424. /**
  40425. * The vertical blur PostProcess id in the pipeline
  40426. */
  40427. SSAOBlurVRenderEffect: string;
  40428. /**
  40429. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  40430. */
  40431. SSAOCombineRenderEffect: string;
  40432. /**
  40433. * The output strength of the SSAO post-process. Default value is 1.0.
  40434. */
  40435. totalStrength: number;
  40436. /**
  40437. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  40438. */
  40439. radius: number;
  40440. /**
  40441. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  40442. * Must not be equal to fallOff and superior to fallOff.
  40443. * Default value is 0.975
  40444. */
  40445. area: number;
  40446. /**
  40447. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  40448. * Must not be equal to area and inferior to area.
  40449. * Default value is 0.0
  40450. */
  40451. fallOff: number;
  40452. /**
  40453. * The base color of the SSAO post-process
  40454. * The final result is "base + ssao" between [0, 1]
  40455. */
  40456. base: number;
  40457. private _scene;
  40458. private _depthTexture;
  40459. private _randomTexture;
  40460. private _originalColorPostProcess;
  40461. private _ssaoPostProcess;
  40462. private _blurHPostProcess;
  40463. private _blurVPostProcess;
  40464. private _ssaoCombinePostProcess;
  40465. private _firstUpdate;
  40466. /**
  40467. * @constructor
  40468. * @param {string} name - The rendering pipeline name
  40469. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  40470. * @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 }
  40471. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  40472. */
  40473. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  40474. /**
  40475. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  40476. */
  40477. dispose(disableDepthRender?: boolean): void;
  40478. private _createBlurPostProcess;
  40479. /** @hidden */
  40480. _rebuild(): void;
  40481. private _createSSAOPostProcess;
  40482. private _createSSAOCombinePostProcess;
  40483. private _createRandomTexture;
  40484. }
  40485. }
  40486. declare module BABYLON {
  40487. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  40488. /**
  40489. * Public members
  40490. */
  40491. /**
  40492. * Post-process which contains the original scene color before the pipeline applies all the effects
  40493. */
  40494. originalPostProcess: Nullable<PostProcess>;
  40495. /**
  40496. * Post-process used to down scale an image x4
  40497. */
  40498. downSampleX4PostProcess: Nullable<PostProcess>;
  40499. /**
  40500. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  40501. */
  40502. brightPassPostProcess: Nullable<PostProcess>;
  40503. /**
  40504. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  40505. */
  40506. blurHPostProcesses: PostProcess[];
  40507. /**
  40508. * Post-process array storing all the vertical blur post-processes used by the pipeline
  40509. */
  40510. blurVPostProcesses: PostProcess[];
  40511. /**
  40512. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  40513. */
  40514. textureAdderPostProcess: Nullable<PostProcess>;
  40515. /**
  40516. * Post-process used to create volumetric lighting effect
  40517. */
  40518. volumetricLightPostProcess: Nullable<PostProcess>;
  40519. /**
  40520. * Post-process used to smooth the previous volumetric light post-process on the X axis
  40521. */
  40522. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  40523. /**
  40524. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  40525. */
  40526. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  40527. /**
  40528. * Post-process used to merge the volumetric light effect and the real scene color
  40529. */
  40530. volumetricLightMergePostProces: Nullable<PostProcess>;
  40531. /**
  40532. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  40533. */
  40534. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  40535. /**
  40536. * Base post-process used to calculate the average luminance of the final image for HDR
  40537. */
  40538. luminancePostProcess: Nullable<PostProcess>;
  40539. /**
  40540. * Post-processes used to create down sample post-processes in order to get
  40541. * the average luminance of the final image for HDR
  40542. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  40543. */
  40544. luminanceDownSamplePostProcesses: PostProcess[];
  40545. /**
  40546. * Post-process used to create a HDR effect (light adaptation)
  40547. */
  40548. hdrPostProcess: Nullable<PostProcess>;
  40549. /**
  40550. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  40551. */
  40552. textureAdderFinalPostProcess: Nullable<PostProcess>;
  40553. /**
  40554. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  40555. */
  40556. lensFlareFinalPostProcess: Nullable<PostProcess>;
  40557. /**
  40558. * Post-process used to merge the final HDR post-process and the real scene color
  40559. */
  40560. hdrFinalPostProcess: Nullable<PostProcess>;
  40561. /**
  40562. * Post-process used to create a lens flare effect
  40563. */
  40564. lensFlarePostProcess: Nullable<PostProcess>;
  40565. /**
  40566. * Post-process that merges the result of the lens flare post-process and the real scene color
  40567. */
  40568. lensFlareComposePostProcess: Nullable<PostProcess>;
  40569. /**
  40570. * Post-process used to create a motion blur effect
  40571. */
  40572. motionBlurPostProcess: Nullable<PostProcess>;
  40573. /**
  40574. * Post-process used to create a depth of field effect
  40575. */
  40576. depthOfFieldPostProcess: Nullable<PostProcess>;
  40577. /**
  40578. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  40579. */
  40580. fxaaPostProcess: Nullable<FxaaPostProcess>;
  40581. /**
  40582. * Represents the brightness threshold in order to configure the illuminated surfaces
  40583. */
  40584. brightThreshold: number;
  40585. /**
  40586. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  40587. */
  40588. blurWidth: number;
  40589. /**
  40590. * Sets if the blur for highlighted surfaces must be only horizontal
  40591. */
  40592. horizontalBlur: boolean;
  40593. /**
  40594. * Sets the overall exposure used by the pipeline
  40595. */
  40596. exposure: number;
  40597. /**
  40598. * Texture used typically to simulate "dirty" on camera lens
  40599. */
  40600. lensTexture: Nullable<Texture>;
  40601. /**
  40602. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  40603. */
  40604. volumetricLightCoefficient: number;
  40605. /**
  40606. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  40607. */
  40608. volumetricLightPower: number;
  40609. /**
  40610. * Used the set the blur intensity to smooth the volumetric lights
  40611. */
  40612. volumetricLightBlurScale: number;
  40613. /**
  40614. * Light (spot or directional) used to generate the volumetric lights rays
  40615. * The source light must have a shadow generate so the pipeline can get its
  40616. * depth map
  40617. */
  40618. sourceLight: Nullable<SpotLight | DirectionalLight>;
  40619. /**
  40620. * For eye adaptation, represents the minimum luminance the eye can see
  40621. */
  40622. hdrMinimumLuminance: number;
  40623. /**
  40624. * For eye adaptation, represents the decrease luminance speed
  40625. */
  40626. hdrDecreaseRate: number;
  40627. /**
  40628. * For eye adaptation, represents the increase luminance speed
  40629. */
  40630. hdrIncreaseRate: number;
  40631. /**
  40632. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  40633. */
  40634. lensColorTexture: Nullable<Texture>;
  40635. /**
  40636. * The overall strengh for the lens flare effect
  40637. */
  40638. lensFlareStrength: number;
  40639. /**
  40640. * Dispersion coefficient for lens flare ghosts
  40641. */
  40642. lensFlareGhostDispersal: number;
  40643. /**
  40644. * Main lens flare halo width
  40645. */
  40646. lensFlareHaloWidth: number;
  40647. /**
  40648. * Based on the lens distortion effect, defines how much the lens flare result
  40649. * is distorted
  40650. */
  40651. lensFlareDistortionStrength: number;
  40652. /**
  40653. * Lens star texture must be used to simulate rays on the flares and is available
  40654. * in the documentation
  40655. */
  40656. lensStarTexture: Nullable<Texture>;
  40657. /**
  40658. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  40659. * flare effect by taking account of the dirt texture
  40660. */
  40661. lensFlareDirtTexture: Nullable<Texture>;
  40662. /**
  40663. * Represents the focal length for the depth of field effect
  40664. */
  40665. depthOfFieldDistance: number;
  40666. /**
  40667. * Represents the blur intensity for the blurred part of the depth of field effect
  40668. */
  40669. depthOfFieldBlurWidth: number;
  40670. /**
  40671. * For motion blur, defines how much the image is blurred by the movement
  40672. */
  40673. motionStrength: number;
  40674. /**
  40675. * List of animations for the pipeline (IAnimatable implementation)
  40676. */
  40677. animations: Animation[];
  40678. /**
  40679. * Private members
  40680. */
  40681. private _scene;
  40682. private _currentDepthOfFieldSource;
  40683. private _basePostProcess;
  40684. private _hdrCurrentLuminance;
  40685. private _floatTextureType;
  40686. private _ratio;
  40687. private _bloomEnabled;
  40688. private _depthOfFieldEnabled;
  40689. private _vlsEnabled;
  40690. private _lensFlareEnabled;
  40691. private _hdrEnabled;
  40692. private _motionBlurEnabled;
  40693. private _fxaaEnabled;
  40694. private _motionBlurSamples;
  40695. private _volumetricLightStepsCount;
  40696. private _samples;
  40697. /**
  40698. * Specifies if the bloom pipeline is enabled
  40699. */
  40700. BloomEnabled: boolean;
  40701. /**
  40702. * Specifies if the depth of field pipeline is enabed
  40703. */
  40704. DepthOfFieldEnabled: boolean;
  40705. /**
  40706. * Specifies if the lens flare pipeline is enabed
  40707. */
  40708. LensFlareEnabled: boolean;
  40709. /**
  40710. * Specifies if the HDR pipeline is enabled
  40711. */
  40712. HDREnabled: boolean;
  40713. /**
  40714. * Specifies if the volumetric lights scattering effect is enabled
  40715. */
  40716. VLSEnabled: boolean;
  40717. /**
  40718. * Specifies if the motion blur effect is enabled
  40719. */
  40720. MotionBlurEnabled: boolean;
  40721. /**
  40722. * Specifies if anti-aliasing is enabled
  40723. */
  40724. fxaaEnabled: boolean;
  40725. /**
  40726. * Specifies the number of steps used to calculate the volumetric lights
  40727. * Typically in interval [50, 200]
  40728. */
  40729. volumetricLightStepsCount: number;
  40730. /**
  40731. * Specifies the number of samples used for the motion blur effect
  40732. * Typically in interval [16, 64]
  40733. */
  40734. motionBlurSamples: number;
  40735. /**
  40736. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  40737. */
  40738. samples: number;
  40739. /**
  40740. * @constructor
  40741. * @param {string} name - The rendering pipeline name
  40742. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  40743. * @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)
  40744. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  40745. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  40746. */
  40747. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  40748. private _buildPipeline;
  40749. private _createDownSampleX4PostProcess;
  40750. private _createBrightPassPostProcess;
  40751. private _createBlurPostProcesses;
  40752. private _createTextureAdderPostProcess;
  40753. private _createVolumetricLightPostProcess;
  40754. private _createLuminancePostProcesses;
  40755. private _createHdrPostProcess;
  40756. private _createLensFlarePostProcess;
  40757. private _createDepthOfFieldPostProcess;
  40758. private _createMotionBlurPostProcess;
  40759. private _getDepthTexture;
  40760. private _disposePostProcesses;
  40761. /**
  40762. * Dispose of the pipeline and stop all post processes
  40763. */
  40764. dispose(): void;
  40765. /**
  40766. * Serialize the rendering pipeline (Used when exporting)
  40767. * @returns the serialized object
  40768. */
  40769. serialize(): any;
  40770. /**
  40771. * Parse the serialized pipeline
  40772. * @param source Source pipeline.
  40773. * @param scene The scene to load the pipeline to.
  40774. * @param rootUrl The URL of the serialized pipeline.
  40775. * @returns An instantiated pipeline from the serialized object.
  40776. */
  40777. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  40778. static LuminanceSteps: number;
  40779. }
  40780. }