babylon.d.ts 1.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Set of assets to keep when moving a scene into an asset container.
  7. */
  8. class KeepAssets {
  9. /**
  10. * Cameras to keep.
  11. */
  12. cameras: Camera[];
  13. /**
  14. * Lights to keep.
  15. */
  16. lights: Light[];
  17. /**
  18. * Meshes to keep.
  19. */
  20. meshes: AbstractMesh[];
  21. /**
  22. * Skeletons to keep.
  23. */
  24. skeletons: Skeleton[];
  25. /**
  26. * ParticleSystems to keep.
  27. */
  28. particleSystems: IParticleSystem[];
  29. /**
  30. * Animations to keep.
  31. */
  32. animations: Animation[];
  33. /**
  34. * AnimationGroups to keep.
  35. */
  36. animationGroups: AnimationGroup[];
  37. /**
  38. * MultiMaterials to keep.
  39. */
  40. multiMaterials: MultiMaterial[];
  41. /**
  42. * Materials to keep.
  43. */
  44. materials: Material[];
  45. /**
  46. * MorphTargetManagers to keep.
  47. */
  48. morphTargetManagers: MorphTargetManager[];
  49. /**
  50. * Geometries to keep.
  51. */
  52. geometries: Geometry[];
  53. /**
  54. * TransformNodes to keep.
  55. */
  56. transformNodes: TransformNode[];
  57. /**
  58. * LensFlareSystems to keep.
  59. */
  60. lensFlareSystems: LensFlareSystem[];
  61. /**
  62. * ShadowGenerators to keep.
  63. */
  64. shadowGenerators: ShadowGenerator[];
  65. /**
  66. * ActionManagers to keep.
  67. */
  68. actionManagers: ActionManager[];
  69. /**
  70. * Sounds to keep.
  71. */
  72. sounds: Sound[];
  73. /**
  74. * Textures to keep.
  75. */
  76. textures: Texture[];
  77. /**
  78. * Effect layers to keep.
  79. */
  80. effectLayers: EffectLayer[];
  81. }
  82. /**
  83. * Container with a set of assets that can be added or removed from a scene.
  84. */
  85. class AssetContainer {
  86. /**
  87. * The scene the AssetContainer belongs to.
  88. */
  89. scene: Scene;
  90. /**
  91. * Cameras populated in the container.
  92. */
  93. cameras: Camera[];
  94. /**
  95. * Lights populated in the container.
  96. */
  97. lights: Light[];
  98. /**
  99. * Meshes populated in the container.
  100. */
  101. meshes: AbstractMesh[];
  102. /**
  103. * Skeletons populated in the container.
  104. */
  105. skeletons: Skeleton[];
  106. /**
  107. * ParticleSystems populated in the container.
  108. */
  109. particleSystems: IParticleSystem[];
  110. /**
  111. * Animations populated in the container.
  112. */
  113. animations: Animation[];
  114. /**
  115. * AnimationGroups populated in the container.
  116. */
  117. animationGroups: AnimationGroup[];
  118. /**
  119. * MultiMaterials populated in the container.
  120. */
  121. multiMaterials: MultiMaterial[];
  122. /**
  123. * Materials populated in the container.
  124. */
  125. materials: Material[];
  126. /**
  127. * MorphTargetManagers populated in the container.
  128. */
  129. morphTargetManagers: MorphTargetManager[];
  130. /**
  131. * Geometries populated in the container.
  132. */
  133. geometries: Geometry[];
  134. /**
  135. * TransformNodes populated in the container.
  136. */
  137. transformNodes: TransformNode[];
  138. /**
  139. * LensFlareSystems populated in the container.
  140. */
  141. lensFlareSystems: LensFlareSystem[];
  142. /**
  143. * ShadowGenerators populated in the container.
  144. */
  145. shadowGenerators: ShadowGenerator[];
  146. /**
  147. * ActionManagers populated in the container.
  148. */
  149. actionManagers: ActionManager[];
  150. /**
  151. * Sounds populated in the container.
  152. */
  153. sounds: Sound[];
  154. /**
  155. * Textures populated in the container.
  156. */
  157. textures: Texture[];
  158. /**
  159. * Effect layers populated in the container.
  160. */
  161. effectLayers: EffectLayer[];
  162. /**
  163. * Instantiates an AssetContainer.
  164. * @param scene The scene the AssetContainer belongs to.
  165. */
  166. constructor(scene: Scene);
  167. /**
  168. * Adds all the assets from the container to the scene.
  169. */
  170. addAllToScene(): void;
  171. /**
  172. * Removes all the assets in the container from the scene
  173. */
  174. removeAllFromScene(): void;
  175. private _moveAssets<T>(sourceAssets, targetAssets, keepAssets);
  176. /**
  177. * Removes all the assets contained in the scene and adds them to the container.
  178. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  179. */
  180. moveAllFromScene(keepAssets?: KeepAssets): void;
  181. }
  182. }
  183. interface Window {
  184. mozIndexedDB: IDBFactory;
  185. webkitIndexedDB: IDBFactory;
  186. msIndexedDB: IDBFactory;
  187. webkitURL: typeof URL;
  188. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  189. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  190. WebGLRenderingContext: WebGLRenderingContext;
  191. MSGesture: MSGesture;
  192. CANNON: any;
  193. AudioContext: AudioContext;
  194. webkitAudioContext: AudioContext;
  195. PointerEvent: any;
  196. Math: Math;
  197. Uint8Array: Uint8ArrayConstructor;
  198. Float32Array: Float32ArrayConstructor;
  199. mozURL: typeof URL;
  200. msURL: typeof URL;
  201. VRFrameData: any;
  202. DracoDecoderModule: any;
  203. }
  204. interface WebGLRenderingContext {
  205. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  206. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  207. vertexAttribDivisor(index: number, divisor: number): void;
  208. createVertexArray(): any;
  209. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  210. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  211. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  212. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  213. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  214. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  215. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  216. createQuery(): WebGLQuery;
  217. deleteQuery(query: WebGLQuery): void;
  218. beginQuery(target: number, query: WebGLQuery): void;
  219. endQuery(target: number): void;
  220. getQueryParameter(query: WebGLQuery, pname: number): any;
  221. getQuery(target: number, pname: number): any;
  222. MAX_SAMPLES: number;
  223. RGBA8: number;
  224. READ_FRAMEBUFFER: number;
  225. DRAW_FRAMEBUFFER: number;
  226. UNIFORM_BUFFER: number;
  227. HALF_FLOAT_OES: number;
  228. RGBA16F: number;
  229. RGBA32F: number;
  230. R32F: number;
  231. RG32F: number;
  232. RGB32F: number;
  233. RED: number;
  234. RG: number;
  235. UNSIGNED_INT_24_8: number;
  236. DEPTH24_STENCIL8: number;
  237. drawBuffers(buffers: number[]): void;
  238. readBuffer(src: number): void;
  239. readonly COLOR_ATTACHMENT0: number;
  240. readonly COLOR_ATTACHMENT1: number;
  241. readonly COLOR_ATTACHMENT2: number;
  242. readonly COLOR_ATTACHMENT3: number;
  243. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  244. ANY_SAMPLES_PASSED: number;
  245. QUERY_RESULT_AVAILABLE: number;
  246. QUERY_RESULT: number;
  247. }
  248. interface Document {
  249. mozCancelFullScreen(): void;
  250. msCancelFullScreen(): void;
  251. mozFullScreen: boolean;
  252. msIsFullScreen: boolean;
  253. fullscreen: boolean;
  254. mozPointerLockElement: HTMLElement;
  255. msPointerLockElement: HTMLElement;
  256. webkitPointerLockElement: HTMLElement;
  257. }
  258. interface HTMLCanvasElement {
  259. msRequestPointerLock?(): void;
  260. mozRequestPointerLock?(): void;
  261. webkitRequestPointerLock?(): void;
  262. }
  263. interface CanvasRenderingContext2D {
  264. msImageSmoothingEnabled: boolean;
  265. }
  266. interface WebGLBuffer {
  267. references: number;
  268. capacity: number;
  269. is32Bits: boolean;
  270. }
  271. interface WebGLProgram {
  272. transformFeedback?: WebGLTransformFeedback | null;
  273. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  274. }
  275. interface MouseEvent {
  276. mozMovementX: number;
  277. mozMovementY: number;
  278. webkitMovementX: number;
  279. webkitMovementY: number;
  280. msMovementX: number;
  281. msMovementY: number;
  282. }
  283. interface Navigator {
  284. mozGetVRDevices: (any: any) => any;
  285. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  286. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  287. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  288. webkitGetGamepads(): Gamepad[];
  289. msGetGamepads(): Gamepad[];
  290. webkitGamepads(): Gamepad[];
  291. }
  292. interface HTMLVideoElement {
  293. mozSrcObject: any;
  294. }
  295. interface Screen {
  296. orientation: string;
  297. mozOrientation: string;
  298. }
  299. interface Math {
  300. fround(x: number): number;
  301. imul(a: number, b: number): number;
  302. }
  303. interface EXT_disjoint_timer_query {
  304. QUERY_COUNTER_BITS_EXT: number;
  305. TIME_ELAPSED_EXT: number;
  306. TIMESTAMP_EXT: number;
  307. GPU_DISJOINT_EXT: number;
  308. QUERY_RESULT_EXT: number;
  309. QUERY_RESULT_AVAILABLE_EXT: number;
  310. queryCounterEXT(query: WebGLQuery, target: number): void;
  311. createQueryEXT(): WebGLQuery;
  312. beginQueryEXT(target: number, query: WebGLQuery): void;
  313. endQueryEXT(target: number): void;
  314. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  315. deleteQueryEXT(query: WebGLQuery): void;
  316. }
  317. interface WebGLUniformLocation {
  318. _currentState: any;
  319. }
  320. declare module BABYLON {
  321. /**
  322. * Node is the basic class for all scene objects (Mesh, Light Camera).
  323. */
  324. class Node {
  325. /**
  326. * Gets or sets the name of the node
  327. */
  328. name: string;
  329. /**
  330. * Gets or sets the id of the node
  331. */
  332. id: string;
  333. /**
  334. * Gets or sets the unique id of the node
  335. */
  336. uniqueId: number;
  337. /**
  338. * Gets or sets a string used to store user defined state for the node
  339. */
  340. state: string;
  341. /**
  342. * Gets or sets an object used to store user defined information for the node
  343. */
  344. metadata: any;
  345. /**
  346. * Gets or sets a boolean used to define if the node must be serialized
  347. */
  348. doNotSerialize: boolean;
  349. /** @ignore */
  350. _isDisposed: boolean;
  351. /**
  352. * Gets a list of Animations associated with the node
  353. */
  354. animations: Animation[];
  355. private _ranges;
  356. /**
  357. * Callback raised when the node is ready to be used
  358. */
  359. onReady: (node: Node) => void;
  360. private _isEnabled;
  361. private _isReady;
  362. /** @ignore */
  363. _currentRenderId: number;
  364. private _parentRenderId;
  365. protected _childRenderId: number;
  366. /** @ignore */
  367. _waitingParentId: Nullable<string>;
  368. private _scene;
  369. /** @ignore */
  370. _cache: any;
  371. private _parentNode;
  372. private _children;
  373. /**
  374. * Gets a boolean indicating if the node has been disposed
  375. * @returns true if the node was disposed
  376. */
  377. isDisposed(): boolean;
  378. /**
  379. * Gets or sets the parent of the node
  380. */
  381. parent: Nullable<Node>;
  382. private _animationPropertiesOverride;
  383. /**
  384. * Gets or sets the animation properties override
  385. */
  386. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  387. /**
  388. * Gets a string idenfifying the name of the class
  389. * @returns "Node" string
  390. */
  391. getClassName(): string;
  392. /**
  393. * An event triggered when the mesh is disposed
  394. */
  395. onDisposeObservable: Observable<Node>;
  396. private _onDisposeObserver;
  397. /**
  398. * Sets a callback that will be raised when the node will be disposed
  399. */
  400. onDispose: () => void;
  401. /**
  402. * Creates a new Node
  403. * @param {string} name - the name and id to be given to this node
  404. * @param {BABYLON.Scene} the scene this node will be added to
  405. */
  406. constructor(name: string, scene?: Nullable<Scene>);
  407. /**
  408. * Gets the scene of the node
  409. * @returns a {BABYLON.Scene}
  410. */
  411. getScene(): Scene;
  412. /**
  413. * Gets the engine of the node
  414. * @returns a {BABYLON.Engine}
  415. */
  416. getEngine(): Engine;
  417. private _behaviors;
  418. /**
  419. * Attach a behavior to the node
  420. * @see http://doc.babylonjs.com/features/behaviour
  421. * @param behavior defines the behavior to attach
  422. * @returns the current Node
  423. */
  424. addBehavior(behavior: Behavior<Node>): Node;
  425. /**
  426. * Remove an attached behavior
  427. * @see http://doc.babylonjs.com/features/behaviour
  428. * @param behavior defines the behavior to attach
  429. * @returns the current Node
  430. */
  431. removeBehavior(behavior: Behavior<Node>): Node;
  432. /**
  433. * Gets the list of attached behaviors
  434. * @see http://doc.babylonjs.com/features/behaviour
  435. */
  436. readonly behaviors: Behavior<Node>[];
  437. /**
  438. * Gets an attached behavior by name
  439. * @param name defines the name of the behavior to look for
  440. * @see http://doc.babylonjs.com/features/behaviour
  441. * @returns null if behavior was not found else the requested behavior
  442. */
  443. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  444. /**
  445. * Returns the world matrix of the node
  446. * @returns a matrix containing the node's world matrix
  447. */
  448. getWorldMatrix(): Matrix;
  449. /** @ignore */
  450. _initCache(): void;
  451. /** @ignore */
  452. updateCache(force?: boolean): void;
  453. /** @ignore */
  454. _updateCache(ignoreParentClass?: boolean): void;
  455. /** @ignore */
  456. _isSynchronized(): boolean;
  457. /** @ignore */
  458. _markSyncedWithParent(): void;
  459. /** @ignore */
  460. isSynchronizedWithParent(): boolean;
  461. /** @ignore */
  462. isSynchronized(updateCache?: boolean): boolean;
  463. /** @ignore */
  464. hasNewParent(update?: boolean): boolean;
  465. /**
  466. * Is this node ready to be used/rendered
  467. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  468. * @return true if the node is ready
  469. */
  470. isReady(completeCheck?: boolean): boolean;
  471. /**
  472. * Is this node enabled?
  473. * 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
  474. * @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
  475. * @return whether this node (and its parent) is enabled
  476. */
  477. isEnabled(checkAncestors?: boolean): boolean;
  478. /**
  479. * Set the enabled state of this node
  480. * @param value defines the new enabled state
  481. */
  482. setEnabled(value: boolean): void;
  483. /**
  484. * Is this node a descendant of the given node?
  485. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  486. * @param ancestor defines the parent node to inspect
  487. * @returns a boolean indicating if this node is a descendant of the given node
  488. */
  489. isDescendantOf(ancestor: Node): boolean;
  490. /** @ignore */
  491. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  492. /**
  493. * Will return all nodes that have this node as ascendant
  494. * @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
  495. * @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
  496. * @return all children nodes of all types
  497. */
  498. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  499. /**
  500. * Get all child-meshes of this node
  501. * @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
  502. * @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
  503. * @returns an array of {BABYLON.AbstractMesh}
  504. */
  505. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  506. /**
  507. * Get all child-transformNodes of this node
  508. * @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
  509. * @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
  510. * @returns an array of {BABYLON.TransformNode}
  511. */
  512. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  513. /**
  514. * Get all direct children of this node
  515. * @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
  516. * @returns an array of {BABYLON.Node}
  517. */
  518. getChildren(predicate?: (node: Node) => boolean): Node[];
  519. /** @ignore */
  520. _setReady(state: boolean): void;
  521. /**
  522. * Get an animation by name
  523. * @param name defines the name of the animation to look for
  524. * @returns null if not found else the requested animation
  525. */
  526. getAnimationByName(name: string): Nullable<Animation>;
  527. /**
  528. * Creates an animation range for this node
  529. * @param name defines the name of the range
  530. * @param from defines the starting key
  531. * @param to defines the end key
  532. */
  533. createAnimationRange(name: string, from: number, to: number): void;
  534. /**
  535. * Delete a specific animation range
  536. * @param name defines the name of the range to delete
  537. * @param deleteFrames defines if animation frames from the range must be deleted as well
  538. */
  539. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  540. /**
  541. * Get an animation range by name
  542. * @param name defines the name of the animation range to look for
  543. * @returns null if not found else the requested animation range
  544. */
  545. getAnimationRange(name: string): Nullable<AnimationRange>;
  546. /**
  547. * Will start the animation sequence
  548. * @param name defines the range frames for animation sequence
  549. * @param loop defines if the animation should loop (false by default)
  550. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  551. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  552. * @returns the object created for this animation. If range does not exist, it will return null
  553. */
  554. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  555. /**
  556. * Serialize animation ranges into a JSON compatible object
  557. * @returns serialization object
  558. */
  559. serializeAnimationRanges(): any;
  560. /**
  561. * Computes the world matrix of the node
  562. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  563. * @returns the world matrix
  564. */
  565. computeWorldMatrix(force?: boolean): Matrix;
  566. /**
  567. * Releases resources associated with this node.
  568. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  569. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  570. */
  571. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  572. /**
  573. * Parse animation range data from a serialization object and store them into a given node
  574. * @param node defines where to store the animation ranges
  575. * @param parsedNode defines the serialization object to read data from
  576. * @param scene defines the hosting scene
  577. */
  578. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  579. }
  580. }
  581. declare module BABYLON {
  582. /**
  583. * Define an interface for all classes that will hold resources
  584. */
  585. interface IDisposable {
  586. /**
  587. * Releases all held resources
  588. */
  589. dispose(): void;
  590. }
  591. /**
  592. * Interface used to let developers provide their own mesh selection mechanism
  593. */
  594. interface IActiveMeshCandidateProvider {
  595. /**
  596. * Return the list of active meshes
  597. * @param scene defines the current scene
  598. * @returns the list of active meshes
  599. */
  600. getMeshes(scene: Scene): AbstractMesh[];
  601. /**
  602. * Indicates if the meshes have been checked to make sure they are isEnabled()
  603. */
  604. readonly checksIsEnabled: boolean;
  605. }
  606. /**
  607. * This class is used by the onRenderingGroupObservable
  608. */
  609. class RenderingGroupInfo {
  610. /**
  611. * The Scene that being rendered
  612. */
  613. scene: Scene;
  614. /**
  615. * The camera currently used for the rendering pass
  616. */
  617. camera: Nullable<Camera>;
  618. /**
  619. * The ID of the renderingGroup being processed
  620. */
  621. renderingGroupId: number;
  622. /**
  623. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  624. */
  625. renderStage: number;
  626. /**
  627. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  628. * This stage will be fired no matter what
  629. */
  630. static STAGE_PRECLEAR: number;
  631. /**
  632. * Called before opaque object are rendered.
  633. * This stage will be fired only if there's 3D Opaque content to render
  634. */
  635. static STAGE_PREOPAQUE: number;
  636. /**
  637. * Called after the opaque objects are rendered and before the transparent ones
  638. * This stage will be fired only if there's 3D transparent content to render
  639. */
  640. static STAGE_PRETRANSPARENT: number;
  641. /**
  642. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  643. * This stage will be fired no matter what
  644. */
  645. static STAGE_POSTTRANSPARENT: number;
  646. }
  647. /**
  648. * Represents a scene to be rendered by the engine.
  649. * @see http://doc.babylonjs.com/features/scene
  650. */
  651. class Scene implements IAnimatable {
  652. private static _FOGMODE_NONE;
  653. private static _FOGMODE_EXP;
  654. private static _FOGMODE_EXP2;
  655. private static _FOGMODE_LINEAR;
  656. private static _uniqueIdCounter;
  657. /**
  658. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  659. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  660. */
  661. static MinDeltaTime: number;
  662. /**
  663. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  664. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  665. */
  666. static MaxDeltaTime: number;
  667. /** The fog is deactivated */
  668. static readonly FOGMODE_NONE: number;
  669. /** The fog density is following an exponential function */
  670. static readonly FOGMODE_EXP: number;
  671. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  672. static readonly FOGMODE_EXP2: number;
  673. /** The fog density is following a linear function. */
  674. static readonly FOGMODE_LINEAR: number;
  675. /**
  676. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  677. */
  678. autoClear: boolean;
  679. /**
  680. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  681. */
  682. autoClearDepthAndStencil: boolean;
  683. /**
  684. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  685. */
  686. clearColor: Color4;
  687. /**
  688. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  689. */
  690. ambientColor: Color3;
  691. /** @ignore */
  692. _environmentBRDFTexture: BaseTexture;
  693. /** @ignore */
  694. protected _environmentTexture: BaseTexture;
  695. /**
  696. * Texture used in all pbr material as the reflection texture.
  697. * As in the majority of the scene they are the same (exception for multi room and so on),
  698. * this is easier to reference from here than from all the materials.
  699. */
  700. /**
  701. * Texture used in all pbr material as the reflection texture.
  702. * As in the majority of the scene they are the same (exception for multi room and so on),
  703. * this is easier to set here than in all the materials.
  704. */
  705. environmentTexture: BaseTexture;
  706. /** @ignore */
  707. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  708. /**
  709. * Default image processing configuration used either in the rendering
  710. * Forward main pass or through the imageProcessingPostProcess if present.
  711. * As in the majority of the scene they are the same (exception for multi camera),
  712. * this is easier to reference from here than from all the materials and post process.
  713. *
  714. * No setter as we it is a shared configuration, you can set the values instead.
  715. */
  716. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  717. private _forceWireframe;
  718. /**
  719. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  720. */
  721. forceWireframe: boolean;
  722. private _forcePointsCloud;
  723. /**
  724. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  725. */
  726. forcePointsCloud: boolean;
  727. /**
  728. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  729. */
  730. forceShowBoundingBoxes: boolean;
  731. /**
  732. * Gets or sets the active clipplane
  733. */
  734. clipPlane: Nullable<Plane>;
  735. /**
  736. * Gets or sets a boolean indicating if animations are enabled
  737. */
  738. animationsEnabled: boolean;
  739. private _animationPropertiesOverride;
  740. /**
  741. * Gets or sets the animation properties override
  742. */
  743. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  744. /**
  745. * Gets or sets a boolean indicating if a constant deltatime has to be used
  746. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  747. */
  748. useConstantAnimationDeltaTime: boolean;
  749. /**
  750. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  751. * Please note that it requires to run a ray cast through the scene on every frame
  752. */
  753. constantlyUpdateMeshUnderPointer: boolean;
  754. /**
  755. * Defines the HTML cursor to use when hovering over interactive elements
  756. */
  757. hoverCursor: string;
  758. /**
  759. * Defines the HTML default cursor to use (empty by default)
  760. */
  761. defaultCursor: string;
  762. /**
  763. * This is used to call preventDefault() on pointer down
  764. * in order to block unwanted artifacts like system double clicks
  765. */
  766. preventDefaultOnPointerDown: boolean;
  767. /**
  768. * Gets or sets user defined metadata
  769. */
  770. metadata: any;
  771. /**
  772. * Gets the name of the plugin used to load this scene (null by default)
  773. */
  774. loadingPluginName: string;
  775. /**
  776. * Use this array to add regular expressions used to disable offline support for specific urls
  777. */
  778. disableOfflineSupportExceptionRules: RegExp[];
  779. private _spritePredicate;
  780. /**
  781. * An event triggered when the scene is disposed.
  782. */
  783. onDisposeObservable: Observable<Scene>;
  784. private _onDisposeObserver;
  785. /** Sets a function to be executed when this scene is disposed. */
  786. onDispose: () => void;
  787. /**
  788. * An event triggered before rendering the scene (right after animations and physics)
  789. */
  790. onBeforeRenderObservable: Observable<Scene>;
  791. private _onBeforeRenderObserver;
  792. /** Sets a function to be executed before rendering this scene */
  793. beforeRender: Nullable<() => void>;
  794. /**
  795. * An event triggered after rendering the scene
  796. */
  797. onAfterRenderObservable: Observable<Scene>;
  798. private _onAfterRenderObserver;
  799. /** Sets a function to be executed after rendering this scene */
  800. afterRender: Nullable<() => void>;
  801. /**
  802. * An event triggered before animating the scene
  803. */
  804. onBeforeAnimationsObservable: Observable<Scene>;
  805. /**
  806. * An event triggered after animations processing
  807. */
  808. onAfterAnimationsObservable: Observable<Scene>;
  809. /**
  810. * An event triggered before draw calls are ready to be sent
  811. */
  812. onBeforeDrawPhaseObservable: Observable<Scene>;
  813. /**
  814. * An event triggered after draw calls have been sent
  815. */
  816. onAfterDrawPhaseObservable: Observable<Scene>;
  817. /**
  818. * An event triggered when physic simulation is about to be run
  819. */
  820. onBeforePhysicsObservable: Observable<Scene>;
  821. /**
  822. * An event triggered when physic simulation has been done
  823. */
  824. onAfterPhysicsObservable: Observable<Scene>;
  825. /**
  826. * An event triggered when the scene is ready
  827. */
  828. onReadyObservable: Observable<Scene>;
  829. /**
  830. * An event triggered before rendering a camera
  831. */
  832. onBeforeCameraRenderObservable: Observable<Camera>;
  833. private _onBeforeCameraRenderObserver;
  834. /** Sets a function to be executed before rendering a camera*/
  835. beforeCameraRender: () => void;
  836. /**
  837. * An event triggered after rendering a camera
  838. */
  839. onAfterCameraRenderObservable: Observable<Camera>;
  840. private _onAfterCameraRenderObserver;
  841. /** Sets a function to be executed after rendering a camera*/
  842. afterCameraRender: () => void;
  843. /**
  844. * An event triggered when active meshes evaluation is about to start
  845. */
  846. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  847. /**
  848. * An event triggered when active meshes evaluation is done
  849. */
  850. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  851. /**
  852. * An event triggered when particles rendering is about to start
  853. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  854. */
  855. onBeforeParticlesRenderingObservable: Observable<Scene>;
  856. /**
  857. * An event triggered when particles rendering is done
  858. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  859. */
  860. onAfterParticlesRenderingObservable: Observable<Scene>;
  861. /**
  862. * An event triggered when sprites rendering is about to start
  863. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  864. */
  865. onBeforeSpritesRenderingObservable: Observable<Scene>;
  866. /**
  867. * An event triggered when sprites rendering is done
  868. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  869. */
  870. onAfterSpritesRenderingObservable: Observable<Scene>;
  871. /**
  872. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  873. */
  874. onDataLoadedObservable: Observable<Scene>;
  875. /**
  876. * An event triggered when a camera is created
  877. */
  878. onNewCameraAddedObservable: Observable<Camera>;
  879. /**
  880. * An event triggered when a camera is removed
  881. */
  882. onCameraRemovedObservable: Observable<Camera>;
  883. /**
  884. * An event triggered when a light is created
  885. */
  886. onNewLightAddedObservable: Observable<Light>;
  887. /**
  888. * An event triggered when a light is removed
  889. */
  890. onLightRemovedObservable: Observable<Light>;
  891. /**
  892. * An event triggered when a geometry is created
  893. */
  894. onNewGeometryAddedObservable: Observable<Geometry>;
  895. /**
  896. * An event triggered when a geometry is removed
  897. */
  898. onGeometryRemovedObservable: Observable<Geometry>;
  899. /**
  900. * An event triggered when a transform node is created
  901. */
  902. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  903. /**
  904. * An event triggered when a transform node is removed
  905. */
  906. onTransformNodeRemovedObservable: Observable<TransformNode>;
  907. /**
  908. * An event triggered when a mesh is created
  909. */
  910. onNewMeshAddedObservable: Observable<AbstractMesh>;
  911. /**
  912. * An event triggered when a mesh is removed
  913. */
  914. onMeshRemovedObservable: Observable<AbstractMesh>;
  915. /**
  916. * An event triggered when render targets are about to be rendered
  917. * Can happen multiple times per frame.
  918. */
  919. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  920. /**
  921. * An event triggered when render targets were rendered.
  922. * Can happen multiple times per frame.
  923. */
  924. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  925. /**
  926. * An event triggered before calculating deterministic simulation step
  927. */
  928. onBeforeStepObservable: Observable<Scene>;
  929. /**
  930. * An event triggered after calculating deterministic simulation step
  931. */
  932. onAfterStepObservable: Observable<Scene>;
  933. /**
  934. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  935. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  936. * 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)
  937. */
  938. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  939. /**
  940. * Gets a list of Animations associated with the scene
  941. */
  942. animations: Animation[];
  943. private _registeredForLateAnimationBindings;
  944. /**
  945. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  946. */
  947. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  948. /**
  949. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  950. */
  951. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  952. /**
  953. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  954. */
  955. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  956. private _onPointerMove;
  957. private _onPointerDown;
  958. private _onPointerUp;
  959. /** Deprecated. Use onPointerObservable instead */
  960. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  961. /** Deprecated. Use onPointerObservable instead */
  962. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  963. /** Deprecated. Use onPointerObservable instead */
  964. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  965. /** Deprecated. Use onPointerObservable instead */
  966. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  967. private _gamepadManager;
  968. /**
  969. * Gets the gamepad manager associated with the scene
  970. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  971. */
  972. readonly gamepadManager: GamepadManager;
  973. /**
  974. * 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).
  975. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  976. */
  977. onPrePointerObservable: Observable<PointerInfoPre>;
  978. /**
  979. * Observable event triggered each time an input event is received from the rendering canvas
  980. */
  981. onPointerObservable: Observable<PointerInfo>;
  982. /**
  983. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  984. */
  985. readonly unTranslatedPointer: Vector2;
  986. /** The distance in pixel that you have to move to prevent some events */
  987. static DragMovementThreshold: number;
  988. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  989. static LongPressDelay: number;
  990. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  991. static DoubleClickDelay: number;
  992. /** If you need to check double click without raising a single click at first click, enable this flag */
  993. static ExclusiveDoubleClickMode: boolean;
  994. private _initClickEvent;
  995. private _initActionManager;
  996. private _delayedSimpleClick;
  997. private _delayedSimpleClickTimeout;
  998. private _previousDelayedSimpleClickTimeout;
  999. private _meshPickProceed;
  1000. private _previousButtonPressed;
  1001. private _currentPickResult;
  1002. private _previousPickResult;
  1003. private _totalPointersPressed;
  1004. private _doubleClickOccured;
  1005. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1006. cameraToUseForPointers: Nullable<Camera>;
  1007. private _pointerX;
  1008. private _pointerY;
  1009. private _unTranslatedPointerX;
  1010. private _unTranslatedPointerY;
  1011. private _startingPointerPosition;
  1012. private _previousStartingPointerPosition;
  1013. private _startingPointerTime;
  1014. private _previousStartingPointerTime;
  1015. private _timeAccumulator;
  1016. private _currentStepId;
  1017. private _currentInternalStep;
  1018. /** @ignore */
  1019. _mirroredCameraPosition: Nullable<Vector3>;
  1020. /**
  1021. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1022. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1023. */
  1024. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1025. /**
  1026. * Observable event triggered each time an keyboard event is received from the hosting window
  1027. */
  1028. onKeyboardObservable: Observable<KeyboardInfo>;
  1029. private _onKeyDown;
  1030. private _onKeyUp;
  1031. private _onCanvasFocusObserver;
  1032. private _onCanvasBlurObserver;
  1033. private _useRightHandedSystem;
  1034. /**
  1035. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1036. */
  1037. useRightHandedSystem: boolean;
  1038. /**
  1039. * Sets the step Id used by deterministic lock step
  1040. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1041. * @param newStepId defines the step Id
  1042. */
  1043. setStepId(newStepId: number): void;
  1044. /**
  1045. * Gets the step Id used by deterministic lock step
  1046. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1047. * @returns the step Id
  1048. */
  1049. getStepId(): number;
  1050. /**
  1051. * Gets the internal step used by deterministic lock step
  1052. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1053. * @returns the internal step
  1054. */
  1055. getInternalStep(): number;
  1056. private _fogEnabled;
  1057. /**
  1058. * Gets or sets a boolean indicating if fog is enabled on this scene
  1059. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1060. */
  1061. fogEnabled: boolean;
  1062. private _fogMode;
  1063. /**
  1064. * Gets or sets the fog mode to use
  1065. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1066. */
  1067. fogMode: number;
  1068. /**
  1069. * Gets or sets the fog color to use
  1070. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1071. */
  1072. fogColor: Color3;
  1073. /**
  1074. * Gets or sets the fog density to use
  1075. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1076. */
  1077. fogDensity: number;
  1078. /**
  1079. * Gets or sets the fog start distance to use
  1080. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1081. */
  1082. fogStart: number;
  1083. /**
  1084. * Gets or sets the fog end distance to use
  1085. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1086. */
  1087. fogEnd: number;
  1088. private _shadowsEnabled;
  1089. /**
  1090. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1091. */
  1092. shadowsEnabled: boolean;
  1093. private _lightsEnabled;
  1094. /**
  1095. * Gets or sets a boolean indicating if lights are enabled on this scene
  1096. */
  1097. lightsEnabled: boolean;
  1098. /**
  1099. * All of the lights added to this scene
  1100. * @see http://doc.babylonjs.com/babylon101/lights
  1101. */
  1102. lights: Light[];
  1103. /** All of the cameras added to this scene.
  1104. * @see http://doc.babylonjs.com/babylon101/cameras
  1105. */
  1106. cameras: Camera[];
  1107. /** All of the active cameras added to this scene. */
  1108. activeCameras: Camera[];
  1109. /** The current active camera */
  1110. activeCamera: Nullable<Camera>;
  1111. /**
  1112. * All of the tranform nodes added to this scene
  1113. * @see http://doc.babylonjs.com/how_to/transformnode
  1114. */
  1115. transformNodes: TransformNode[];
  1116. /**
  1117. * All of the (abstract) meshes added to this scene
  1118. */
  1119. meshes: AbstractMesh[];
  1120. /**
  1121. * All of the animation groups added to this scene
  1122. * @see http://doc.babylonjs.com/how_to/group
  1123. */
  1124. animationGroups: AnimationGroup[];
  1125. private _geometries;
  1126. /**
  1127. * All of the materials added to this scene
  1128. * @see http://doc.babylonjs.com/babylon101/materials
  1129. */
  1130. materials: Material[];
  1131. /**
  1132. * All of the multi-materials added to this scene
  1133. * @see http://doc.babylonjs.com/how_to/multi_materials
  1134. */
  1135. multiMaterials: MultiMaterial[];
  1136. private _defaultMaterial;
  1137. /** The default material used on meshes when no material is affected */
  1138. /** The default material used on meshes when no material is affected */
  1139. defaultMaterial: Material;
  1140. private _texturesEnabled;
  1141. /**
  1142. * Gets or sets a boolean indicating if textures are enabled on this scene
  1143. */
  1144. texturesEnabled: boolean;
  1145. /**
  1146. * All of the textures added to this scene
  1147. */
  1148. textures: BaseTexture[];
  1149. /**
  1150. * Gets or sets a boolean indicating if particles are enabled on this scene
  1151. */
  1152. particlesEnabled: boolean;
  1153. /**
  1154. * All of the particle systems added to this scene
  1155. * @see http://doc.babylonjs.com/babylon101/particles
  1156. */
  1157. particleSystems: IParticleSystem[];
  1158. /**
  1159. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1160. */
  1161. spritesEnabled: boolean;
  1162. /**
  1163. * All of the sprite managers added to this scene
  1164. * @see http://doc.babylonjs.com/babylon101/sprites
  1165. */
  1166. spriteManagers: SpriteManager[];
  1167. /**
  1168. * The list of layers (background and foreground) of the scene
  1169. */
  1170. layers: Layer[];
  1171. /**
  1172. * The list of effect layers (highlights/glow) added to the scene
  1173. * @see http://doc.babylonjs.com/how_to/highlight_layer
  1174. * @see http://doc.babylonjs.com/how_to/glow_layer
  1175. */
  1176. effectLayers: EffectLayer[];
  1177. private _skeletonsEnabled;
  1178. /**
  1179. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1180. */
  1181. skeletonsEnabled: boolean;
  1182. /**
  1183. * The list of skeletons added to the scene
  1184. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  1185. */
  1186. skeletons: Skeleton[];
  1187. /**
  1188. * The list of morph target managers added to the scene
  1189. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  1190. */
  1191. morphTargetManagers: MorphTargetManager[];
  1192. /**
  1193. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1194. */
  1195. lensFlaresEnabled: boolean;
  1196. /**
  1197. * The list of lens flare system added to the scene
  1198. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  1199. */
  1200. lensFlareSystems: LensFlareSystem[];
  1201. /**
  1202. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1203. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1204. */
  1205. collisionsEnabled: boolean;
  1206. private _workerCollisions;
  1207. /** @ignore */
  1208. collisionCoordinator: ICollisionCoordinator;
  1209. /**
  1210. * Defines the gravity applied to this scene (used only for collisions)
  1211. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1212. */
  1213. gravity: Vector3;
  1214. /**
  1215. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1216. */
  1217. postProcessesEnabled: boolean;
  1218. /**
  1219. * The list of postprocesses added to the scene
  1220. */
  1221. postProcesses: PostProcess[];
  1222. /**
  1223. * Gets the current postprocess manager
  1224. */
  1225. postProcessManager: PostProcessManager;
  1226. private _postProcessRenderPipelineManager;
  1227. /**
  1228. * Gets the postprocess render pipeline manager
  1229. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  1230. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  1231. */
  1232. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1233. /**
  1234. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1235. */
  1236. renderTargetsEnabled: boolean;
  1237. /**
  1238. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1239. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1240. */
  1241. dumpNextRenderTargets: boolean;
  1242. /**
  1243. * The list of user defined render targets added to the scene
  1244. */
  1245. customRenderTargets: RenderTargetTexture[];
  1246. /**
  1247. * Defines if texture loading must be delayed
  1248. * If true, textures will only be loaded when they need to be rendered
  1249. */
  1250. useDelayedTextureLoading: boolean;
  1251. /**
  1252. * Gets the list of meshes imported to the scene through SceneLoader
  1253. */
  1254. importedMeshesFiles: String[];
  1255. /**
  1256. * Gets or sets a boolean indicating if probes are enabled on this scene
  1257. */
  1258. probesEnabled: boolean;
  1259. /**
  1260. * The list of reflection probes added to the scene
  1261. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1262. */
  1263. reflectionProbes: ReflectionProbe[];
  1264. /**
  1265. * @ignore
  1266. */
  1267. database: Database;
  1268. /**
  1269. * Gets or sets the action manager associated with the scene
  1270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1271. */
  1272. actionManager: ActionManager;
  1273. /** @ignore */
  1274. _actionManagers: ActionManager[];
  1275. private _meshesForIntersections;
  1276. /**
  1277. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1278. */
  1279. proceduralTexturesEnabled: boolean;
  1280. /**
  1281. * The list of procedural textures added to the scene
  1282. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1283. */
  1284. proceduralTextures: ProceduralTexture[];
  1285. private _mainSoundTrack;
  1286. /**
  1287. * The list of sound tracks added to the scene
  1288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1289. */
  1290. soundTracks: SoundTrack[];
  1291. private _audioEnabled;
  1292. private _headphone;
  1293. /**
  1294. * Gets the main soundtrack associated with the scene
  1295. */
  1296. readonly mainSoundTrack: SoundTrack;
  1297. /**
  1298. * Gets or sets the VRExperienceHelper attached to the scene
  1299. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1300. * @ignoreNaming
  1301. */
  1302. VRHelper: VRExperienceHelper;
  1303. /**
  1304. * Gets or sets the simplification queue attached to the scene
  1305. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  1306. */
  1307. simplificationQueue: SimplificationQueue;
  1308. private _engine;
  1309. private _totalVertices;
  1310. /** @ignore */
  1311. _activeIndices: PerfCounter;
  1312. /** @ignore */
  1313. _activeParticles: PerfCounter;
  1314. /** @ignore */
  1315. _activeBones: PerfCounter;
  1316. private _animationRatio;
  1317. private _animationTimeLast;
  1318. private _animationTime;
  1319. /**
  1320. * Gets or sets a general scale for animation speed
  1321. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1322. */
  1323. animationTimeScale: number;
  1324. /** @ignore */
  1325. _cachedMaterial: Nullable<Material>;
  1326. /** @ignore */
  1327. _cachedEffect: Nullable<Effect>;
  1328. /** @ignore */
  1329. _cachedVisibility: Nullable<number>;
  1330. private _renderId;
  1331. private _executeWhenReadyTimeoutId;
  1332. private _intermediateRendering;
  1333. private _viewUpdateFlag;
  1334. private _projectionUpdateFlag;
  1335. private _alternateViewUpdateFlag;
  1336. private _alternateProjectionUpdateFlag;
  1337. /** @ignore */
  1338. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1339. private _activeRequests;
  1340. private _pendingData;
  1341. private _isDisposed;
  1342. /**
  1343. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1344. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1345. */
  1346. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1347. private _activeMeshes;
  1348. private _processedMaterials;
  1349. private _renderTargets;
  1350. /** @ignore */
  1351. _activeParticleSystems: SmartArray<IParticleSystem>;
  1352. private _activeSkeletons;
  1353. private _softwareSkinnedMeshes;
  1354. private _renderingManager;
  1355. private _physicsEngine;
  1356. /** @ignore */
  1357. _activeAnimatables: Animatable[];
  1358. private _transformMatrix;
  1359. private _sceneUbo;
  1360. private _alternateSceneUbo;
  1361. private _pickWithRayInverseMatrix;
  1362. private _boundingBoxRenderer;
  1363. private _outlineRenderer;
  1364. private _viewMatrix;
  1365. private _projectionMatrix;
  1366. private _alternateViewMatrix;
  1367. private _alternateProjectionMatrix;
  1368. private _alternateTransformMatrix;
  1369. private _useAlternateCameraConfiguration;
  1370. private _alternateRendering;
  1371. /** @ignore */
  1372. _forcedViewPosition: Nullable<Vector3>;
  1373. /** @ignore */
  1374. readonly _isAlternateRenderingEnabled: boolean;
  1375. private _frustumPlanes;
  1376. /**
  1377. * Gets the list of frustum planes (built from the active camera)
  1378. */
  1379. readonly frustumPlanes: Plane[];
  1380. /**
  1381. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1382. * This is useful if there are more lights that the maximum simulteanous authorized
  1383. */
  1384. requireLightSorting: boolean;
  1385. private _selectionOctree;
  1386. private _pointerOverMesh;
  1387. private _pointerOverSprite;
  1388. private _debugLayer;
  1389. private _depthRenderer;
  1390. private _geometryBufferRenderer;
  1391. /**
  1392. * Gets the current geometry buffer associated to the scene.
  1393. */
  1394. /**
  1395. * Sets the current geometry buffer for the scene.
  1396. */
  1397. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1398. private _pickedDownMesh;
  1399. private _pickedUpMesh;
  1400. private _pickedDownSprite;
  1401. private _externalData;
  1402. private _uid;
  1403. /**
  1404. * Creates a new Scene
  1405. * @param engine defines the engine to use to render this scene
  1406. */
  1407. constructor(engine: Engine);
  1408. /**
  1409. * Gets the debug layer associated with the scene
  1410. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1411. */
  1412. readonly debugLayer: DebugLayer;
  1413. /**
  1414. * Gets a boolean indicating if collisions are processed on a web worker
  1415. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1416. */
  1417. workerCollisions: boolean;
  1418. /**
  1419. * Gets the octree used to boost mesh selection (picking)
  1420. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1421. */
  1422. readonly selectionOctree: Octree<AbstractMesh>;
  1423. /**
  1424. * Gets the mesh that is currently under the pointer
  1425. */
  1426. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1427. /**
  1428. * Gets the current on-screen X position of the pointer
  1429. */
  1430. readonly pointerX: number;
  1431. /**
  1432. * Gets the current on-screen Y position of the pointer
  1433. */
  1434. readonly pointerY: number;
  1435. /**
  1436. * Gets the cached material (ie. the latest rendered one)
  1437. * @returns the cached material
  1438. */
  1439. getCachedMaterial(): Nullable<Material>;
  1440. /**
  1441. * Gets the cached effect (ie. the latest rendered one)
  1442. * @returns the cached effect
  1443. */
  1444. getCachedEffect(): Nullable<Effect>;
  1445. /**
  1446. * Gets the cached visibility state (ie. the latest rendered one)
  1447. * @returns the cached visibility state
  1448. */
  1449. getCachedVisibility(): Nullable<number>;
  1450. /**
  1451. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1452. * @param material defines the current material
  1453. * @param effect defines the current effect
  1454. * @param visibility defines the current visibility state
  1455. * @returns true if one parameter is not cached
  1456. */
  1457. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1458. /**
  1459. * Gets the bounding box renderer associated with the scene
  1460. * @returns a BoundingBoxRenderer
  1461. */
  1462. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1463. /**
  1464. * Gets the outline renderer associated with the scene
  1465. * @returns a OutlineRenderer
  1466. */
  1467. getOutlineRenderer(): OutlineRenderer;
  1468. /**
  1469. * Gets the engine associated with the scene
  1470. * @returns an Engine
  1471. */
  1472. getEngine(): Engine;
  1473. /**
  1474. * Gets the total number of vertices rendered per frame
  1475. * @returns the total number of vertices rendered per frame
  1476. */
  1477. getTotalVertices(): number;
  1478. /**
  1479. * Gets the performance counter for total vertices
  1480. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1481. */
  1482. readonly totalVerticesPerfCounter: PerfCounter;
  1483. /**
  1484. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1485. * @returns the total number of active indices rendered per frame
  1486. */
  1487. getActiveIndices(): number;
  1488. /**
  1489. * Gets the performance counter for active indices
  1490. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1491. */
  1492. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1493. /**
  1494. * Gets the total number of active particles rendered per frame
  1495. * @returns the total number of active particles rendered per frame
  1496. */
  1497. getActiveParticles(): number;
  1498. /**
  1499. * Gets the performance counter for active particles
  1500. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1501. */
  1502. readonly activeParticlesPerfCounter: PerfCounter;
  1503. /**
  1504. * Gets the total number of active bones rendered per frame
  1505. * @returns the total number of active bones rendered per frame
  1506. */
  1507. getActiveBones(): number;
  1508. /**
  1509. * Gets the performance counter for active bones
  1510. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1511. */
  1512. readonly activeBonesPerfCounter: PerfCounter;
  1513. /** @ignore */
  1514. getInterFramePerfCounter(): number;
  1515. /** @ignore */
  1516. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1517. /** @ignore */
  1518. getLastFrameDuration(): number;
  1519. /** @ignore */
  1520. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1521. /** @ignore */
  1522. getEvaluateActiveMeshesDuration(): number;
  1523. /** @ignore */
  1524. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1525. /**
  1526. * Gets the array of active meshes
  1527. * @returns an array of AbstractMesh
  1528. */
  1529. getActiveMeshes(): SmartArray<AbstractMesh>;
  1530. /** @ignore */
  1531. getRenderTargetsDuration(): number;
  1532. /** @ignore */
  1533. getRenderDuration(): number;
  1534. /** @ignore */
  1535. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1536. /** @ignore */
  1537. getParticlesDuration(): number;
  1538. /** @ignore */
  1539. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1540. /** @ignore */
  1541. getSpritesDuration(): number;
  1542. /** @ignore */
  1543. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1544. /**
  1545. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1546. * @returns a number
  1547. */
  1548. getAnimationRatio(): number;
  1549. /**
  1550. * Gets an unique Id for the current frame
  1551. * @returns a number
  1552. */
  1553. getRenderId(): number;
  1554. /** Call this function if you want to manually increment the render Id*/
  1555. incrementRenderId(): void;
  1556. private _updatePointerPosition(evt);
  1557. private _createUbo();
  1558. private _createAlternateUbo();
  1559. /**
  1560. * Use this method to simulate a pointer move on a mesh
  1561. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1562. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1563. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1564. * @returns the current scene
  1565. */
  1566. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1567. private _processPointerMove(pickResult, evt);
  1568. /**
  1569. * Use this method to simulate a pointer down on a mesh
  1570. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1571. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1572. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1573. * @returns the current scene
  1574. */
  1575. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1576. private _processPointerDown(pickResult, evt);
  1577. /**
  1578. * Use this method to simulate a pointer up on a mesh
  1579. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1580. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1581. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1582. * @returns the current scene
  1583. */
  1584. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1585. private _processPointerUp(pickResult, evt, clickInfo);
  1586. /**
  1587. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1588. * @param attachUp defines if you want to attach events to pointerup
  1589. * @param attachDown defines if you want to attach events to pointerdown
  1590. * @param attachMove defines if you want to attach events to pointermove
  1591. */
  1592. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1593. /** Detaches all event handlers*/
  1594. detachControl(): void;
  1595. /**
  1596. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1597. * Delay loaded resources are not taking in account
  1598. * @return true if all required resources are ready
  1599. */
  1600. isReady(): boolean;
  1601. /** Resets all cached information relative to material (including effect and visibility) */
  1602. resetCachedMaterial(): void;
  1603. /**
  1604. * Registers a function to be called before every frame render
  1605. * @param func defines the function to register
  1606. */
  1607. registerBeforeRender(func: () => void): void;
  1608. /**
  1609. * Unregisters a function called before every frame render
  1610. * @param func defines the function to unregister
  1611. */
  1612. unregisterBeforeRender(func: () => void): void;
  1613. /**
  1614. * Registers a function to be called after every frame render
  1615. * @param func defines the function to register
  1616. */
  1617. registerAfterRender(func: () => void): void;
  1618. /**
  1619. * Unregisters a function called after every frame render
  1620. * @param func defines the function to unregister
  1621. */
  1622. unregisterAfterRender(func: () => void): void;
  1623. private _executeOnceBeforeRender(func);
  1624. /**
  1625. * The provided function will run before render once and will be disposed afterwards.
  1626. * A timeout delay can be provided so that the function will be executed in N ms.
  1627. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1628. * @param func The function to be executed.
  1629. * @param timeout optional delay in ms
  1630. */
  1631. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1632. /** @ignore */
  1633. _addPendingData(data: any): void;
  1634. /** @ignore */
  1635. _removePendingData(data: any): void;
  1636. /**
  1637. * Returns the number of items waiting to be loaded
  1638. * @returns the number of items waiting to be loaded
  1639. */
  1640. getWaitingItemsCount(): number;
  1641. /**
  1642. * Returns a boolean indicating if the scene is still loading data
  1643. */
  1644. readonly isLoading: boolean;
  1645. /**
  1646. * Registers a function to be executed when the scene is ready
  1647. * @param {Function} func - the function to be executed
  1648. */
  1649. executeWhenReady(func: () => void): void;
  1650. /**
  1651. * Returns a promise that resolves when the scene is ready
  1652. * @returns A promise that resolves when the scene is ready
  1653. */
  1654. whenReadyAsync(): Promise<void>;
  1655. /** @ignore */
  1656. _checkIsReady(): void;
  1657. /**
  1658. * Will start the animation sequence of a given target
  1659. * @param target defines the target
  1660. * @param from defines from which frame should animation start
  1661. * @param to defines until which frame should animation run.
  1662. * @param weight defines the weight to apply to the animation (1.0 by default)
  1663. * @param loop defines if the animation loops
  1664. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1665. * @param onAnimationEnd defines the function to be executed when the animation ends
  1666. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1667. * @returns the animatable object created for this animation
  1668. */
  1669. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1670. /**
  1671. * Will start the animation sequence of a given target
  1672. * @param target defines the target
  1673. * @param from defines from which frame should animation start
  1674. * @param to defines until which frame should animation run.
  1675. * @param loop defines if the animation loops
  1676. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1677. * @param onAnimationEnd defines the function to be executed when the animation ends
  1678. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1679. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1680. * @returns the animatable object created for this animation
  1681. */
  1682. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean): Animatable;
  1683. /**
  1684. * Begin a new animation on a given node
  1685. * @param target defines the target where the animation will take place
  1686. * @param animations defines the list of animations to start
  1687. * @param from defines the initial value
  1688. * @param to defines the final value
  1689. * @param loop defines if you want animation to loop (off by default)
  1690. * @param speedRatio defines the speed ratio to apply to all animations
  1691. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1692. * @returns the list of created animatables
  1693. */
  1694. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1695. /**
  1696. * Begin a new animation on a given node and its hierarchy
  1697. * @param target defines the root node where the animation will take place
  1698. * @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.
  1699. * @param animations defines the list of animations to start
  1700. * @param from defines the initial value
  1701. * @param to defines the final value
  1702. * @param loop defines if you want animation to loop (off by default)
  1703. * @param speedRatio defines the speed ratio to apply to all animations
  1704. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1705. * @returns the list of animatables created for all nodes
  1706. */
  1707. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1708. /**
  1709. * Gets the animatable associated with a specific target
  1710. * @param target defines the target of the animatable
  1711. * @returns the required animatable if found
  1712. */
  1713. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1714. /**
  1715. * Gets all animatables associated with a given target
  1716. * @param target defines the target to look animatables for
  1717. * @returns an array of Animatables
  1718. */
  1719. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1720. /**
  1721. * Gets all animatable attached to the scene
  1722. */
  1723. readonly animatables: Animatable[];
  1724. /**
  1725. * Will stop the animation of the given target
  1726. * @param target - the target
  1727. * @param animationName - the name of the animation to stop (all animations will be stopped if empty)
  1728. */
  1729. stopAnimation(target: any, animationName?: string): void;
  1730. /**
  1731. * Stops and removes all animations that have been applied to the scene
  1732. */
  1733. stopAllAnimations(): void;
  1734. private _animate();
  1735. /** @ignore */
  1736. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation): void;
  1737. private _processLateAnimationBindingsForMatrices(holder, originalValue);
  1738. private _processLateAnimationBindings();
  1739. /** @ignore */
  1740. _switchToAlternateCameraConfiguration(active: boolean): void;
  1741. /**
  1742. * Gets the current view matrix
  1743. * @returns a Matrix
  1744. */
  1745. getViewMatrix(): Matrix;
  1746. /**
  1747. * Gets the current projection matrix
  1748. * @returns a Matrix
  1749. */
  1750. getProjectionMatrix(): Matrix;
  1751. /**
  1752. * Gets the current transform matrix
  1753. * @returns a Matrix made of View * Projection
  1754. */
  1755. getTransformMatrix(): Matrix;
  1756. /**
  1757. * Sets the current transform matrix
  1758. * @param view defines the View matrix to use
  1759. * @param projection defines the Projection matrix to use
  1760. */
  1761. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1762. /** @ignore */
  1763. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1764. /**
  1765. * Gets the uniform buffer used to store scene data
  1766. * @returns a UniformBuffer
  1767. */
  1768. getSceneUniformBuffer(): UniformBuffer;
  1769. /**
  1770. * Gets an unique (relatively to the current scene) Id
  1771. * @returns an unique number for the scene
  1772. */
  1773. getUniqueId(): number;
  1774. /**
  1775. * Add a mesh to the list of scene's meshes
  1776. * @param newMesh defines the mesh to add
  1777. */
  1778. addMesh(newMesh: AbstractMesh): void;
  1779. /**
  1780. * Remove a mesh for the list of scene's meshes
  1781. * @param toRemove defines the mesh to remove
  1782. * @returns the index where the mesh was in the mesh list
  1783. */
  1784. removeMesh(toRemove: AbstractMesh): number;
  1785. /**
  1786. * Add a transform node to the list of scene's transform nodes
  1787. * @param newTransformNode defines the transform node to add
  1788. */
  1789. addTransformNode(newTransformNode: TransformNode): void;
  1790. /**
  1791. * Remove a transform node for the list of scene's transform nodes
  1792. * @param toRemove defines the transform node to remove
  1793. * @returns the index where the transform node was in the transform node list
  1794. */
  1795. removeTransformNode(toRemove: TransformNode): number;
  1796. /**
  1797. * Remove a skeleton for the list of scene's skeletons
  1798. * @param toRemove defines the skeleton to remove
  1799. * @returns the index where the skeleton was in the skeleton list
  1800. */
  1801. removeSkeleton(toRemove: Skeleton): number;
  1802. /**
  1803. * Remove a morph target for the list of scene's morph targets
  1804. * @param toRemove defines the morph target to remove
  1805. * @returns the index where the morph target was in the morph target list
  1806. */
  1807. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1808. /**
  1809. * Remove a light for the list of scene's lights
  1810. * @param toRemove defines the light to remove
  1811. * @returns the index where the light was in the light list
  1812. */
  1813. removeLight(toRemove: Light): number;
  1814. /**
  1815. * Remove a camera for the list of scene's cameras
  1816. * @param toRemove defines the camera to remove
  1817. * @returns the index where the camera was in the camera list
  1818. */
  1819. removeCamera(toRemove: Camera): number;
  1820. /**
  1821. * Remove a particle system for the list of scene's particle systems
  1822. * @param toRemove defines the particle system to remove
  1823. * @returns the index where the particle system was in the particle system list
  1824. */
  1825. removeParticleSystem(toRemove: IParticleSystem): number;
  1826. /**
  1827. * Remove a animation for the list of scene's animations
  1828. * @param toRemove defines the animation to remove
  1829. * @returns the index where the animation was in the animation list
  1830. */
  1831. removeAnimation(toRemove: Animation): number;
  1832. /**
  1833. * Removes the given animation group from this scene.
  1834. * @param toRemove The animation group to remove
  1835. * @returns The index of the removed animation group
  1836. */
  1837. removeAnimationGroup(toRemove: AnimationGroup): number;
  1838. /**
  1839. * Removes the given multi-material from this scene.
  1840. * @param toRemove The multi-material to remove
  1841. * @returns The index of the removed multi-material
  1842. */
  1843. removeMultiMaterial(toRemove: MultiMaterial): number;
  1844. /**
  1845. * Removes the given material from this scene.
  1846. * @param toRemove The material to remove
  1847. * @returns The index of the removed material
  1848. */
  1849. removeMaterial(toRemove: Material): number;
  1850. /**
  1851. * Removes the given lens flare system from this scene.
  1852. * @param toRemove The lens flare system to remove
  1853. * @returns The index of the removed lens flare system
  1854. */
  1855. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1856. /**
  1857. * Removes the given action manager from this scene.
  1858. * @param toRemove The action manager to remove
  1859. * @returns The index of the removed action manager
  1860. */
  1861. removeActionManager(toRemove: ActionManager): number;
  1862. /**
  1863. * Removes the given effect layer from this scene.
  1864. * @param toRemove defines the effect layer to remove
  1865. * @returns the index of the removed effect layer
  1866. */
  1867. removeEffectLayer(toRemove: EffectLayer): number;
  1868. /**
  1869. * Removes the given texture from this scene.
  1870. * @param toRemove The texture to remove
  1871. * @returns The index of the removed texture
  1872. */
  1873. removeTexture(toRemove: BaseTexture): number;
  1874. /**
  1875. * Adds the given light to this scene
  1876. * @param newLight The light to add
  1877. */
  1878. addLight(newLight: Light): void;
  1879. /**
  1880. * Sorts the list list based on light priorities
  1881. */
  1882. sortLightsByPriority(): void;
  1883. /**
  1884. * Adds the given camera to this scene
  1885. * @param newCamera The camera to add
  1886. */
  1887. addCamera(newCamera: Camera): void;
  1888. /**
  1889. * Adds the given skeleton to this scene
  1890. * @param newSkeleton The skeleton to add
  1891. */
  1892. addSkeleton(newSkeleton: Skeleton): void;
  1893. /**
  1894. * Adds the given particle system to this scene
  1895. * @param newParticleSystem The particle system to add
  1896. */
  1897. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1898. /**
  1899. * Adds the given animation to this scene
  1900. * @param newAnimation The animation to add
  1901. */
  1902. addAnimation(newAnimation: Animation): void;
  1903. /**
  1904. * Adds the given animation group to this scene.
  1905. * @param newAnimationGroup The animation group to add
  1906. */
  1907. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1908. /**
  1909. * Adds the given multi-material to this scene
  1910. * @param newMultiMaterial The multi-material to add
  1911. */
  1912. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1913. /**
  1914. * Adds the given material to this scene
  1915. * @param newMaterial The material to add
  1916. */
  1917. addMaterial(newMaterial: Material): void;
  1918. /**
  1919. * Adds the given morph target to this scene
  1920. * @param newMorphTargetManager The morph target to add
  1921. */
  1922. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1923. /**
  1924. * Adds the given geometry to this scene
  1925. * @param newGeometry The geometry to add
  1926. */
  1927. addGeometry(newGeometry: Geometry): void;
  1928. /**
  1929. * Adds the given lens flare system to this scene
  1930. * @param newLensFlareSystem The lens flare system to add
  1931. */
  1932. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1933. /**
  1934. * Adds the given effect layer to this scene
  1935. * @param newEffectLayer defines the effect layer to add
  1936. */
  1937. addEffectLayer(newEffectLayer: EffectLayer): void;
  1938. /**
  1939. * Adds the given action manager to this scene
  1940. * @param newActionManager The action manager to add
  1941. */
  1942. addActionManager(newActionManager: ActionManager): void;
  1943. /**
  1944. * Adds the given texture to this scene.
  1945. * @param newTexture The texture to add
  1946. */
  1947. addTexture(newTexture: BaseTexture): void;
  1948. /**
  1949. * Switch active camera
  1950. * @param newCamera defines the new active camera
  1951. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1952. */
  1953. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1954. /**
  1955. * sets the active camera of the scene using its ID
  1956. * @param id defines the camera's ID
  1957. * @return the new active camera or null if none found.
  1958. */
  1959. setActiveCameraByID(id: string): Nullable<Camera>;
  1960. /**
  1961. * sets the active camera of the scene using its name
  1962. * @param name defines the camera's name
  1963. * @returns the new active camera or null if none found.
  1964. */
  1965. setActiveCameraByName(name: string): Nullable<Camera>;
  1966. /**
  1967. * get an animation group using its name
  1968. * @param name defines the material's name
  1969. * @return the animation group or null if none found.
  1970. */
  1971. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1972. /**
  1973. * get a material using its id
  1974. * @param id defines the material's ID
  1975. * @return the material or null if none found.
  1976. */
  1977. getMaterialByID(id: string): Nullable<Material>;
  1978. /**
  1979. * Gets a material using its name
  1980. * @param name defines the material's name
  1981. * @return the material or null if none found.
  1982. */
  1983. getMaterialByName(name: string): Nullable<Material>;
  1984. /**
  1985. * Gets a lens flare system using its name
  1986. * @param name defines the name to look for
  1987. * @returns the lens flare system or null if not found
  1988. */
  1989. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  1990. /**
  1991. * Gets a lens flare system using its id
  1992. * @param id defines the id to look for
  1993. * @returns the lens flare system or null if not found
  1994. */
  1995. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  1996. /**
  1997. * Gets a camera using its id
  1998. * @param id defines the id to look for
  1999. * @returns the camera or null if not found
  2000. */
  2001. getCameraByID(id: string): Nullable<Camera>;
  2002. /**
  2003. * Gets a camera using its unique id
  2004. * @param uniqueId defines the unique id to look for
  2005. * @returns the camera or null if not found
  2006. */
  2007. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2008. /**
  2009. * Gets a camera using its name
  2010. * @param name defines the camera's name
  2011. * @return the camera or null if none found.
  2012. */
  2013. getCameraByName(name: string): Nullable<Camera>;
  2014. /**
  2015. * Gets a bone using its id
  2016. * @param id defines the bone's id
  2017. * @return the bone or null if not found
  2018. */
  2019. getBoneByID(id: string): Nullable<Bone>;
  2020. /**
  2021. * Gets a bone using its id
  2022. * @param name defines the bone's name
  2023. * @return the bone or null if not found
  2024. */
  2025. getBoneByName(name: string): Nullable<Bone>;
  2026. /**
  2027. * Gets a light node using its name
  2028. * @param name defines the the light's name
  2029. * @return the light or null if none found.
  2030. */
  2031. getLightByName(name: string): Nullable<Light>;
  2032. /**
  2033. * Gets a light node using its id
  2034. * @param id defines the light's id
  2035. * @return the light or null if none found.
  2036. */
  2037. getLightByID(id: string): Nullable<Light>;
  2038. /**
  2039. * Gets a light node using its scene-generated unique ID
  2040. * @param uniqueId defines the light's unique id
  2041. * @return the light or null if none found.
  2042. */
  2043. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2044. /**
  2045. * Gets a particle system by id
  2046. * @param id defines the particle system id
  2047. * @return the corresponding system or null if none found
  2048. */
  2049. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2050. /**
  2051. * Gets a geometry using its ID
  2052. * @param id defines the geometry's id
  2053. * @return the geometry or null if none found.
  2054. */
  2055. getGeometryByID(id: string): Nullable<Geometry>;
  2056. /**
  2057. * Add a new geometry to this scene
  2058. * @param geometry defines the geometry to be added to the scene.
  2059. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2060. * @return a boolean defining if the geometry was added or not
  2061. */
  2062. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2063. /**
  2064. * Removes an existing geometry
  2065. * @param geometry defines the geometry to be removed from the scene
  2066. * @return a boolean defining if the geometry was removed or not
  2067. */
  2068. removeGeometry(geometry: Geometry): boolean;
  2069. /**
  2070. * Gets the list of geometries attached to the scene
  2071. * @returns an array of Geometry
  2072. */
  2073. getGeometries(): Geometry[];
  2074. /**
  2075. * Gets the first added mesh found of a given ID
  2076. * @param id defines the id to search for
  2077. * @return the mesh found or null if not found at all
  2078. */
  2079. getMeshByID(id: string): Nullable<AbstractMesh>;
  2080. /**
  2081. * Gets a list of meshes using their id
  2082. * @param id defines the id to search for
  2083. * @returns a list of meshes
  2084. */
  2085. getMeshesByID(id: string): Array<AbstractMesh>;
  2086. /**
  2087. * Gets the first added transform node found of a given ID
  2088. * @param id defines the id to search for
  2089. * @return the found transform node or null if not found at all.
  2090. */
  2091. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2092. /**
  2093. * Gets a list of transform nodes using their id
  2094. * @param id defines the id to search for
  2095. * @returns a list of transform nodes
  2096. */
  2097. getTransformNodesByID(id: string): Array<TransformNode>;
  2098. /**
  2099. * Gets a mesh with its auto-generated unique id
  2100. * @param uniqueId defines the unique id to search for
  2101. * @return the found mesh or null if not found at all.
  2102. */
  2103. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2104. /**
  2105. * Gets a the last added mesh using a given id
  2106. * @param id defines the id to search for
  2107. * @return the found mesh or null if not found at all.
  2108. */
  2109. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2110. /**
  2111. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2112. * @param id defines the id to search for
  2113. * @return the found node or null if not found at all
  2114. */
  2115. getLastEntryByID(id: string): Nullable<Node>;
  2116. /**
  2117. * Gets a node (Mesh, Camera, Light) using a given id
  2118. * @param id defines the id to search for
  2119. * @return the found node or null if not found at all
  2120. */
  2121. getNodeByID(id: string): Nullable<Node>;
  2122. /**
  2123. * Gets a node (Mesh, Camera, Light) using a given name
  2124. * @param name defines the name to search for
  2125. * @return the found node or null if not found at all.
  2126. */
  2127. getNodeByName(name: string): Nullable<Node>;
  2128. /**
  2129. * Gets a mesh using a given name
  2130. * @param name defines the name to search for
  2131. * @return the found mesh or null if not found at all.
  2132. */
  2133. getMeshByName(name: string): Nullable<AbstractMesh>;
  2134. /**
  2135. * Gets a transform node using a given name
  2136. * @param name defines the name to search for
  2137. * @return the found transform node or null if not found at all.
  2138. */
  2139. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2140. /**
  2141. * Gets a sound using a given name
  2142. * @param name defines the name to search for
  2143. * @return the found sound or null if not found at all.
  2144. */
  2145. getSoundByName(name: string): Nullable<Sound>;
  2146. /**
  2147. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2148. * @param id defines the id to search for
  2149. * @return the found skeleton or null if not found at all.
  2150. */
  2151. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2152. /**
  2153. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2154. * @param id defines the id to search for
  2155. * @return the found skeleton or null if not found at all.
  2156. */
  2157. getSkeletonById(id: string): Nullable<Skeleton>;
  2158. /**
  2159. * Gets a skeleton using a given name
  2160. * @param name defines the name to search for
  2161. * @return the found skeleton or null if not found at all.
  2162. */
  2163. getSkeletonByName(name: string): Nullable<Skeleton>;
  2164. /**
  2165. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2166. * @param id defines the id to search for
  2167. * @return the found morph target manager or null if not found at all.
  2168. */
  2169. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2170. /**
  2171. * Gets a boolean indicating if the given mesh is active
  2172. * @param mesh defines the mesh to look for
  2173. * @returns true if the mesh is in the active list
  2174. */
  2175. isActiveMesh(mesh: AbstractMesh): boolean;
  2176. /**
  2177. * Return a the first highlight layer of the scene with a given name.
  2178. * @param name The name of the highlight layer to look for.
  2179. * @return The highlight layer if found otherwise null.
  2180. */
  2181. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  2182. /**
  2183. * Return a the first highlight layer of the scene with a given name.
  2184. * @param name The name of the highlight layer to look for.
  2185. * @return The highlight layer if found otherwise null.
  2186. */
  2187. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  2188. /**
  2189. * Return a unique id as a string which can serve as an identifier for the scene
  2190. */
  2191. readonly uid: string;
  2192. /**
  2193. * Add an externaly attached data from its key.
  2194. * This method call will fail and return false, if such key already exists.
  2195. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2196. * @param key the unique key that identifies the data
  2197. * @param data the data object to associate to the key for this Engine instance
  2198. * @return true if no such key were already present and the data was added successfully, false otherwise
  2199. */
  2200. addExternalData<T>(key: string, data: T): boolean;
  2201. /**
  2202. * Get an externaly attached data from its key
  2203. * @param key the unique key that identifies the data
  2204. * @return the associated data, if present (can be null), or undefined if not present
  2205. */
  2206. getExternalData<T>(key: string): Nullable<T>;
  2207. /**
  2208. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2209. * @param key the unique key that identifies the data
  2210. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2211. * @return the associated data, can be null if the factory returned null.
  2212. */
  2213. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2214. /**
  2215. * Remove an externaly attached data from the Engine instance
  2216. * @param key the unique key that identifies the data
  2217. * @return true if the data was successfully removed, false if it doesn't exist
  2218. */
  2219. removeExternalData(key: string): boolean;
  2220. private _evaluateSubMesh(subMesh, mesh);
  2221. /**
  2222. * Clear the processed materials smart array preventing retention point in material dispose.
  2223. */
  2224. freeProcessedMaterials(): void;
  2225. /**
  2226. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2227. */
  2228. freeActiveMeshes(): void;
  2229. /**
  2230. * Clear the info related to rendering groups preventing retention points during dispose.
  2231. */
  2232. freeRenderingGroups(): void;
  2233. /** @ignore */
  2234. _isInIntermediateRendering(): boolean;
  2235. private _activeMeshCandidateProvider;
  2236. /**
  2237. * Defines the current active mesh candidate provider
  2238. * @param provider defines the provider to use
  2239. */
  2240. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2241. /**
  2242. * Gets the current active mesh candidate provider
  2243. * @returns the current active mesh candidate provider
  2244. */
  2245. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2246. private _activeMeshesFrozen;
  2247. /**
  2248. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2249. * @returns the current scene
  2250. */
  2251. freezeActiveMeshes(): Scene;
  2252. /**
  2253. * Use this function to restart evaluating active meshes on every frame
  2254. * @returns the current scene
  2255. */
  2256. unfreezeActiveMeshes(): Scene;
  2257. private _evaluateActiveMeshes();
  2258. private _activeMesh(sourceMesh, mesh);
  2259. /**
  2260. * Update the transform matrix to update from the current active camera
  2261. * @param force defines a boolean used to force the update even if cache is up to date
  2262. */
  2263. updateTransformMatrix(force?: boolean): void;
  2264. /**
  2265. * 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)
  2266. * @param alternateCamera defines the camera to use
  2267. */
  2268. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2269. private _renderForCamera(camera, rigParent?);
  2270. private _processSubCameras(camera);
  2271. private _checkIntersections();
  2272. /**
  2273. * Render the scene
  2274. */
  2275. render(): void;
  2276. private _updateAudioParameters();
  2277. /**
  2278. * Gets or sets if audio support is enabled
  2279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2280. */
  2281. audioEnabled: boolean;
  2282. private _disableAudio();
  2283. private _enableAudio();
  2284. /**
  2285. * Gets or sets if audio will be output to headphones
  2286. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2287. */
  2288. headphone: boolean;
  2289. private _switchAudioModeForHeadphones();
  2290. private _switchAudioModeForNormalSpeakers();
  2291. /**
  2292. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  2293. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  2294. * @returns the created depth renderer
  2295. */
  2296. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  2297. /**
  2298. * Disables a depth renderer for a given camera
  2299. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  2300. */
  2301. disableDepthRenderer(camera?: Nullable<Camera>): void;
  2302. /**
  2303. * Enables a GeometryBufferRender and associates it with the scene
  2304. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  2305. * @returns the GeometryBufferRenderer
  2306. */
  2307. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  2308. /**
  2309. * Disables the GeometryBufferRender associated with the scene
  2310. */
  2311. disableGeometryBufferRenderer(): void;
  2312. /**
  2313. * Freeze all materials
  2314. * A frozen material will not be updatable but should be faster to render
  2315. */
  2316. freezeMaterials(): void;
  2317. /**
  2318. * Unfreeze all materials
  2319. * A frozen material will not be updatable but should be faster to render
  2320. */
  2321. unfreezeMaterials(): void;
  2322. /**
  2323. * Releases all held ressources
  2324. */
  2325. dispose(): void;
  2326. /**
  2327. * Gets if the scene is already disposed
  2328. */
  2329. readonly isDisposed: boolean;
  2330. /**
  2331. * Releases sounds & soundtracks
  2332. */
  2333. disposeSounds(): void;
  2334. /**
  2335. * Get the world extend vectors with an optional filter
  2336. *
  2337. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2338. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2339. */
  2340. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2341. min: Vector3;
  2342. max: Vector3;
  2343. };
  2344. /**
  2345. * Creates or updates the octree used to boost selection (picking)
  2346. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2347. * @param maxCapacity defines the maximum capacity per leaf
  2348. * @param maxDepth defines the maximum depth of the octree
  2349. * @returns an octree of AbstractMesh
  2350. */
  2351. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2352. /**
  2353. * Creates a ray that can be used to pick in the scene
  2354. * @param x defines the x coordinate of the origin (on-screen)
  2355. * @param y defines the y coordinate of the origin (on-screen)
  2356. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2357. * @param camera defines the camera to use for the picking
  2358. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2359. * @returns a Ray
  2360. */
  2361. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2362. /**
  2363. * Creates a ray that can be used to pick in the scene
  2364. * @param x defines the x coordinate of the origin (on-screen)
  2365. * @param y defines the y coordinate of the origin (on-screen)
  2366. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2367. * @param result defines the ray where to store the picking ray
  2368. * @param camera defines the camera to use for the picking
  2369. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2370. * @returns the current scene
  2371. */
  2372. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2373. /**
  2374. * Creates a ray that can be used to pick in the scene
  2375. * @param x defines the x coordinate of the origin (on-screen)
  2376. * @param y defines the y coordinate of the origin (on-screen)
  2377. * @param camera defines the camera to use for the picking
  2378. * @returns a Ray
  2379. */
  2380. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2381. /**
  2382. * Creates a ray that can be used to pick in the scene
  2383. * @param x defines the x coordinate of the origin (on-screen)
  2384. * @param y defines the y coordinate of the origin (on-screen)
  2385. * @param result defines the ray where to store the picking ray
  2386. * @param camera defines the camera to use for the picking
  2387. * @returns the current scene
  2388. */
  2389. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2390. private _internalPick(rayFunction, predicate?, fastCheck?);
  2391. private _internalMultiPick(rayFunction, predicate?);
  2392. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  2393. private _tempPickingRay;
  2394. /** Launch a ray to try to pick a mesh in the scene
  2395. * @param x position on screen
  2396. * @param y position on screen
  2397. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2398. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2399. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2400. * @returns a PickingInfo
  2401. */
  2402. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2403. /** Launch a ray to try to pick a sprite in the scene
  2404. * @param x position on screen
  2405. * @param y position on screen
  2406. * @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
  2407. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2408. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2409. * @returns a PickingInfo
  2410. */
  2411. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2412. private _cachedRayForTransform;
  2413. /** Use the given ray to pick a mesh in the scene
  2414. * @param ray The ray to use to pick meshes
  2415. * @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
  2416. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2417. * @returns a PickingInfo
  2418. */
  2419. pickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2420. /**
  2421. * Launch a ray to try to pick a mesh in the scene
  2422. * @param x X position on screen
  2423. * @param y Y position on screen
  2424. * @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
  2425. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2426. * @returns an array of PickingInfo
  2427. */
  2428. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2429. /**
  2430. * Launch a ray to try to pick a mesh in the scene
  2431. * @param ray Ray to use
  2432. * @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
  2433. * @returns an array of PickingInfo
  2434. */
  2435. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2436. /**
  2437. * Force the value of meshUnderPointer
  2438. * @param mesh defines the mesh to use
  2439. */
  2440. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2441. /**
  2442. * Gets the mesh under the pointer
  2443. * @returns a Mesh or null if no mesh is under the pointer
  2444. */
  2445. getPointerOverMesh(): Nullable<AbstractMesh>;
  2446. /**
  2447. * Force the sprite under the pointer
  2448. * @param sprite defines the sprite to use
  2449. */
  2450. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2451. /**
  2452. * Gets the sprite under the pointer
  2453. * @returns a Sprite or null if no sprite is under the pointer
  2454. */
  2455. getPointerOverSprite(): Nullable<Sprite>;
  2456. /**
  2457. * Gets the current physics engine
  2458. * @returns a PhysicsEngine or null if none attached
  2459. */
  2460. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2461. /**
  2462. * Enables physics to the current scene
  2463. * @param gravity defines the scene's gravity for the physics engine
  2464. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2465. * @return a boolean indicating if the physics engine was initialized
  2466. */
  2467. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2468. /**
  2469. * Disables and disposes the physics engine associated with the scene
  2470. */
  2471. disablePhysicsEngine(): void;
  2472. /**
  2473. * Gets a boolean indicating if there is an active physics engine
  2474. * @returns a boolean indicating if there is an active physics engine
  2475. */
  2476. isPhysicsEnabled(): boolean;
  2477. /**
  2478. * Deletes a physics compound impostor
  2479. * @param compound defines the compound to delete
  2480. */
  2481. deleteCompoundImpostor(compound: any): void;
  2482. /** @ignore */
  2483. _rebuildGeometries(): void;
  2484. /** @ignore */
  2485. _rebuildTextures(): void;
  2486. /**
  2487. * Creates a default light for the scene.
  2488. * @param replace Whether to replace the existing lights in the scene.
  2489. */
  2490. createDefaultLight(replace?: boolean): void;
  2491. /**
  2492. * Creates a default camera for the scene.
  2493. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  2494. * @param replace Whether to replace the existing active camera in the scene.
  2495. * @param attachCameraControls Whether to attach camera controls to the canvas.
  2496. */
  2497. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2498. /**
  2499. * Creates a default camera and a default light
  2500. * @param createArcRotateCamera defines that the camera will be an ArcRotateCamera
  2501. * @param replace defines if the camera and/or light will replace the existing ones
  2502. * @param attachCameraControls defines if attachControl will be called on the new camera
  2503. */
  2504. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2505. /**
  2506. * Creates a new sky box
  2507. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2508. * @param environmentTexture defines the texture to use as environment texture
  2509. * @param pbr defines if PBRMaterial must be used instead of StandardMaterial
  2510. * @param scale defines the overall scale of the skybox
  2511. * @param blur defines if blurring must be applied to the environment texture (works only with pbr === true)
  2512. * @returns a new mesh holding the sky box
  2513. */
  2514. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number): Nullable<Mesh>;
  2515. /**
  2516. * Creates a new environment
  2517. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2518. * @param options defines the options you can use to configure the environment
  2519. * @returns the new EnvironmentHelper
  2520. */
  2521. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2522. /**
  2523. * Creates a new VREXperienceHelper
  2524. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2525. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2526. * @returns a new VREXperienceHelper
  2527. */
  2528. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2529. private _getByTags(list, tagsQuery, forEach?);
  2530. /**
  2531. * Get a list of meshes by tags
  2532. * @param tagsQuery defines the tags query to use
  2533. * @param forEach defines a predicate used to filter results
  2534. * @returns an array of Mesh
  2535. */
  2536. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2537. /**
  2538. * Get a list of cameras by tags
  2539. * @param tagsQuery defines the tags query to use
  2540. * @param forEach defines a predicate used to filter results
  2541. * @returns an array of Camera
  2542. */
  2543. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2544. /**
  2545. * Get a list of lights by tags
  2546. * @param tagsQuery defines the tags query to use
  2547. * @param forEach defines a predicate used to filter results
  2548. * @returns an array of Light
  2549. */
  2550. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2551. /**
  2552. * Get a list of materials by tags
  2553. * @param tagsQuery defines the tags query to use
  2554. * @param forEach defines a predicate used to filter results
  2555. * @returns an array of Material
  2556. */
  2557. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2558. /**
  2559. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2560. * This allowed control for front to back rendering or reversly depending of the special needs.
  2561. *
  2562. * @param renderingGroupId The rendering group id corresponding to its index
  2563. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2564. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2565. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2566. */
  2567. 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;
  2568. /**
  2569. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2570. *
  2571. * @param renderingGroupId The rendering group id corresponding to its index
  2572. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2573. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2574. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2575. */
  2576. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2577. /**
  2578. * Will flag all materials as dirty to trigger new shader compilation
  2579. * @param flag defines the flag used to specify which material part must be marked as dirty
  2580. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2581. */
  2582. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2583. /** @ignore */
  2584. _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;
  2585. /** @ignore */
  2586. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2587. }
  2588. }
  2589. declare module BABYLON {
  2590. type Nullable<T> = T | null;
  2591. type float = number;
  2592. type double = number;
  2593. type int = number;
  2594. type FloatArray = number[] | Float32Array;
  2595. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2596. /**
  2597. * Alias for types that can be used by a Buffer or VertexBuffer.
  2598. */
  2599. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2600. }
  2601. declare module BABYLON {
  2602. /**
  2603. * The action to be carried out following a trigger
  2604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2605. */
  2606. class Action {
  2607. triggerOptions: any;
  2608. /**
  2609. * Trigger for the action
  2610. */
  2611. trigger: number;
  2612. /**
  2613. * Internal only - manager for action
  2614. * @ignore
  2615. */
  2616. _actionManager: ActionManager;
  2617. private _nextActiveAction;
  2618. private _child;
  2619. private _condition?;
  2620. private _triggerParameter;
  2621. /**
  2622. * An event triggered prior to action being executed.
  2623. */
  2624. onBeforeExecuteObservable: Observable<Action>;
  2625. /**
  2626. * Creates a new Action
  2627. * @param triggerOptions the trigger, with or without parameters, for the action
  2628. * @param condition an optional determinant of action
  2629. */
  2630. constructor(triggerOptions: any, condition?: Condition);
  2631. /**
  2632. * Internal only
  2633. * @ignore
  2634. */
  2635. _prepare(): void;
  2636. /**
  2637. * Gets the trigger parameters
  2638. * @returns the trigger parameters
  2639. */
  2640. getTriggerParameter(): any;
  2641. /**
  2642. * Internal only - executes current action event
  2643. * @ignore
  2644. */
  2645. _executeCurrent(evt?: ActionEvent): void;
  2646. /**
  2647. * Execute placeholder for child classes
  2648. * @param evt optional action event
  2649. */
  2650. execute(evt?: ActionEvent): void;
  2651. /**
  2652. * Skips to next active action
  2653. */
  2654. skipToNextActiveAction(): void;
  2655. /**
  2656. * Adds action to chain of actions, may be a DoNothingAction
  2657. * @param index The index of the attribute.
  2658. * @returns The action passed in
  2659. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2660. */
  2661. then(action: Action): Action;
  2662. /**
  2663. * Internal only
  2664. * @ignore
  2665. */
  2666. _getProperty(propertyPath: string): string;
  2667. /**
  2668. * Internal only
  2669. * @ignore
  2670. */
  2671. _getEffectiveTarget(target: any, propertyPath: string): any;
  2672. /**
  2673. * Serialize placeholder for child classes
  2674. * @param parent of child
  2675. * @returns the serialized object
  2676. */
  2677. serialize(parent: any): any;
  2678. /**
  2679. * Internal only called by serialize
  2680. * @ignore
  2681. */
  2682. protected _serialize(serializedAction: any, parent?: any): any;
  2683. /**
  2684. * Internal only
  2685. * @ignore
  2686. */
  2687. static _SerializeValueAsString: (value: any) => string;
  2688. /**
  2689. * Internal only
  2690. * @ignore
  2691. */
  2692. static _GetTargetProperty: (target: Scene | Node) => {
  2693. name: string;
  2694. targetType: string;
  2695. value: string;
  2696. };
  2697. }
  2698. }
  2699. declare module BABYLON {
  2700. /**
  2701. * ActionEvent is the event being sent when an action is triggered.
  2702. */
  2703. class ActionEvent {
  2704. source: any;
  2705. pointerX: number;
  2706. pointerY: number;
  2707. meshUnderPointer: Nullable<AbstractMesh>;
  2708. sourceEvent: any;
  2709. additionalData: any;
  2710. /**
  2711. * @param source The mesh or sprite that triggered the action.
  2712. * @param pointerX The X mouse cursor position at the time of the event
  2713. * @param pointerY The Y mouse cursor position at the time of the event
  2714. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2715. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2716. */
  2717. constructor(source: any, pointerX: number, pointerY: number, meshUnderPointer: Nullable<AbstractMesh>, sourceEvent?: any, additionalData?: any);
  2718. /**
  2719. * Helper function to auto-create an ActionEvent from a source mesh.
  2720. * @param source The source mesh that triggered the event
  2721. * @param evt {Event} The original (browser) event
  2722. */
  2723. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2724. /**
  2725. * Helper function to auto-create an ActionEvent from a source mesh.
  2726. * @param source The source sprite that triggered the event
  2727. * @param scene Scene associated with the sprite
  2728. * @param evt {Event} The original (browser) event
  2729. */
  2730. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2731. /**
  2732. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2733. * @param scene the scene where the event occurred
  2734. * @param evt {Event} The original (browser) event
  2735. */
  2736. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2737. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2738. }
  2739. /**
  2740. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2741. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2742. */
  2743. class ActionManager {
  2744. private static _NothingTrigger;
  2745. private static _OnPickTrigger;
  2746. private static _OnLeftPickTrigger;
  2747. private static _OnRightPickTrigger;
  2748. private static _OnCenterPickTrigger;
  2749. private static _OnPickDownTrigger;
  2750. private static _OnDoublePickTrigger;
  2751. private static _OnPickUpTrigger;
  2752. private static _OnLongPressTrigger;
  2753. private static _OnPointerOverTrigger;
  2754. private static _OnPointerOutTrigger;
  2755. private static _OnEveryFrameTrigger;
  2756. private static _OnIntersectionEnterTrigger;
  2757. private static _OnIntersectionExitTrigger;
  2758. private static _OnKeyDownTrigger;
  2759. private static _OnKeyUpTrigger;
  2760. private static _OnPickOutTrigger;
  2761. static readonly NothingTrigger: number;
  2762. static readonly OnPickTrigger: number;
  2763. static readonly OnLeftPickTrigger: number;
  2764. static readonly OnRightPickTrigger: number;
  2765. static readonly OnCenterPickTrigger: number;
  2766. static readonly OnPickDownTrigger: number;
  2767. static readonly OnDoublePickTrigger: number;
  2768. static readonly OnPickUpTrigger: number;
  2769. static readonly OnPickOutTrigger: number;
  2770. static readonly OnLongPressTrigger: number;
  2771. static readonly OnPointerOverTrigger: number;
  2772. static readonly OnPointerOutTrigger: number;
  2773. static readonly OnEveryFrameTrigger: number;
  2774. static readonly OnIntersectionEnterTrigger: number;
  2775. static readonly OnIntersectionExitTrigger: number;
  2776. static readonly OnKeyDownTrigger: number;
  2777. static readonly OnKeyUpTrigger: number;
  2778. static Triggers: {
  2779. [key: string]: number;
  2780. };
  2781. actions: Action[];
  2782. hoverCursor: string;
  2783. private _scene;
  2784. constructor(scene: Scene);
  2785. dispose(): void;
  2786. getScene(): Scene;
  2787. /**
  2788. * Does this action manager handles actions of any of the given triggers
  2789. * @param {number[]} triggers - the triggers to be tested
  2790. * @return {boolean} whether one (or more) of the triggers is handeled
  2791. */
  2792. hasSpecificTriggers(triggers: number[]): boolean;
  2793. /**
  2794. * Does this action manager handles actions of a given trigger
  2795. * @param trigger defines the trigger to be tested
  2796. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2797. * @return whether the trigger is handled
  2798. */
  2799. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2800. /**
  2801. * Does this action manager has pointer triggers
  2802. * @return {boolean} whether or not it has pointer triggers
  2803. */
  2804. readonly hasPointerTriggers: boolean;
  2805. /**
  2806. * Does this action manager has pick triggers
  2807. * @return {boolean} whether or not it has pick triggers
  2808. */
  2809. readonly hasPickTriggers: boolean;
  2810. /**
  2811. * Does exist one action manager with at least one trigger
  2812. * @return {boolean} whether or not it exists one action manager with one trigger
  2813. **/
  2814. static readonly HasTriggers: boolean;
  2815. /**
  2816. * Does exist one action manager with at least one pick trigger
  2817. * @return {boolean} whether or not it exists one action manager with one pick trigger
  2818. **/
  2819. static readonly HasPickTriggers: boolean;
  2820. /**
  2821. * Does exist one action manager that handles actions of a given trigger
  2822. * @param {number} trigger - the trigger to be tested
  2823. * @return {boolean} whether the trigger is handeled by at least one action manager
  2824. **/
  2825. static HasSpecificTrigger(trigger: number): boolean;
  2826. /**
  2827. * Registers an action to this action manager
  2828. * @param {BABYLON.Action} action - the action to be registered
  2829. * @return {BABYLON.Action} the action amended (prepared) after registration
  2830. */
  2831. registerAction(action: Action): Nullable<Action>;
  2832. /**
  2833. * Unregisters an action to this action manager
  2834. * @param action The action to be unregistered
  2835. * @return whether the action has been unregistered
  2836. */
  2837. unregisterAction(action: Action): Boolean;
  2838. /**
  2839. * Process a specific trigger
  2840. * @param {number} trigger - the trigger to process
  2841. * @param evt {BABYLON.ActionEvent} the event details to be processed
  2842. */
  2843. processTrigger(trigger: number, evt?: ActionEvent): void;
  2844. _getEffectiveTarget(target: any, propertyPath: string): any;
  2845. _getProperty(propertyPath: string): string;
  2846. serialize(name: string): any;
  2847. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  2848. static GetTriggerName(trigger: number): string;
  2849. }
  2850. }
  2851. declare module BABYLON {
  2852. /**
  2853. * A Condition applied to an Action
  2854. */
  2855. class Condition {
  2856. /**
  2857. * Internal only - manager for action
  2858. * @ignore
  2859. */
  2860. _actionManager: ActionManager;
  2861. /**
  2862. * Internal only
  2863. * @ignore
  2864. */
  2865. _evaluationId: number;
  2866. /**
  2867. * Internal only
  2868. * @ignore
  2869. */
  2870. _currentResult: boolean;
  2871. /**
  2872. * Creates a new Condition
  2873. * @param actionManager the manager of the action the condition is applied to
  2874. */
  2875. constructor(actionManager: ActionManager);
  2876. /**
  2877. * Check if the current condition is valid
  2878. * @returns a boolean
  2879. */
  2880. isValid(): boolean;
  2881. /**
  2882. * Internal only
  2883. * @ignore
  2884. */
  2885. _getProperty(propertyPath: string): string;
  2886. /**
  2887. * Internal only
  2888. * @ignore
  2889. */
  2890. _getEffectiveTarget(target: any, propertyPath: string): any;
  2891. /**
  2892. * Serialize placeholder for child classes
  2893. * @returns the serialized object
  2894. */
  2895. serialize(): any;
  2896. /**
  2897. * Internal only
  2898. * @ignore
  2899. */
  2900. protected _serialize(serializedCondition: any): any;
  2901. }
  2902. /**
  2903. * Defines specific conditional operators as extensions of Condition
  2904. */
  2905. class ValueCondition extends Condition {
  2906. /** path to specify the property of the target the conditional operator uses */
  2907. propertyPath: string;
  2908. /** the value compared by the conditional operator against the current value of the property */
  2909. value: any;
  2910. /** the conditional operator, default ValueCondition.IsEqual */
  2911. operator: number;
  2912. /**
  2913. * Internal only
  2914. * @ignore
  2915. */
  2916. private static _IsEqual;
  2917. /**
  2918. * Internal only
  2919. * @ignore
  2920. */
  2921. private static _IsDifferent;
  2922. /**
  2923. * Internal only
  2924. * @ignore
  2925. */
  2926. private static _IsGreater;
  2927. /**
  2928. * Internal only
  2929. * @ignore
  2930. */
  2931. private static _IsLesser;
  2932. /**
  2933. * returns the number for IsEqual
  2934. */
  2935. static readonly IsEqual: number;
  2936. /**
  2937. * Returns the number for IsDifferent
  2938. */
  2939. static readonly IsDifferent: number;
  2940. /**
  2941. * Returns the number for IsGreater
  2942. */
  2943. static readonly IsGreater: number;
  2944. /**
  2945. * Returns the number for IsLesser
  2946. */
  2947. static readonly IsLesser: number;
  2948. /**
  2949. * Internal only The action manager for the condition
  2950. * @ignore
  2951. */
  2952. _actionManager: ActionManager;
  2953. /**
  2954. * Internal only
  2955. * @ignore
  2956. */
  2957. private _target;
  2958. /**
  2959. * Internal only
  2960. * @ignore
  2961. */
  2962. private _effectiveTarget;
  2963. /**
  2964. * Internal only
  2965. * @ignore
  2966. */
  2967. private _property;
  2968. /**
  2969. * Creates a new ValueCondition
  2970. * @param actionManager manager for the action the condition applies to
  2971. * @param target for the action
  2972. * @param propertyPath path to specify the property of the target the conditional operator uses
  2973. * @param value the value compared by the conditional operator against the current value of the property
  2974. * @param operator the conditional operator, default ValueCondition.IsEqual
  2975. */
  2976. constructor(actionManager: ActionManager, target: any,
  2977. /** path to specify the property of the target the conditional operator uses */
  2978. propertyPath: string,
  2979. /** the value compared by the conditional operator against the current value of the property */
  2980. value: any,
  2981. /** the conditional operator, default ValueCondition.IsEqual */
  2982. operator?: number);
  2983. /**
  2984. * Compares the given value with the property value for the specified conditional operator
  2985. * @returns the result of the comparison
  2986. */
  2987. isValid(): boolean;
  2988. /**
  2989. * Serialize the ValueCondition into a JSON compatible object
  2990. * @returns serialization object
  2991. */
  2992. serialize(): any;
  2993. /**
  2994. * Gets the name of the conditional operator for the ValueCondition
  2995. * @param operator the conditional operator
  2996. * @returns the name
  2997. */
  2998. static GetOperatorName(operator: number): string;
  2999. }
  3000. /**
  3001. * Defines a predicate condition as an extension of Condition
  3002. */
  3003. class PredicateCondition extends Condition {
  3004. /** defines the predicate function used to validate the condition */
  3005. predicate: () => boolean;
  3006. /**
  3007. * Internal only - manager for action
  3008. * @ignore
  3009. */
  3010. _actionManager: ActionManager;
  3011. /**
  3012. * Creates a new PredicateCondition
  3013. * @param actionManager manager for the action the condition applies to
  3014. * @param predicate defines the predicate function used to validate the condition
  3015. */
  3016. constructor(actionManager: ActionManager,
  3017. /** defines the predicate function used to validate the condition */
  3018. predicate: () => boolean);
  3019. /**
  3020. * @returns the validity of the predicate condition
  3021. */
  3022. isValid(): boolean;
  3023. }
  3024. /**
  3025. * Defines a state condition as an extension of Condition
  3026. */
  3027. class StateCondition extends Condition {
  3028. value: string;
  3029. /**
  3030. * Internal only - manager for action
  3031. * @ignore
  3032. */
  3033. _actionManager: ActionManager;
  3034. /**
  3035. * Internal only
  3036. * @ignore
  3037. */
  3038. private _target;
  3039. /**
  3040. * Creates a new StateCondition
  3041. * @param actionManager manager for the action the condition applies to
  3042. * @param target of the condition
  3043. * @param value to compare with target state
  3044. */
  3045. constructor(actionManager: ActionManager, target: any, value: string);
  3046. /**
  3047. * @returns the validity of the state
  3048. */
  3049. isValid(): boolean;
  3050. /**
  3051. * Serialize the StateCondition into a JSON compatible object
  3052. * @returns serialization object
  3053. */
  3054. serialize(): any;
  3055. }
  3056. }
  3057. declare module BABYLON {
  3058. class SwitchBooleanAction extends Action {
  3059. propertyPath: string;
  3060. private _target;
  3061. private _effectiveTarget;
  3062. private _property;
  3063. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3064. _prepare(): void;
  3065. execute(): void;
  3066. serialize(parent: any): any;
  3067. }
  3068. class SetStateAction extends Action {
  3069. value: string;
  3070. private _target;
  3071. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3072. execute(): void;
  3073. serialize(parent: any): any;
  3074. }
  3075. class SetValueAction extends Action {
  3076. propertyPath: string;
  3077. value: any;
  3078. private _target;
  3079. private _effectiveTarget;
  3080. private _property;
  3081. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3082. _prepare(): void;
  3083. execute(): void;
  3084. serialize(parent: any): any;
  3085. }
  3086. class IncrementValueAction extends Action {
  3087. propertyPath: string;
  3088. value: any;
  3089. private _target;
  3090. private _effectiveTarget;
  3091. private _property;
  3092. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3093. _prepare(): void;
  3094. execute(): void;
  3095. serialize(parent: any): any;
  3096. }
  3097. class PlayAnimationAction extends Action {
  3098. from: number;
  3099. to: number;
  3100. loop: boolean | undefined;
  3101. private _target;
  3102. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3103. _prepare(): void;
  3104. execute(): void;
  3105. serialize(parent: any): any;
  3106. }
  3107. class StopAnimationAction extends Action {
  3108. private _target;
  3109. constructor(triggerOptions: any, target: any, condition?: Condition);
  3110. _prepare(): void;
  3111. execute(): void;
  3112. serialize(parent: any): any;
  3113. }
  3114. class DoNothingAction extends Action {
  3115. constructor(triggerOptions?: any, condition?: Condition);
  3116. execute(): void;
  3117. serialize(parent: any): any;
  3118. }
  3119. class CombineAction extends Action {
  3120. children: Action[];
  3121. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3122. _prepare(): void;
  3123. execute(evt: ActionEvent): void;
  3124. serialize(parent: any): any;
  3125. }
  3126. class ExecuteCodeAction extends Action {
  3127. func: (evt: ActionEvent) => void;
  3128. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3129. execute(evt: ActionEvent): void;
  3130. }
  3131. class SetParentAction extends Action {
  3132. private _parent;
  3133. private _target;
  3134. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3135. _prepare(): void;
  3136. execute(): void;
  3137. serialize(parent: any): any;
  3138. }
  3139. class PlaySoundAction extends Action {
  3140. private _sound;
  3141. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3142. _prepare(): void;
  3143. execute(): void;
  3144. serialize(parent: any): any;
  3145. }
  3146. class StopSoundAction extends Action {
  3147. private _sound;
  3148. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3149. _prepare(): void;
  3150. execute(): void;
  3151. serialize(parent: any): any;
  3152. }
  3153. }
  3154. declare module BABYLON {
  3155. class InterpolateValueAction extends Action {
  3156. propertyPath: string;
  3157. value: any;
  3158. duration: number;
  3159. stopOtherAnimations: boolean | undefined;
  3160. onInterpolationDone: (() => void) | undefined;
  3161. private _target;
  3162. private _effectiveTarget;
  3163. private _property;
  3164. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3165. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3166. _prepare(): void;
  3167. execute(): void;
  3168. serialize(parent: any): any;
  3169. }
  3170. }
  3171. declare module BABYLON {
  3172. class Animatable {
  3173. target: any;
  3174. fromFrame: number;
  3175. toFrame: number;
  3176. loopAnimation: boolean;
  3177. onAnimationEnd: (() => void) | null | undefined;
  3178. private _localDelayOffset;
  3179. private _pausedDelay;
  3180. private _runtimeAnimations;
  3181. private _paused;
  3182. private _scene;
  3183. private _speedRatio;
  3184. private _weight;
  3185. private _syncRoot;
  3186. animationStarted: boolean;
  3187. /**
  3188. * Gets the root Animatable used to synchronize and normalize animations
  3189. */
  3190. readonly syncRoot: Animatable;
  3191. /**
  3192. * Gets the current frame of the first RuntimeAnimation
  3193. * Used to synchronize Animatables
  3194. */
  3195. readonly masterFrame: number;
  3196. /**
  3197. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3198. */
  3199. weight: number;
  3200. /**
  3201. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3202. */
  3203. speedRatio: number;
  3204. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  3205. /**
  3206. * Synchronize and normalize current Animatable with a source Animatable
  3207. * This is useful when using animation weights and when animations are not of the same length
  3208. * @param root defines the root Animatable to synchronize with
  3209. * @returns the current Animatable
  3210. */
  3211. syncWith(root: Animatable): Animatable;
  3212. getAnimations(): RuntimeAnimation[];
  3213. appendAnimations(target: any, animations: Animation[]): void;
  3214. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3215. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3216. reset(): void;
  3217. enableBlending(blendingSpeed: number): void;
  3218. disableBlending(): void;
  3219. goToFrame(frame: number): void;
  3220. pause(): void;
  3221. restart(): void;
  3222. stop(animationName?: string): void;
  3223. _animate(delay: number): boolean;
  3224. }
  3225. }
  3226. declare module BABYLON {
  3227. class AnimationRange {
  3228. name: string;
  3229. from: number;
  3230. to: number;
  3231. constructor(name: string, from: number, to: number);
  3232. clone(): AnimationRange;
  3233. }
  3234. /**
  3235. * Composed of a frame, and an action function
  3236. */
  3237. class AnimationEvent {
  3238. frame: number;
  3239. action: () => void;
  3240. onlyOnce: boolean | undefined;
  3241. isDone: boolean;
  3242. constructor(frame: number, action: () => void, onlyOnce?: boolean | undefined);
  3243. }
  3244. class PathCursor {
  3245. private path;
  3246. private _onchange;
  3247. value: number;
  3248. animations: Animation[];
  3249. constructor(path: Path2);
  3250. getPoint(): Vector3;
  3251. moveAhead(step?: number): PathCursor;
  3252. moveBack(step?: number): PathCursor;
  3253. move(step: number): PathCursor;
  3254. private ensureLimits();
  3255. private raiseOnChange();
  3256. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3257. }
  3258. interface IAnimationKey {
  3259. frame: number;
  3260. value: any;
  3261. inTangent?: any;
  3262. outTangent?: any;
  3263. interpolation?: AnimationKeyInterpolation;
  3264. }
  3265. enum AnimationKeyInterpolation {
  3266. /**
  3267. * Do not interpolate between keys and use the start key value only. Tangents are ignored.
  3268. */
  3269. STEP = 1,
  3270. }
  3271. /**
  3272. * Class used to store any kind of animation
  3273. */
  3274. class Animation {
  3275. name: string;
  3276. targetProperty: string;
  3277. framePerSecond: number;
  3278. dataType: number;
  3279. loopMode: number | undefined;
  3280. enableBlending: boolean | undefined;
  3281. /**
  3282. * Use matrix interpolation instead of using direct key value when animating matrices
  3283. */
  3284. static AllowMatricesInterpolation: boolean;
  3285. /**
  3286. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3287. */
  3288. static AllowMatrixDecomposeForInterpolation: boolean;
  3289. private _keys;
  3290. private _easingFunction;
  3291. _runtimeAnimations: RuntimeAnimation[];
  3292. private _events;
  3293. targetPropertyPath: string[];
  3294. blendingSpeed: number;
  3295. private _ranges;
  3296. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3297. /**
  3298. * Sets up an animation.
  3299. * @param property the property to animate
  3300. * @param animationType the animation type to apply
  3301. * @param easingFunction the easing function used in the animation
  3302. * @returns The created animation
  3303. */
  3304. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3305. /**
  3306. * Create and start an animation on a node
  3307. * @param {string} name defines the name of the global animation that will be run on all nodes
  3308. * @param {BABYLON.Node} node defines the root node where the animation will take place
  3309. * @param {string} targetProperty defines property to animate
  3310. * @param {number} framePerSecond defines the number of frame per second yo use
  3311. * @param {number} totalFrame defines the number of frames in total
  3312. * @param {any} from defines the initial value
  3313. * @param {any} to defines the final value
  3314. * @param {number} loopMode defines which loop mode you want to use (off by default)
  3315. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  3316. * @param onAnimationEnd defines the callback to call when animation end
  3317. * @returns the animatable created for this animation
  3318. */
  3319. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3320. /**
  3321. * Create and start an animation on a node and its descendants
  3322. * @param {string} name defines the name of the global animation that will be run on all nodes
  3323. * @param {BABYLON.Node} node defines the root node where the animation will take place
  3324. * @param {boolean} 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.
  3325. * @param {string} targetProperty defines property to animate
  3326. * @param {number} framePerSecond defines the number of frame per second yo use
  3327. * @param {number} totalFrame defines the number of frames in total
  3328. * @param {any} from defines the initial value
  3329. * @param {any} to defines the final value
  3330. * @param {number} loopMode defines which loop mode you want to use (off by default)
  3331. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  3332. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3333. * @returns the list of animatables created for all nodes
  3334. * @example https://www.babylonjs-playground.com/#MH0VLI
  3335. */
  3336. 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[]>;
  3337. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3338. /**
  3339. * Transition property of the Camera to the target Value.
  3340. * @param property The property to transition
  3341. * @param targetValue The target Value of the property
  3342. * @param host The object where the property to animate belongs
  3343. * @param scene Scene used to run the animation
  3344. * @param frameRate Framerate (in frame/s) to use
  3345. * @param transition The transition type we want to use
  3346. * @param duration The duration of the animation, in milliseconds
  3347. * @param onAnimationEnd Call back trigger at the end of the animation.
  3348. */
  3349. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3350. /**
  3351. * Return the array of runtime animations currently using this animation
  3352. */
  3353. readonly runtimeAnimations: RuntimeAnimation[];
  3354. readonly hasRunningRuntimeAnimations: boolean;
  3355. constructor(name: string, targetProperty: string, framePerSecond: number, dataType: number, loopMode?: number | undefined, enableBlending?: boolean | undefined);
  3356. /**
  3357. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  3358. */
  3359. toString(fullDetails?: boolean): string;
  3360. /**
  3361. * Add an event to this animation.
  3362. */
  3363. addEvent(event: AnimationEvent): void;
  3364. /**
  3365. * Remove all events found at the given frame
  3366. * @param frame
  3367. */
  3368. removeEvents(frame: number): void;
  3369. getEvents(): AnimationEvent[];
  3370. createRange(name: string, from: number, to: number): void;
  3371. deleteRange(name: string, deleteFrames?: boolean): void;
  3372. getRange(name: string): Nullable<AnimationRange>;
  3373. getKeys(): Array<IAnimationKey>;
  3374. getHighestFrame(): number;
  3375. getEasingFunction(): IEasingFunction;
  3376. setEasingFunction(easingFunction: EasingFunction): void;
  3377. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3378. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3379. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3380. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3381. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3382. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3383. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  3384. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  3385. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  3386. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  3387. /**
  3388. * Defines the function to use to interpolate matrices
  3389. * @param startValue defines the start matrix
  3390. * @param endValue defines the end matrix
  3391. * @param gradient defines the gradient between both matrices
  3392. * @param result defines an optional target matrix where to store the interpolation
  3393. * @returns the interpolated matrix
  3394. */
  3395. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  3396. clone(): Animation;
  3397. setKeys(values: Array<IAnimationKey>): void;
  3398. serialize(): any;
  3399. private static _ANIMATIONTYPE_FLOAT;
  3400. private static _ANIMATIONTYPE_VECTOR3;
  3401. private static _ANIMATIONTYPE_QUATERNION;
  3402. private static _ANIMATIONTYPE_MATRIX;
  3403. private static _ANIMATIONTYPE_COLOR3;
  3404. private static _ANIMATIONTYPE_VECTOR2;
  3405. private static _ANIMATIONTYPE_SIZE;
  3406. private static _ANIMATIONLOOPMODE_RELATIVE;
  3407. private static _ANIMATIONLOOPMODE_CYCLE;
  3408. private static _ANIMATIONLOOPMODE_CONSTANT;
  3409. static readonly ANIMATIONTYPE_FLOAT: number;
  3410. static readonly ANIMATIONTYPE_VECTOR3: number;
  3411. static readonly ANIMATIONTYPE_VECTOR2: number;
  3412. static readonly ANIMATIONTYPE_SIZE: number;
  3413. static readonly ANIMATIONTYPE_QUATERNION: number;
  3414. static readonly ANIMATIONTYPE_MATRIX: number;
  3415. static readonly ANIMATIONTYPE_COLOR3: number;
  3416. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  3417. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  3418. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  3419. static Parse(parsedAnimation: any): Animation;
  3420. static AppendSerializedAnimations(source: IAnimatable, destination: any): any;
  3421. }
  3422. }
  3423. declare module BABYLON {
  3424. /**
  3425. * This class defines the direct association between an animation and a target
  3426. */
  3427. class TargetedAnimation {
  3428. animation: Animation;
  3429. target: any;
  3430. }
  3431. /**
  3432. * Use this class to create coordinated animations on multiple targets
  3433. */
  3434. class AnimationGroup implements IDisposable {
  3435. name: string;
  3436. private _scene;
  3437. private _targetedAnimations;
  3438. private _animatables;
  3439. private _from;
  3440. private _to;
  3441. private _isStarted;
  3442. private _speedRatio;
  3443. onAnimationEndObservable: Observable<TargetedAnimation>;
  3444. /**
  3445. * Define if the animations are started
  3446. */
  3447. readonly isStarted: boolean;
  3448. /**
  3449. * Gets or sets the speed ratio to use for all animations
  3450. */
  3451. /**
  3452. * Gets or sets the speed ratio to use for all animations
  3453. */
  3454. speedRatio: number;
  3455. /**
  3456. * Gets the targeted animations for this animation group
  3457. */
  3458. readonly targetedAnimations: Array<TargetedAnimation>;
  3459. /**
  3460. * returning the list of animatables controlled by this animation group.
  3461. */
  3462. readonly animatables: Array<Animatable>;
  3463. constructor(name: string, scene?: Nullable<Scene>);
  3464. /**
  3465. * Add an animation (with its target) in the group
  3466. * @param animation defines the animation we want to add
  3467. * @param target defines the target of the animation
  3468. * @returns the {BABYLON.TargetedAnimation} object
  3469. */
  3470. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  3471. /**
  3472. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  3473. * It can add constant keys at begin or end
  3474. * @param beginFrame defines the new begin frame for all animations. It can't be bigger than the smallest begin frame of all animations
  3475. * @param endFrame defines the new end frame for all animations. It can't be smaller than the largest end frame of all animations
  3476. */
  3477. normalize(beginFrame?: number, endFrame?: number): AnimationGroup;
  3478. /**
  3479. * Start all animations on given targets
  3480. * @param loop defines if animations must loop
  3481. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  3482. * @param from defines the from key (optional)
  3483. * @param to defines the to key (optional)
  3484. * @returns the current animation group
  3485. */
  3486. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  3487. /**
  3488. * Pause all animations
  3489. */
  3490. pause(): AnimationGroup;
  3491. /**
  3492. * Play all animations to initial state
  3493. * This function will start() the animations if they were not started or will restart() them if they were paused
  3494. * @param loop defines if animations must loop
  3495. */
  3496. play(loop?: boolean): AnimationGroup;
  3497. /**
  3498. * Reset all animations to initial state
  3499. */
  3500. reset(): AnimationGroup;
  3501. /**
  3502. * Restart animations from key 0
  3503. */
  3504. restart(): AnimationGroup;
  3505. /**
  3506. * Stop all animations
  3507. */
  3508. stop(): AnimationGroup;
  3509. /**
  3510. * Set animation weight for all animatables
  3511. * @param weight defines the weight to use
  3512. * @return the animationGroup
  3513. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  3514. */
  3515. setWeightForAllAnimatables(weight: number): AnimationGroup;
  3516. /**
  3517. * Synchronize and normalize all animatables with a source animatable
  3518. * @param root defines the root animatable to synchronize with
  3519. * @return the animationGroup
  3520. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  3521. */
  3522. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  3523. /**
  3524. * Goes to a specific frame in this animation group
  3525. * @param frame the frame number to go to
  3526. * @return the animationGroup
  3527. */
  3528. goToFrame(frame: number): AnimationGroup;
  3529. /**
  3530. * Dispose all associated resources
  3531. */
  3532. dispose(): void;
  3533. }
  3534. }
  3535. declare module BABYLON {
  3536. /**
  3537. * Class used to override all child animations of a given target
  3538. */
  3539. class AnimationPropertiesOverride {
  3540. /**
  3541. * Gets or sets a value indicating if animation blending must be used
  3542. */
  3543. enableBlending: boolean;
  3544. /**
  3545. * Gets or sets the blending speed to use when enableBlending is true
  3546. */
  3547. blendingSpeed: number;
  3548. /**
  3549. * Gets or sets the default loop mode to use
  3550. */
  3551. loopMode: number;
  3552. }
  3553. }
  3554. declare module BABYLON {
  3555. interface IEasingFunction {
  3556. ease(gradient: number): number;
  3557. }
  3558. class EasingFunction implements IEasingFunction {
  3559. private static _EASINGMODE_EASEIN;
  3560. private static _EASINGMODE_EASEOUT;
  3561. private static _EASINGMODE_EASEINOUT;
  3562. static readonly EASINGMODE_EASEIN: number;
  3563. static readonly EASINGMODE_EASEOUT: number;
  3564. static readonly EASINGMODE_EASEINOUT: number;
  3565. private _easingMode;
  3566. setEasingMode(easingMode: number): void;
  3567. getEasingMode(): number;
  3568. easeInCore(gradient: number): number;
  3569. ease(gradient: number): number;
  3570. }
  3571. class CircleEase extends EasingFunction implements IEasingFunction {
  3572. easeInCore(gradient: number): number;
  3573. }
  3574. class BackEase extends EasingFunction implements IEasingFunction {
  3575. amplitude: number;
  3576. constructor(amplitude?: number);
  3577. easeInCore(gradient: number): number;
  3578. }
  3579. class BounceEase extends EasingFunction implements IEasingFunction {
  3580. bounces: number;
  3581. bounciness: number;
  3582. constructor(bounces?: number, bounciness?: number);
  3583. easeInCore(gradient: number): number;
  3584. }
  3585. class CubicEase extends EasingFunction implements IEasingFunction {
  3586. easeInCore(gradient: number): number;
  3587. }
  3588. class ElasticEase extends EasingFunction implements IEasingFunction {
  3589. oscillations: number;
  3590. springiness: number;
  3591. constructor(oscillations?: number, springiness?: number);
  3592. easeInCore(gradient: number): number;
  3593. }
  3594. class ExponentialEase extends EasingFunction implements IEasingFunction {
  3595. exponent: number;
  3596. constructor(exponent?: number);
  3597. easeInCore(gradient: number): number;
  3598. }
  3599. class PowerEase extends EasingFunction implements IEasingFunction {
  3600. power: number;
  3601. constructor(power?: number);
  3602. easeInCore(gradient: number): number;
  3603. }
  3604. class QuadraticEase extends EasingFunction implements IEasingFunction {
  3605. easeInCore(gradient: number): number;
  3606. }
  3607. class QuarticEase extends EasingFunction implements IEasingFunction {
  3608. easeInCore(gradient: number): number;
  3609. }
  3610. class QuinticEase extends EasingFunction implements IEasingFunction {
  3611. easeInCore(gradient: number): number;
  3612. }
  3613. class SineEase extends EasingFunction implements IEasingFunction {
  3614. easeInCore(gradient: number): number;
  3615. }
  3616. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  3617. x1: number;
  3618. y1: number;
  3619. x2: number;
  3620. y2: number;
  3621. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  3622. easeInCore(gradient: number): number;
  3623. }
  3624. }
  3625. declare module BABYLON {
  3626. class RuntimeAnimation {
  3627. private _currentFrame;
  3628. private _animation;
  3629. private _target;
  3630. private _host;
  3631. private _originalValue;
  3632. private _originalBlendValue;
  3633. private _offsetsCache;
  3634. private _highLimitsCache;
  3635. private _stopped;
  3636. private _blendingFactor;
  3637. private _scene;
  3638. private _currentValue;
  3639. /** @ignore */
  3640. _workValue: any;
  3641. private _activeTarget;
  3642. private _targetPath;
  3643. private _weight;
  3644. /**
  3645. * Gets the current frame
  3646. */
  3647. readonly currentFrame: number;
  3648. /**
  3649. * Gets the weight of the runtime animation
  3650. */
  3651. readonly weight: number;
  3652. /**
  3653. * Gets the original value of the runtime animation
  3654. */
  3655. readonly originalValue: any;
  3656. /**
  3657. * Gets the current value of the runtime animation
  3658. */
  3659. readonly currentValue: any;
  3660. /**
  3661. * Gets the path where to store the animated value in the target
  3662. */
  3663. readonly targetPath: string;
  3664. /**
  3665. * Gets the actual target of the runtime animation
  3666. */
  3667. readonly target: any;
  3668. /**
  3669. * Create a new RuntimeAnimation object
  3670. * @param target defines the target of the animation
  3671. * @param animation defines the source {BABYLON.Animation} object
  3672. * @param scene defines the hosting scene
  3673. * @param host defines the initiating Animatable
  3674. */
  3675. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  3676. readonly animation: Animation;
  3677. reset(): void;
  3678. isStopped(): boolean;
  3679. dispose(): void;
  3680. private _getKeyValue(value);
  3681. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  3682. /**
  3683. * Affect the interpolated value to the target
  3684. * @param currentValue defines the value computed by the animation
  3685. * @param weight defines the weight to apply to this value
  3686. */
  3687. setValue(currentValue: any, weight?: number): void;
  3688. private _setValue(target, currentValue, weight?);
  3689. private _getCorrectLoopMode();
  3690. /**
  3691. * Move the current animation to a given frame
  3692. * @param frame defines the frame to move to
  3693. */
  3694. goToFrame(frame: number): void;
  3695. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  3696. private _ratioOffset;
  3697. private _previousDelay;
  3698. private _previousRatio;
  3699. /**
  3700. * Execute the current animation
  3701. * @param delay defines the delay to add to the current frame
  3702. * @param from defines the lower bound of the animation range
  3703. * @param to defines the upper bound of the animation range
  3704. * @param loop defines if the current animation must loop
  3705. * @param speedRatio defines the current speed ratio
  3706. * @param weight defines the weight of the animation (default is -1 so no weight)
  3707. * @returns a boolean indicating if the animation has ended
  3708. */
  3709. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  3710. }
  3711. }
  3712. declare module BABYLON {
  3713. class Analyser {
  3714. SMOOTHING: number;
  3715. FFT_SIZE: number;
  3716. BARGRAPHAMPLITUDE: number;
  3717. DEBUGCANVASPOS: {
  3718. x: number;
  3719. y: number;
  3720. };
  3721. DEBUGCANVASSIZE: {
  3722. width: number;
  3723. height: number;
  3724. };
  3725. private _byteFreqs;
  3726. private _byteTime;
  3727. private _floatFreqs;
  3728. private _webAudioAnalyser;
  3729. private _debugCanvas;
  3730. private _debugCanvasContext;
  3731. private _scene;
  3732. private _registerFunc;
  3733. private _audioEngine;
  3734. constructor(scene: Scene);
  3735. getFrequencyBinCount(): number;
  3736. getByteFrequencyData(): Uint8Array;
  3737. getByteTimeDomainData(): Uint8Array;
  3738. getFloatFrequencyData(): Uint8Array;
  3739. drawDebugCanvas(): void;
  3740. stopDebugCanvas(): void;
  3741. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  3742. dispose(): void;
  3743. }
  3744. }
  3745. declare module BABYLON {
  3746. class AudioEngine {
  3747. private _audioContext;
  3748. private _audioContextInitialized;
  3749. canUseWebAudio: boolean;
  3750. masterGain: GainNode;
  3751. private _connectedAnalyser;
  3752. WarnedWebAudioUnsupported: boolean;
  3753. unlocked: boolean;
  3754. onAudioUnlocked: () => any;
  3755. isMP3supported: boolean;
  3756. isOGGsupported: boolean;
  3757. readonly audioContext: Nullable<AudioContext>;
  3758. constructor();
  3759. private _unlockiOSaudio();
  3760. private _initializeAudioContext();
  3761. dispose(): void;
  3762. getGlobalVolume(): number;
  3763. setGlobalVolume(newVolume: number): void;
  3764. connectToAnalyser(analyser: Analyser): void;
  3765. }
  3766. }
  3767. declare module BABYLON {
  3768. class Sound {
  3769. name: string;
  3770. autoplay: boolean;
  3771. loop: boolean;
  3772. useCustomAttenuation: boolean;
  3773. soundTrackId: number;
  3774. spatialSound: boolean;
  3775. refDistance: number;
  3776. rolloffFactor: number;
  3777. maxDistance: number;
  3778. distanceModel: string;
  3779. private _panningModel;
  3780. onended: () => any;
  3781. private _playbackRate;
  3782. private _streaming;
  3783. private _startTime;
  3784. private _startOffset;
  3785. private _position;
  3786. private _localDirection;
  3787. private _volume;
  3788. private _isReadyToPlay;
  3789. isPlaying: boolean;
  3790. isPaused: boolean;
  3791. private _isDirectional;
  3792. private _readyToPlayCallback;
  3793. private _audioBuffer;
  3794. private _soundSource;
  3795. private _streamingSource;
  3796. private _soundPanner;
  3797. private _soundGain;
  3798. private _inputAudioNode;
  3799. private _ouputAudioNode;
  3800. private _coneInnerAngle;
  3801. private _coneOuterAngle;
  3802. private _coneOuterGain;
  3803. private _scene;
  3804. private _connectedMesh;
  3805. private _customAttenuationFunction;
  3806. private _registerFunc;
  3807. private _isOutputConnected;
  3808. private _htmlAudioElement;
  3809. private _urlType;
  3810. /**
  3811. * Create a sound and attach it to a scene
  3812. * @param name Name of your sound
  3813. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  3814. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  3815. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  3816. */
  3817. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  3818. dispose(): void;
  3819. isReady(): boolean;
  3820. private _soundLoaded(audioData);
  3821. setAudioBuffer(audioBuffer: AudioBuffer): void;
  3822. updateOptions(options: any): void;
  3823. private _createSpatialParameters();
  3824. private _updateSpatialParameters();
  3825. switchPanningModelToHRTF(): void;
  3826. switchPanningModelToEqualPower(): void;
  3827. private _switchPanningModel();
  3828. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  3829. /**
  3830. * Transform this sound into a directional source
  3831. * @param coneInnerAngle Size of the inner cone in degree
  3832. * @param coneOuterAngle Size of the outer cone in degree
  3833. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  3834. */
  3835. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  3836. setPosition(newPosition: Vector3): void;
  3837. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  3838. private _updateDirection();
  3839. updateDistanceFromListener(): void;
  3840. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  3841. /**
  3842. * Play the sound
  3843. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  3844. * @param offset (optional) Start the sound setting it at a specific time
  3845. */
  3846. play(time?: number, offset?: number): void;
  3847. private _onended();
  3848. /**
  3849. * Stop the sound
  3850. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  3851. */
  3852. stop(time?: number): void;
  3853. pause(): void;
  3854. setVolume(newVolume: number, time?: number): void;
  3855. setPlaybackRate(newPlaybackRate: number): void;
  3856. getVolume(): number;
  3857. attachToMesh(meshToConnectTo: AbstractMesh): void;
  3858. detachFromMesh(): void;
  3859. private _onRegisterAfterWorldMatrixUpdate(node);
  3860. clone(): Nullable<Sound>;
  3861. getAudioBuffer(): AudioBuffer | null;
  3862. serialize(): any;
  3863. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  3864. }
  3865. }
  3866. declare module BABYLON {
  3867. class SoundTrack {
  3868. private _outputAudioNode;
  3869. private _scene;
  3870. id: number;
  3871. soundCollection: Array<Sound>;
  3872. private _isMainTrack;
  3873. private _connectedAnalyser;
  3874. private _options;
  3875. private _isInitialized;
  3876. constructor(scene: Scene, options?: any);
  3877. private _initializeSoundTrackAudioGraph();
  3878. dispose(): void;
  3879. AddSound(sound: Sound): void;
  3880. RemoveSound(sound: Sound): void;
  3881. setVolume(newVolume: number): void;
  3882. switchPanningModelToHRTF(): void;
  3883. switchPanningModelToEqualPower(): void;
  3884. connectToAnalyser(analyser: Analyser): void;
  3885. }
  3886. }
  3887. declare module BABYLON {
  3888. interface Behavior<T extends Node> {
  3889. name: string;
  3890. init(): void;
  3891. attach(node: T): void;
  3892. detach(): void;
  3893. }
  3894. }
  3895. declare module BABYLON {
  3896. /**
  3897. * Class used to store bone information
  3898. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  3899. */
  3900. class Bone extends Node {
  3901. /**
  3902. * defines the bone name
  3903. */
  3904. name: string;
  3905. private static _tmpVecs;
  3906. private static _tmpQuat;
  3907. private static _tmpMats;
  3908. /**
  3909. * Gets the list of child bones
  3910. */
  3911. children: Bone[];
  3912. /** Gets the animations associated with this bone */
  3913. animations: Animation[];
  3914. /**
  3915. * Gets or sets bone length
  3916. */
  3917. length: number;
  3918. /**
  3919. * @ignore Internal only
  3920. * Set this value to map this bone to a different index in the transform matrices
  3921. * Set this value to -1 to exclude the bone from the transform matrices
  3922. */
  3923. _index: Nullable<number>;
  3924. private _skeleton;
  3925. private _localMatrix;
  3926. private _restPose;
  3927. private _baseMatrix;
  3928. private _absoluteTransform;
  3929. private _invertedAbsoluteTransform;
  3930. private _parent;
  3931. private _scalingDeterminant;
  3932. private _worldTransform;
  3933. private _localScaling;
  3934. private _localRotation;
  3935. private _localPosition;
  3936. private _needToDecompose;
  3937. private _needToCompose;
  3938. /** @ignore */
  3939. /** @ignore */
  3940. _matrix: Matrix;
  3941. /**
  3942. * Create a new bone
  3943. * @param name defines the bone name
  3944. * @param skeleton defines the parent skeleton
  3945. * @param parentBone defines the parent (can be null if the bone is the root)
  3946. * @param localMatrix defines the local matrix
  3947. * @param restPose defines the rest pose matrix
  3948. * @param baseMatrix defines the base matrix
  3949. * @param index defines index of the bone in the hiearchy
  3950. */
  3951. constructor(
  3952. /**
  3953. * defines the bone name
  3954. */
  3955. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  3956. /**
  3957. * Gets the parent skeleton
  3958. * @returns a skeleton
  3959. */
  3960. getSkeleton(): Skeleton;
  3961. /**
  3962. * Gets parent bone
  3963. * @returns a bone or null if the bone is the root of the bone hierarchy
  3964. */
  3965. getParent(): Nullable<Bone>;
  3966. /**
  3967. * Sets the parent bone
  3968. * @param parent defines the parent (can be null if the bone is the root)
  3969. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  3970. */
  3971. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  3972. /**
  3973. * Gets the local matrix
  3974. * @returns a matrix
  3975. */
  3976. getLocalMatrix(): Matrix;
  3977. /**
  3978. * Gets the base matrix (initial matrix which remains unchanged)
  3979. * @returns a matrix
  3980. */
  3981. getBaseMatrix(): Matrix;
  3982. /**
  3983. * Gets the rest pose matrix
  3984. * @returns a matrix
  3985. */
  3986. getRestPose(): Matrix;
  3987. /**
  3988. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  3989. */
  3990. getWorldMatrix(): Matrix;
  3991. /**
  3992. * Sets the local matrix to rest pose matrix
  3993. */
  3994. returnToRest(): void;
  3995. /**
  3996. * Gets the inverse of the absolute transform matrix.
  3997. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  3998. * @returns a matrix
  3999. */
  4000. getInvertedAbsoluteTransform(): Matrix;
  4001. /**
  4002. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  4003. * @returns a matrix
  4004. */
  4005. getAbsoluteTransform(): Matrix;
  4006. /** Gets or sets current position (in local space) */
  4007. position: Vector3;
  4008. /** Gets or sets current rotation (in local space) */
  4009. rotation: Vector3;
  4010. /** Gets or sets current rotation quaternion (in local space) */
  4011. rotationQuaternion: Quaternion;
  4012. /** Gets or sets current scaling (in local space) */
  4013. scaling: Vector3;
  4014. /**
  4015. * Gets the animation properties override
  4016. */
  4017. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  4018. private _decompose();
  4019. private _compose();
  4020. /**
  4021. * Update the local matrix
  4022. * @param matrix defines the new local matrix
  4023. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4024. */
  4025. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean): void;
  4026. /** @ignore */
  4027. _updateDifferenceMatrix(rootMatrix?: Matrix): void;
  4028. /**
  4029. * Flag the bone as dirty (Forcing it to update everything)
  4030. */
  4031. markAsDirty(): void;
  4032. private _markAsDirtyAndCompose();
  4033. private _markAsDirtyAndDecompose();
  4034. /**
  4035. * Copy an animation range from another bone
  4036. * @param source defines the source bone
  4037. * @param rangeName defines the range name to copy
  4038. * @param frameOffset defines the frame offset
  4039. * @param rescaleAsRequired defines if rescaling must be applied if required
  4040. * @param skelDimensionsRatio defines the scaling ratio
  4041. * @returns true if operation was successful
  4042. */
  4043. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  4044. /**
  4045. * Translate the bone in local or world space
  4046. * @param vec The amount to translate the bone
  4047. * @param space The space that the translation is in
  4048. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4049. */
  4050. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4051. /**
  4052. * Set the postion of the bone in local or world space
  4053. * @param position The position to set the bone
  4054. * @param space The space that the position is in
  4055. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4056. */
  4057. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4058. /**
  4059. * Set the absolute position of the bone (world space)
  4060. * @param position The position to set the bone
  4061. * @param mesh The mesh that this bone is attached to
  4062. */
  4063. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  4064. /**
  4065. * Scale the bone on the x, y and z axes (in local space)
  4066. * @param x The amount to scale the bone on the x axis
  4067. * @param y The amount to scale the bone on the y axis
  4068. * @param z The amount to scale the bone on the z axis
  4069. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  4070. */
  4071. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  4072. /**
  4073. * Set the bone scaling in local space
  4074. * @param scale defines the scaling vector
  4075. */
  4076. setScale(scale: Vector3): void;
  4077. /**
  4078. * Gets the current scaling in local space
  4079. * @returns the current scaling vector
  4080. */
  4081. getScale(): Vector3;
  4082. /**
  4083. * Gets the current scaling in local space and stores it in a target vector
  4084. * @param result defines the target vector
  4085. */
  4086. getScaleToRef(result: Vector3): void;
  4087. /**
  4088. * Set the yaw, pitch, and roll of the bone in local or world space
  4089. * @param yaw The rotation of the bone on the y axis
  4090. * @param pitch The rotation of the bone on the x axis
  4091. * @param roll The rotation of the bone on the z axis
  4092. * @param space The space that the axes of rotation are in
  4093. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4094. */
  4095. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  4096. /**
  4097. * Add a rotation to the bone on an axis in local or world space
  4098. * @param axis The axis to rotate the bone on
  4099. * @param amount The amount to rotate the bone
  4100. * @param space The space that the axis is in
  4101. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4102. */
  4103. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  4104. /**
  4105. * Set the rotation of the bone to a particular axis angle in local or world space
  4106. * @param axis The axis to rotate the bone on
  4107. * @param angle The angle that the bone should be rotated to
  4108. * @param space The space that the axis is in
  4109. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4110. */
  4111. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  4112. /**
  4113. * Set the euler rotation of the bone in local of world space
  4114. * @param rotation The euler rotation that the bone should be set to
  4115. * @param space The space that the rotation is in
  4116. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4117. */
  4118. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4119. /**
  4120. * Set the quaternion rotation of the bone in local of world space
  4121. * @param quat The quaternion rotation that the bone should be set to
  4122. * @param space The space that the rotation is in
  4123. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4124. */
  4125. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  4126. /**
  4127. * Set the rotation matrix of the bone in local of world space
  4128. * @param rotMat The rotation matrix that the bone should be set to
  4129. * @param space The space that the rotation is in
  4130. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4131. */
  4132. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  4133. private _rotateWithMatrix(rmat, space?, mesh?);
  4134. private _getNegativeRotationToRef(rotMatInv, mesh?);
  4135. /**
  4136. * Get the position of the bone in local or world space
  4137. * @param space The space that the returned position is in
  4138. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4139. * @returns The position of the bone
  4140. */
  4141. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4142. /**
  4143. * Copy the position of the bone to a vector3 in local or world space
  4144. * @param space The space that the returned position is in
  4145. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4146. * @param result The vector3 to copy the position to
  4147. */
  4148. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  4149. /**
  4150. * Get the absolute position of the bone (world space)
  4151. * @param mesh The mesh that this bone is attached to
  4152. * @returns The absolute position of the bone
  4153. */
  4154. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  4155. /**
  4156. * Copy the absolute position of the bone (world space) to the result param
  4157. * @param mesh The mesh that this bone is attached to
  4158. * @param result The vector3 to copy the absolute position to
  4159. */
  4160. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  4161. /**
  4162. * Compute the absolute transforms of this bone and its children
  4163. */
  4164. computeAbsoluteTransforms(): void;
  4165. /**
  4166. * Get the world direction from an axis that is in the local space of the bone
  4167. * @param localAxis The local direction that is used to compute the world direction
  4168. * @param mesh The mesh that this bone is attached to
  4169. * @returns The world direction
  4170. */
  4171. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4172. /**
  4173. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  4174. * @param localAxis The local direction that is used to compute the world direction
  4175. * @param mesh The mesh that this bone is attached to
  4176. * @param result The vector3 that the world direction will be copied to
  4177. */
  4178. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4179. /**
  4180. * Get the euler rotation of the bone in local or world space
  4181. * @param space The space that the rotation should be in
  4182. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4183. * @returns The euler rotation
  4184. */
  4185. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4186. /**
  4187. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  4188. * @param space The space that the rotation should be in
  4189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4190. * @param result The vector3 that the rotation should be copied to
  4191. */
  4192. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4193. /**
  4194. * Get the quaternion rotation of the bone in either local or world space
  4195. * @param space The space that the rotation should be in
  4196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4197. * @returns The quaternion rotation
  4198. */
  4199. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  4200. /**
  4201. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  4202. * @param space The space that the rotation should be in
  4203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4204. * @param result The quaternion that the rotation should be copied to
  4205. */
  4206. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  4207. /**
  4208. * Get the rotation matrix of the bone in local or world space
  4209. * @param space The space that the rotation should be in
  4210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4211. * @returns The rotation matrix
  4212. */
  4213. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  4214. /**
  4215. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  4216. * @param space The space that the rotation should be in
  4217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4218. * @param result The quaternion that the rotation should be copied to
  4219. */
  4220. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  4221. /**
  4222. * Get the world position of a point that is in the local space of the bone
  4223. * @param position The local position
  4224. * @param mesh The mesh that this bone is attached to
  4225. * @returns The world position
  4226. */
  4227. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4228. /**
  4229. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  4230. * @param position The local position
  4231. * @param mesh The mesh that this bone is attached to
  4232. * @param result The vector3 that the world position should be copied to
  4233. */
  4234. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4235. /**
  4236. * Get the local position of a point that is in world space
  4237. * @param position The world position
  4238. * @param mesh The mesh that this bone is attached to
  4239. * @returns The local position
  4240. */
  4241. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4242. /**
  4243. * Get the local position of a point that is in world space and copy it to the result param
  4244. * @param position The world position
  4245. * @param mesh The mesh that this bone is attached to
  4246. * @param result The vector3 that the local position should be copied to
  4247. */
  4248. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4249. }
  4250. }
  4251. declare module BABYLON {
  4252. /**
  4253. * Class used to apply inverse kinematics to bones
  4254. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  4255. */
  4256. class BoneIKController {
  4257. private static _tmpVecs;
  4258. private static _tmpQuat;
  4259. private static _tmpMats;
  4260. /**
  4261. * Gets or sets the target mesh
  4262. */
  4263. targetMesh: AbstractMesh;
  4264. /** Gets or sets the mesh used as pole */
  4265. poleTargetMesh: AbstractMesh;
  4266. /**
  4267. * Gets or sets the bone used as pole
  4268. */
  4269. poleTargetBone: Nullable<Bone>;
  4270. /**
  4271. * Gets or sets the target position
  4272. */
  4273. targetPosition: Vector3;
  4274. /**
  4275. * Gets or sets the pole target position
  4276. */
  4277. poleTargetPosition: Vector3;
  4278. /**
  4279. * Gets or sets the pole target local offset
  4280. */
  4281. poleTargetLocalOffset: Vector3;
  4282. /**
  4283. * Gets or sets the pole angle
  4284. */
  4285. poleAngle: number;
  4286. /**
  4287. * Gets or sets the mesh associated with the controller
  4288. */
  4289. mesh: AbstractMesh;
  4290. /**
  4291. * 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)
  4292. */
  4293. slerpAmount: number;
  4294. private _bone1Quat;
  4295. private _bone1Mat;
  4296. private _bone2Ang;
  4297. private _bone1;
  4298. private _bone2;
  4299. private _bone1Length;
  4300. private _bone2Length;
  4301. private _maxAngle;
  4302. private _maxReach;
  4303. private _rightHandedSystem;
  4304. private _bendAxis;
  4305. private _slerping;
  4306. private _adjustRoll;
  4307. /**
  4308. * Gets or sets maximum allowed angle
  4309. */
  4310. maxAngle: number;
  4311. /**
  4312. * Creates a new BoneIKController
  4313. * @param mesh defines the mesh to control
  4314. * @param bone defines the bone to control
  4315. * @param options defines options to set up the controller
  4316. */
  4317. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  4318. targetMesh?: AbstractMesh;
  4319. poleTargetMesh?: AbstractMesh;
  4320. poleTargetBone?: Bone;
  4321. poleTargetLocalOffset?: Vector3;
  4322. poleAngle?: number;
  4323. bendAxis?: Vector3;
  4324. maxAngle?: number;
  4325. slerpAmount?: number;
  4326. });
  4327. private _setMaxAngle(ang);
  4328. /**
  4329. * Force the controller to update the bones
  4330. */
  4331. update(): void;
  4332. }
  4333. }
  4334. declare module BABYLON {
  4335. /**
  4336. * Class used to make a bone look toward a point in space
  4337. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  4338. */
  4339. class BoneLookController {
  4340. private static _tmpVecs;
  4341. private static _tmpQuat;
  4342. private static _tmpMats;
  4343. /**
  4344. * The target Vector3 that the bone will look at
  4345. */
  4346. target: Vector3;
  4347. /**
  4348. * The mesh that the bone is attached to
  4349. */
  4350. mesh: AbstractMesh;
  4351. /**
  4352. * The bone that will be looking to the target
  4353. */
  4354. bone: Bone;
  4355. /**
  4356. * The up axis of the coordinate system that is used when the bone is rotated
  4357. */
  4358. upAxis: Vector3;
  4359. /**
  4360. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  4361. */
  4362. upAxisSpace: Space;
  4363. /**
  4364. * Used to make an adjustment to the yaw of the bone
  4365. */
  4366. adjustYaw: number;
  4367. /**
  4368. * Used to make an adjustment to the pitch of the bone
  4369. */
  4370. adjustPitch: number;
  4371. /**
  4372. * Used to make an adjustment to the roll of the bone
  4373. */
  4374. adjustRoll: number;
  4375. /**
  4376. * 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)
  4377. */
  4378. slerpAmount: number;
  4379. private _minYaw;
  4380. private _maxYaw;
  4381. private _minPitch;
  4382. private _maxPitch;
  4383. private _minYawSin;
  4384. private _minYawCos;
  4385. private _maxYawSin;
  4386. private _maxYawCos;
  4387. private _midYawConstraint;
  4388. private _minPitchTan;
  4389. private _maxPitchTan;
  4390. private _boneQuat;
  4391. private _slerping;
  4392. private _transformYawPitch;
  4393. private _transformYawPitchInv;
  4394. private _firstFrameSkipped;
  4395. private _yawRange;
  4396. private _fowardAxis;
  4397. /**
  4398. * Gets or sets the minimum yaw angle that the bone can look to
  4399. */
  4400. minYaw: number;
  4401. /**
  4402. * Gets or sets the maximum yaw angle that the bone can look to
  4403. */
  4404. maxYaw: number;
  4405. /**
  4406. * Gets or sets the minimum pitch angle that the bone can look to
  4407. */
  4408. minPitch: number;
  4409. /**
  4410. * Gets or sets the maximum pitch angle that the bone can look to
  4411. */
  4412. maxPitch: number;
  4413. /**
  4414. * Create a BoneLookController
  4415. * @param mesh the mesh that the bone belongs to
  4416. * @param bone the bone that will be looking to the target
  4417. * @param target the target Vector3 to look at
  4418. * @param settings optional settings:
  4419. * * maxYaw: the maximum angle the bone will yaw to
  4420. * * minYaw: the minimum angle the bone will yaw to
  4421. * * maxPitch: the maximum angle the bone will pitch to
  4422. * * minPitch: the minimum angle the bone will yaw to
  4423. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  4424. * * upAxis: the up axis of the coordinate system
  4425. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  4426. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  4427. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  4428. * * adjustYaw: used to make an adjustment to the yaw of the bone
  4429. * * adjustPitch: used to make an adjustment to the pitch of the bone
  4430. * * adjustRoll: used to make an adjustment to the roll of the bone
  4431. **/
  4432. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  4433. maxYaw?: number;
  4434. minYaw?: number;
  4435. maxPitch?: number;
  4436. minPitch?: number;
  4437. slerpAmount?: number;
  4438. upAxis?: Vector3;
  4439. upAxisSpace?: Space;
  4440. yawAxis?: Vector3;
  4441. pitchAxis?: Vector3;
  4442. adjustYaw?: number;
  4443. adjustPitch?: number;
  4444. adjustRoll?: number;
  4445. });
  4446. /**
  4447. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  4448. */
  4449. update(): void;
  4450. private _getAngleDiff(ang1, ang2);
  4451. private _getAngleBetween(ang1, ang2);
  4452. private _isAngleBetween(ang, ang1, ang2);
  4453. }
  4454. }
  4455. declare module BABYLON {
  4456. /**
  4457. * Class used to handle skinning animations
  4458. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4459. */
  4460. class Skeleton implements IAnimatable {
  4461. /** defines the skeleton name */
  4462. name: string;
  4463. /** defines the skeleton Id */
  4464. id: string;
  4465. /**
  4466. * Gets the list of child bones
  4467. */
  4468. bones: Bone[];
  4469. /**
  4470. * Gets an estimate of the dimension of the skeleton at rest
  4471. */
  4472. dimensionsAtRest: Vector3;
  4473. /**
  4474. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  4475. */
  4476. needInitialSkinMatrix: boolean;
  4477. /**
  4478. * Gets the list of animations attached to this skeleton
  4479. */
  4480. animations: Array<Animation>;
  4481. private _scene;
  4482. private _isDirty;
  4483. private _transformMatrices;
  4484. private _meshesWithPoseMatrix;
  4485. private _animatables;
  4486. private _identity;
  4487. private _synchronizedWithMesh;
  4488. private _ranges;
  4489. private _lastAbsoluteTransformsUpdateId;
  4490. /**
  4491. * Specifies if the skeleton should be serialized
  4492. */
  4493. doNotSerialize: boolean;
  4494. private _animationPropertiesOverride;
  4495. /**
  4496. * Gets or sets the animation properties override
  4497. */
  4498. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  4499. /**
  4500. * An observable triggered before computing the skeleton's matrices
  4501. */
  4502. onBeforeComputeObservable: Observable<Skeleton>;
  4503. /**
  4504. * Creates a new skeleton
  4505. * @param name defines the skeleton name
  4506. * @param id defines the skeleton Id
  4507. * @param scene defines the hosting scene
  4508. */
  4509. constructor(
  4510. /** defines the skeleton name */
  4511. name: string,
  4512. /** defines the skeleton Id */
  4513. id: string, scene: Scene);
  4514. /**
  4515. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  4516. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  4517. * @returns a Float32Array containing matrices data
  4518. */
  4519. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  4520. /**
  4521. * Gets the current hosting scene
  4522. * @returns a scene object
  4523. */
  4524. getScene(): Scene;
  4525. /**
  4526. * Gets a string representing the current skeleton data
  4527. * @param fullDetails defines a boolean indicating if we want a verbose version
  4528. * @returns a string representing the current skeleton data
  4529. */
  4530. toString(fullDetails?: boolean): string;
  4531. /**
  4532. * Get bone's index searching by name
  4533. * @param name defines bone's name to search for
  4534. * @return the indice of the bone. Returns -1 if not found
  4535. */
  4536. getBoneIndexByName(name: string): number;
  4537. /**
  4538. * Creater a new animation range
  4539. * @param name defines the name of the range
  4540. * @param from defines the start key
  4541. * @param to defines the end key
  4542. */
  4543. createAnimationRange(name: string, from: number, to: number): void;
  4544. /**
  4545. * Delete a specific animation range
  4546. * @param name defines the name of the range
  4547. * @param deleteFrames defines if frames must be removed as well
  4548. */
  4549. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  4550. /**
  4551. * Gets a specific animation range
  4552. * @param name defines the name of the range to look for
  4553. * @returns the requested animation range or null if not found
  4554. */
  4555. getAnimationRange(name: string): Nullable<AnimationRange>;
  4556. /**
  4557. * Gets the list of all animation ranges defined on this skeleton
  4558. * @returns an array
  4559. */
  4560. getAnimationRanges(): Nullable<AnimationRange>[];
  4561. /**
  4562. * Copy animation range from a source skeleton.
  4563. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  4564. * @param source defines the source skeleton
  4565. * @param name defines the name of the range to copy
  4566. * @param rescaleAsRequired defines if rescaling must be applied if required
  4567. * @returns true if operation was successful
  4568. */
  4569. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  4570. /**
  4571. * Forces the skeleton to go to rest pose
  4572. */
  4573. returnToRest(): void;
  4574. private _getHighestAnimationFrame();
  4575. /**
  4576. * Begin a specific animation range
  4577. * @param name defines the name of the range to start
  4578. * @param loop defines if looping must be turned on (false by default)
  4579. * @param speedRatio defines the speed ratio to apply (1 by default)
  4580. * @param onAnimationEnd defines a callback which will be called when animation will end
  4581. * @returns a new animatable
  4582. */
  4583. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  4584. /** @ignore */
  4585. _markAsDirty(): void;
  4586. /** @ignore */
  4587. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  4588. /** @ignore */
  4589. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  4590. /** @ignore */
  4591. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  4592. /**
  4593. * Build all resources required to render a skeleton
  4594. */
  4595. prepare(): void;
  4596. /**
  4597. * Gets the list of animatables currently running for this skeleton
  4598. * @returns an array of animatables
  4599. */
  4600. getAnimatables(): IAnimatable[];
  4601. /**
  4602. * Clone the current skeleton
  4603. * @param name defines the name of the new skeleton
  4604. * @param id defines the id of the enw skeleton
  4605. * @returns the new skeleton
  4606. */
  4607. clone(name: string, id: string): Skeleton;
  4608. /**
  4609. * Enable animation blending for this skeleton
  4610. * @param blendingSpeed defines the blending speed to apply
  4611. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  4612. */
  4613. enableBlending(blendingSpeed?: number): void;
  4614. /**
  4615. * Releases all resources associated with the current skeleton
  4616. */
  4617. dispose(): void;
  4618. /**
  4619. * Serialize the skeleton in a JSON object
  4620. * @returns a JSON object
  4621. */
  4622. serialize(): any;
  4623. /**
  4624. * Creates a new skeleton from serialized data
  4625. * @param parsedSkeleton defines the serialized data
  4626. * @param scene defines the hosting scene
  4627. * @returns a new skeleton
  4628. */
  4629. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  4630. /**
  4631. * Compute all node absolute transforms
  4632. * @param forceUpdate defines if computation must be done even if cache is up to date
  4633. */
  4634. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  4635. /**
  4636. * Gets the root pose matrix
  4637. * @returns a matrix
  4638. */
  4639. getPoseMatrix(): Nullable<Matrix>;
  4640. /**
  4641. * Sorts bones per internal index
  4642. */
  4643. sortBones(): void;
  4644. private _sortBones(index, bones, visited);
  4645. }
  4646. }
  4647. declare module BABYLON {
  4648. class ArcRotateCamera extends TargetCamera {
  4649. alpha: number;
  4650. beta: number;
  4651. radius: number;
  4652. protected _target: Vector3;
  4653. protected _targetHost: Nullable<AbstractMesh>;
  4654. target: Vector3;
  4655. inertialAlphaOffset: number;
  4656. inertialBetaOffset: number;
  4657. inertialRadiusOffset: number;
  4658. lowerAlphaLimit: Nullable<number>;
  4659. upperAlphaLimit: Nullable<number>;
  4660. lowerBetaLimit: number;
  4661. upperBetaLimit: number;
  4662. lowerRadiusLimit: Nullable<number>;
  4663. upperRadiusLimit: Nullable<number>;
  4664. inertialPanningX: number;
  4665. inertialPanningY: number;
  4666. pinchToPanMaxDistance: number;
  4667. panningDistanceLimit: Nullable<number>;
  4668. panningOriginTarget: Vector3;
  4669. panningInertia: number;
  4670. angularSensibilityX: number;
  4671. angularSensibilityY: number;
  4672. pinchPrecision: number;
  4673. pinchDeltaPercentage: number;
  4674. panningSensibility: number;
  4675. keysUp: number[];
  4676. keysDown: number[];
  4677. keysLeft: number[];
  4678. keysRight: number[];
  4679. wheelPrecision: number;
  4680. wheelDeltaPercentage: number;
  4681. zoomOnFactor: number;
  4682. targetScreenOffset: Vector2;
  4683. allowUpsideDown: boolean;
  4684. _viewMatrix: Matrix;
  4685. _useCtrlForPanning: boolean;
  4686. _panningMouseButton: number;
  4687. inputs: ArcRotateCameraInputsManager;
  4688. _reset: () => void;
  4689. panningAxis: Vector3;
  4690. protected _localDirection: Vector3;
  4691. protected _transformedDirection: Vector3;
  4692. private _bouncingBehavior;
  4693. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  4694. useBouncingBehavior: boolean;
  4695. private _framingBehavior;
  4696. readonly framingBehavior: Nullable<FramingBehavior>;
  4697. useFramingBehavior: boolean;
  4698. private _autoRotationBehavior;
  4699. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  4700. useAutoRotationBehavior: boolean;
  4701. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  4702. onCollide: (collidedMesh: AbstractMesh) => void;
  4703. checkCollisions: boolean;
  4704. collisionRadius: Vector3;
  4705. protected _collider: Collider;
  4706. protected _previousPosition: Vector3;
  4707. protected _collisionVelocity: Vector3;
  4708. protected _newPosition: Vector3;
  4709. protected _previousAlpha: number;
  4710. protected _previousBeta: number;
  4711. protected _previousRadius: number;
  4712. protected _collisionTriggered: boolean;
  4713. protected _targetBoundingCenter: Nullable<Vector3>;
  4714. private _computationVector;
  4715. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene);
  4716. _initCache(): void;
  4717. _updateCache(ignoreParentClass?: boolean): void;
  4718. protected _getTargetPosition(): Vector3;
  4719. /**
  4720. * Store current camera state (fov, position, etc..)
  4721. */
  4722. private _storedAlpha;
  4723. private _storedBeta;
  4724. private _storedRadius;
  4725. private _storedTarget;
  4726. storeState(): Camera;
  4727. /**
  4728. * Restored camera state. You must call storeState() first
  4729. */
  4730. _restoreStateValues(): boolean;
  4731. _isSynchronizedViewMatrix(): boolean;
  4732. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  4733. detachControl(element: HTMLElement): void;
  4734. _checkInputs(): void;
  4735. protected _checkLimits(): void;
  4736. rebuildAnglesAndRadius(): void;
  4737. setPosition(position: Vector3): void;
  4738. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  4739. _getViewMatrix(): Matrix;
  4740. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  4741. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  4742. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  4743. min: Vector3;
  4744. max: Vector3;
  4745. distance: number;
  4746. }, doNotUpdateMaxZ?: boolean): void;
  4747. /**
  4748. * @override
  4749. * Override Camera.createRigCamera
  4750. */
  4751. createRigCamera(name: string, cameraIndex: number): Camera;
  4752. /**
  4753. * @override
  4754. * Override Camera._updateRigCameras
  4755. */
  4756. _updateRigCameras(): void;
  4757. dispose(): void;
  4758. getClassName(): string;
  4759. }
  4760. }
  4761. declare module BABYLON {
  4762. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  4763. constructor(camera: ArcRotateCamera);
  4764. addMouseWheel(): ArcRotateCameraInputsManager;
  4765. addPointers(): ArcRotateCameraInputsManager;
  4766. addKeyboard(): ArcRotateCameraInputsManager;
  4767. addGamepad(): ArcRotateCameraInputsManager;
  4768. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  4769. }
  4770. }
  4771. declare module BABYLON {
  4772. class Camera extends Node {
  4773. inputs: CameraInputsManager<Camera>;
  4774. private static _PERSPECTIVE_CAMERA;
  4775. private static _ORTHOGRAPHIC_CAMERA;
  4776. private static _FOVMODE_VERTICAL_FIXED;
  4777. private static _FOVMODE_HORIZONTAL_FIXED;
  4778. private static _RIG_MODE_NONE;
  4779. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  4780. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  4781. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  4782. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  4783. private static _RIG_MODE_VR;
  4784. private static _RIG_MODE_WEBVR;
  4785. static readonly PERSPECTIVE_CAMERA: number;
  4786. static readonly ORTHOGRAPHIC_CAMERA: number;
  4787. /**
  4788. * This is the default FOV mode for perspective cameras.
  4789. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  4790. *
  4791. */
  4792. static readonly FOVMODE_VERTICAL_FIXED: number;
  4793. /**
  4794. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  4795. *
  4796. */
  4797. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  4798. static readonly RIG_MODE_NONE: number;
  4799. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  4800. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  4801. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  4802. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  4803. static readonly RIG_MODE_VR: number;
  4804. static readonly RIG_MODE_WEBVR: number;
  4805. static ForceAttachControlToAlwaysPreventDefault: boolean;
  4806. static UseAlternateWebVRRendering: boolean;
  4807. position: Vector3;
  4808. /**
  4809. * The vector the camera should consider as up.
  4810. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  4811. */
  4812. upVector: Vector3;
  4813. orthoLeft: Nullable<number>;
  4814. orthoRight: Nullable<number>;
  4815. orthoBottom: Nullable<number>;
  4816. orthoTop: Nullable<number>;
  4817. /**
  4818. * FOV is set in Radians. (default is 0.8)
  4819. */
  4820. fov: number;
  4821. minZ: number;
  4822. maxZ: number;
  4823. inertia: number;
  4824. mode: number;
  4825. isIntermediate: boolean;
  4826. viewport: Viewport;
  4827. /**
  4828. * Restricts the camera to viewing objects with the same layerMask.
  4829. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  4830. */
  4831. layerMask: number;
  4832. /**
  4833. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  4834. */
  4835. fovMode: number;
  4836. cameraRigMode: number;
  4837. interaxialDistance: number;
  4838. isStereoscopicSideBySide: boolean;
  4839. _cameraRigParams: any;
  4840. _rigCameras: Camera[];
  4841. _rigPostProcess: Nullable<PostProcess>;
  4842. protected _webvrViewMatrix: Matrix;
  4843. _skipRendering: boolean;
  4844. _alternateCamera: Camera;
  4845. customRenderTargets: RenderTargetTexture[];
  4846. onViewMatrixChangedObservable: Observable<Camera>;
  4847. onProjectionMatrixChangedObservable: Observable<Camera>;
  4848. onAfterCheckInputsObservable: Observable<Camera>;
  4849. onRestoreStateObservable: Observable<Camera>;
  4850. private _computedViewMatrix;
  4851. _projectionMatrix: Matrix;
  4852. private _doNotComputeProjectionMatrix;
  4853. private _worldMatrix;
  4854. _postProcesses: Nullable<PostProcess>[];
  4855. private _transformMatrix;
  4856. _activeMeshes: SmartArray<AbstractMesh>;
  4857. private _globalPosition;
  4858. private _frustumPlanes;
  4859. private _refreshFrustumPlanes;
  4860. constructor(name: string, position: Vector3, scene: Scene);
  4861. private _storedFov;
  4862. private _stateStored;
  4863. /**
  4864. * Store current camera state (fov, position, etc..)
  4865. */
  4866. storeState(): Camera;
  4867. /**
  4868. * Restores the camera state values if it has been stored. You must call storeState() first
  4869. */
  4870. protected _restoreStateValues(): boolean;
  4871. /**
  4872. * Restored camera state. You must call storeState() first
  4873. */
  4874. restoreState(): boolean;
  4875. getClassName(): string;
  4876. /**
  4877. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  4878. */
  4879. toString(fullDetails?: boolean): string;
  4880. readonly globalPosition: Vector3;
  4881. getActiveMeshes(): SmartArray<AbstractMesh>;
  4882. isActiveMesh(mesh: Mesh): boolean;
  4883. /**
  4884. * Is this camera ready to be used/rendered
  4885. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  4886. * @return true if the camera is ready
  4887. */
  4888. isReady(completeCheck?: boolean): boolean;
  4889. _initCache(): void;
  4890. _updateCache(ignoreParentClass?: boolean): void;
  4891. _isSynchronized(): boolean;
  4892. _isSynchronizedViewMatrix(): boolean;
  4893. _isSynchronizedProjectionMatrix(): boolean;
  4894. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  4895. detachControl(element: HTMLElement): void;
  4896. update(): void;
  4897. _checkInputs(): void;
  4898. readonly rigCameras: Camera[];
  4899. readonly rigPostProcess: Nullable<PostProcess>;
  4900. /**
  4901. * Internal, gets the first post proces.
  4902. * @returns the first post process to be run on this camera.
  4903. */
  4904. _getFirstPostProcess(): Nullable<PostProcess>;
  4905. private _cascadePostProcessesToRigCams();
  4906. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  4907. detachPostProcess(postProcess: PostProcess): void;
  4908. getWorldMatrix(): Matrix;
  4909. _getViewMatrix(): Matrix;
  4910. getViewMatrix(force?: boolean): Matrix;
  4911. freezeProjectionMatrix(projection?: Matrix): void;
  4912. unfreezeProjectionMatrix(): void;
  4913. getProjectionMatrix(force?: boolean): Matrix;
  4914. getTranformationMatrix(): Matrix;
  4915. private updateFrustumPlanes();
  4916. isInFrustum(target: ICullable): boolean;
  4917. isCompletelyInFrustum(target: ICullable): boolean;
  4918. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  4919. /**
  4920. * Releases resources associated with this node.
  4921. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  4922. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  4923. */
  4924. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  4925. readonly leftCamera: Nullable<FreeCamera>;
  4926. readonly rightCamera: Nullable<FreeCamera>;
  4927. getLeftTarget(): Nullable<Vector3>;
  4928. getRightTarget(): Nullable<Vector3>;
  4929. setCameraRigMode(mode: number, rigParams: any): void;
  4930. private _getVRProjectionMatrix();
  4931. protected _updateCameraRotationMatrix(): void;
  4932. protected _updateWebVRCameraRotationMatrix(): void;
  4933. /**
  4934. * This function MUST be overwritten by the different WebVR cameras available.
  4935. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  4936. */
  4937. protected _getWebVRProjectionMatrix(): Matrix;
  4938. /**
  4939. * This function MUST be overwritten by the different WebVR cameras available.
  4940. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  4941. */
  4942. protected _getWebVRViewMatrix(): Matrix;
  4943. setCameraRigParameter(name: string, value: any): void;
  4944. /**
  4945. * needs to be overridden by children so sub has required properties to be copied
  4946. */
  4947. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  4948. /**
  4949. * May need to be overridden by children
  4950. */
  4951. _updateRigCameras(): void;
  4952. _setupInputs(): void;
  4953. serialize(): any;
  4954. clone(name: string): Camera;
  4955. getDirection(localAxis: Vector3): Vector3;
  4956. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  4957. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  4958. computeWorldMatrix(): Matrix;
  4959. static Parse(parsedCamera: any, scene: Scene): Camera;
  4960. }
  4961. }
  4962. declare module BABYLON {
  4963. var CameraInputTypes: {};
  4964. interface ICameraInput<TCamera extends Camera> {
  4965. camera: Nullable<TCamera>;
  4966. getClassName(): string;
  4967. getSimpleName(): string;
  4968. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  4969. detachControl: (element: Nullable<HTMLElement>) => void;
  4970. checkInputs?: () => void;
  4971. }
  4972. interface CameraInputsMap<TCamera extends Camera> {
  4973. [name: string]: ICameraInput<TCamera>;
  4974. [idx: number]: ICameraInput<TCamera>;
  4975. }
  4976. class CameraInputsManager<TCamera extends Camera> {
  4977. attached: CameraInputsMap<TCamera>;
  4978. attachedElement: Nullable<HTMLElement>;
  4979. noPreventDefault: boolean;
  4980. camera: TCamera;
  4981. checkInputs: () => void;
  4982. constructor(camera: TCamera);
  4983. /**
  4984. * Add an input method to a camera.
  4985. * builtin inputs example: camera.inputs.addGamepad();
  4986. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  4987. * @param input camera input method
  4988. */
  4989. add(input: ICameraInput<TCamera>): void;
  4990. /**
  4991. * Remove a specific input method from a camera
  4992. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  4993. * @param inputToRemove camera input method
  4994. */
  4995. remove(inputToRemove: ICameraInput<TCamera>): void;
  4996. removeByType(inputType: string): void;
  4997. private _addCheckInputs(fn);
  4998. attachInput(input: ICameraInput<TCamera>): void;
  4999. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  5000. detachElement(element: HTMLElement, disconnect?: boolean): void;
  5001. rebuildInputCheck(): void;
  5002. /**
  5003. * Remove all attached input methods from a camera
  5004. */
  5005. clear(): void;
  5006. serialize(serializedCamera: any): void;
  5007. parse(parsedCamera: any): void;
  5008. }
  5009. }
  5010. declare module BABYLON {
  5011. /**
  5012. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  5013. * being tilted forward or back and left or right.
  5014. */
  5015. class DeviceOrientationCamera extends FreeCamera {
  5016. private _initialQuaternion;
  5017. private _quaternionCache;
  5018. /**
  5019. * Creates a new device orientation camera
  5020. * @param name The name of the camera
  5021. * @param position The start position camera
  5022. * @param scene The scene the camera belongs to
  5023. */
  5024. constructor(name: string, position: Vector3, scene: Scene);
  5025. /**
  5026. * Gets the current instance class name ("DeviceOrientationCamera").
  5027. * This helps avoiding instanceof at run time.
  5028. * @returns the class name
  5029. */
  5030. getClassName(): string;
  5031. /**
  5032. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  5033. */
  5034. _checkInputs(): void;
  5035. /**
  5036. * Reset the camera to its default orientation on the specified axis only.
  5037. * @param axis The axis to reset
  5038. */
  5039. resetToCurrentRotation(axis?: Axis): void;
  5040. }
  5041. }
  5042. declare module BABYLON {
  5043. class FollowCamera extends TargetCamera {
  5044. radius: number;
  5045. rotationOffset: number;
  5046. heightOffset: number;
  5047. cameraAcceleration: number;
  5048. maxCameraSpeed: number;
  5049. lockedTarget: Nullable<AbstractMesh>;
  5050. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  5051. private getRadians(degrees);
  5052. private follow(cameraTarget);
  5053. _checkInputs(): void;
  5054. getClassName(): string;
  5055. }
  5056. class ArcFollowCamera extends TargetCamera {
  5057. alpha: number;
  5058. beta: number;
  5059. radius: number;
  5060. target: Nullable<AbstractMesh>;
  5061. private _cartesianCoordinates;
  5062. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  5063. private follow();
  5064. _checkInputs(): void;
  5065. getClassName(): string;
  5066. }
  5067. }
  5068. declare module BABYLON {
  5069. class FreeCamera extends TargetCamera {
  5070. ellipsoid: Vector3;
  5071. ellipsoidOffset: Vector3;
  5072. checkCollisions: boolean;
  5073. applyGravity: boolean;
  5074. inputs: FreeCameraInputsManager;
  5075. /**
  5076. * Gets the input sensibility for a mouse input. (default is 2000.0)
  5077. * Higher values reduce sensitivity.
  5078. */
  5079. /**
  5080. * Sets the input sensibility for a mouse input. (default is 2000.0)
  5081. * Higher values reduce sensitivity.
  5082. */
  5083. angularSensibility: number;
  5084. keysUp: number[];
  5085. keysDown: number[];
  5086. keysLeft: number[];
  5087. keysRight: number[];
  5088. onCollide: (collidedMesh: AbstractMesh) => void;
  5089. private _collider;
  5090. private _needMoveForGravity;
  5091. private _oldPosition;
  5092. private _diffPosition;
  5093. private _newPosition;
  5094. _localDirection: Vector3;
  5095. _transformedDirection: Vector3;
  5096. constructor(name: string, position: Vector3, scene: Scene);
  5097. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5098. detachControl(element: HTMLElement): void;
  5099. private _collisionMask;
  5100. collisionMask: number;
  5101. _collideWithWorld(displacement: Vector3): void;
  5102. private _onCollisionPositionChange;
  5103. _checkInputs(): void;
  5104. _decideIfNeedsToMove(): boolean;
  5105. _updatePosition(): void;
  5106. dispose(): void;
  5107. getClassName(): string;
  5108. }
  5109. }
  5110. declare module BABYLON {
  5111. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  5112. constructor(camera: FreeCamera);
  5113. addKeyboard(): FreeCameraInputsManager;
  5114. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  5115. addGamepad(): FreeCameraInputsManager;
  5116. addDeviceOrientation(): FreeCameraInputsManager;
  5117. addTouch(): FreeCameraInputsManager;
  5118. addVirtualJoystick(): FreeCameraInputsManager;
  5119. }
  5120. }
  5121. declare module BABYLON {
  5122. class GamepadCamera extends UniversalCamera {
  5123. gamepadAngularSensibility: number;
  5124. gamepadMoveSensibility: number;
  5125. constructor(name: string, position: Vector3, scene: Scene);
  5126. getClassName(): string;
  5127. }
  5128. }
  5129. declare module BABYLON {
  5130. class AnaglyphFreeCamera extends FreeCamera {
  5131. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  5132. getClassName(): string;
  5133. }
  5134. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  5135. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  5136. getClassName(): string;
  5137. }
  5138. class AnaglyphGamepadCamera extends GamepadCamera {
  5139. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  5140. getClassName(): string;
  5141. }
  5142. class AnaglyphUniversalCamera extends UniversalCamera {
  5143. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  5144. getClassName(): string;
  5145. }
  5146. class StereoscopicFreeCamera extends FreeCamera {
  5147. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  5148. getClassName(): string;
  5149. }
  5150. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  5151. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  5152. getClassName(): string;
  5153. }
  5154. class StereoscopicGamepadCamera extends GamepadCamera {
  5155. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  5156. getClassName(): string;
  5157. }
  5158. class StereoscopicUniversalCamera extends UniversalCamera {
  5159. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  5160. getClassName(): string;
  5161. }
  5162. }
  5163. declare module BABYLON {
  5164. class TargetCamera extends Camera {
  5165. cameraDirection: Vector3;
  5166. cameraRotation: Vector2;
  5167. rotation: Vector3;
  5168. rotationQuaternion: Quaternion;
  5169. speed: number;
  5170. noRotationConstraint: boolean;
  5171. lockedTarget: any;
  5172. _currentTarget: Vector3;
  5173. _viewMatrix: Matrix;
  5174. _camMatrix: Matrix;
  5175. _cameraTransformMatrix: Matrix;
  5176. _cameraRotationMatrix: Matrix;
  5177. private _rigCamTransformMatrix;
  5178. _referencePoint: Vector3;
  5179. private _currentUpVector;
  5180. _transformedReferencePoint: Vector3;
  5181. _lookAtTemp: Matrix;
  5182. _tempMatrix: Matrix;
  5183. _reset: () => void;
  5184. constructor(name: string, position: Vector3, scene: Scene);
  5185. getFrontPosition(distance: number): Vector3;
  5186. _getLockedTargetPosition(): Nullable<Vector3>;
  5187. /**
  5188. * Store current camera state (fov, position, etc..)
  5189. */
  5190. private _storedPosition;
  5191. private _storedRotation;
  5192. private _storedRotationQuaternion;
  5193. storeState(): Camera;
  5194. /**
  5195. * Restored camera state. You must call storeState() first
  5196. */
  5197. _restoreStateValues(): boolean;
  5198. _initCache(): void;
  5199. _updateCache(ignoreParentClass?: boolean): void;
  5200. _isSynchronizedViewMatrix(): boolean;
  5201. _computeLocalCameraSpeed(): number;
  5202. setTarget(target: Vector3): void;
  5203. /**
  5204. * Return the current target position of the camera. This value is expressed in local space.
  5205. */
  5206. getTarget(): Vector3;
  5207. _decideIfNeedsToMove(): boolean;
  5208. _updatePosition(): void;
  5209. _checkInputs(): void;
  5210. protected _updateCameraRotationMatrix(): void;
  5211. _getViewMatrix(): Matrix;
  5212. /**
  5213. * @override
  5214. * Override Camera.createRigCamera
  5215. */
  5216. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  5217. /**
  5218. * @override
  5219. * Override Camera._updateRigCameras
  5220. */
  5221. _updateRigCameras(): void;
  5222. private _getRigCamPosition(halfSpace, result);
  5223. getClassName(): string;
  5224. }
  5225. }
  5226. declare module BABYLON {
  5227. class TouchCamera extends FreeCamera {
  5228. touchAngularSensibility: number;
  5229. touchMoveSensibility: number;
  5230. constructor(name: string, position: Vector3, scene: Scene);
  5231. getClassName(): string;
  5232. _setupInputs(): void;
  5233. }
  5234. }
  5235. declare module BABYLON {
  5236. class UniversalCamera extends TouchCamera {
  5237. gamepadAngularSensibility: number;
  5238. gamepadMoveSensibility: number;
  5239. constructor(name: string, position: Vector3, scene: Scene);
  5240. getClassName(): string;
  5241. }
  5242. }
  5243. declare module BABYLON {
  5244. class VirtualJoysticksCamera extends FreeCamera {
  5245. constructor(name: string, position: Vector3, scene: Scene);
  5246. getClassName(): string;
  5247. }
  5248. }
  5249. interface VRDisplay extends EventTarget {
  5250. /**
  5251. * Dictionary of capabilities describing the VRDisplay.
  5252. */
  5253. readonly capabilities: VRDisplayCapabilities;
  5254. /**
  5255. * z-depth defining the far plane of the eye view frustum
  5256. * enables mapping of values in the render target depth
  5257. * attachment to scene coordinates. Initially set to 10000.0.
  5258. */
  5259. depthFar: number;
  5260. /**
  5261. * z-depth defining the near plane of the eye view frustum
  5262. * enables mapping of values in the render target depth
  5263. * attachment to scene coordinates. Initially set to 0.01.
  5264. */
  5265. depthNear: number;
  5266. /**
  5267. * An identifier for this distinct VRDisplay. Used as an
  5268. * association point in the Gamepad API.
  5269. */
  5270. readonly displayId: number;
  5271. /**
  5272. * A display name, a user-readable name identifying it.
  5273. */
  5274. readonly displayName: string;
  5275. readonly isConnected: boolean;
  5276. readonly isPresenting: boolean;
  5277. /**
  5278. * If this VRDisplay supports room-scale experiences, the optional
  5279. * stage attribute contains details on the room-scale parameters.
  5280. */
  5281. readonly stageParameters: VRStageParameters | null;
  5282. /**
  5283. * Passing the value returned by `requestAnimationFrame` to
  5284. * `cancelAnimationFrame` will unregister the callback.
  5285. */
  5286. cancelAnimationFrame(handle: number): void;
  5287. /**
  5288. * Stops presenting to the VRDisplay.
  5289. */
  5290. exitPresent(): Promise<void>;
  5291. getEyeParameters(whichEye: string): VREyeParameters;
  5292. /**
  5293. * Populates the passed VRFrameData with the information required to render
  5294. * the current frame.
  5295. */
  5296. getFrameData(frameData: VRFrameData): boolean;
  5297. /**
  5298. * Get the layers currently being presented.
  5299. */
  5300. getLayers(): VRLayer[];
  5301. /**
  5302. * Return a VRPose containing the future predicted pose of the VRDisplay
  5303. * when the current frame will be presented. The value returned will not
  5304. * change until JavaScript has returned control to the browser.
  5305. *
  5306. * The VRPose will contain the position, orientation, velocity,
  5307. * and acceleration of each of these properties.
  5308. */
  5309. getPose(): VRPose;
  5310. /**
  5311. * Return the current instantaneous pose of the VRDisplay, with no
  5312. * prediction applied.
  5313. */
  5314. getImmediatePose(): VRPose;
  5315. /**
  5316. * The callback passed to `requestAnimationFrame` will be called
  5317. * any time a new frame should be rendered. When the VRDisplay is
  5318. * presenting the callback will be called at the native refresh
  5319. * rate of the HMD. When not presenting this function acts
  5320. * identically to how window.requestAnimationFrame acts. Content should
  5321. * make no assumptions of frame rate or vsync behavior as the HMD runs
  5322. * asynchronously from other displays and at differing refresh rates.
  5323. */
  5324. requestAnimationFrame(callback: FrameRequestCallback): number;
  5325. /**
  5326. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  5327. * Repeat calls while already presenting will update the VRLayers being displayed.
  5328. */
  5329. requestPresent(layers: VRLayer[]): Promise<void>;
  5330. /**
  5331. * Reset the pose for this display, treating its current position and
  5332. * orientation as the "origin/zero" values. VRPose.position,
  5333. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  5334. * updated when calling resetPose(). This should be called in only
  5335. * sitting-space experiences.
  5336. */
  5337. resetPose(): void;
  5338. /**
  5339. * The VRLayer provided to the VRDisplay will be captured and presented
  5340. * in the HMD. Calling this function has the same effect on the source
  5341. * canvas as any other operation that uses its source image, and canvases
  5342. * created without preserveDrawingBuffer set to true will be cleared.
  5343. */
  5344. submitFrame(pose?: VRPose): void;
  5345. }
  5346. declare var VRDisplay: {
  5347. prototype: VRDisplay;
  5348. new (): VRDisplay;
  5349. };
  5350. interface VRLayer {
  5351. leftBounds?: number[] | null;
  5352. rightBounds?: number[] | null;
  5353. source?: HTMLCanvasElement | null;
  5354. }
  5355. interface VRDisplayCapabilities {
  5356. readonly canPresent: boolean;
  5357. readonly hasExternalDisplay: boolean;
  5358. readonly hasOrientation: boolean;
  5359. readonly hasPosition: boolean;
  5360. readonly maxLayers: number;
  5361. }
  5362. interface VREyeParameters {
  5363. /** @deprecated */
  5364. readonly fieldOfView: VRFieldOfView;
  5365. readonly offset: Float32Array;
  5366. readonly renderHeight: number;
  5367. readonly renderWidth: number;
  5368. }
  5369. interface VRFieldOfView {
  5370. readonly downDegrees: number;
  5371. readonly leftDegrees: number;
  5372. readonly rightDegrees: number;
  5373. readonly upDegrees: number;
  5374. }
  5375. interface VRFrameData {
  5376. readonly leftProjectionMatrix: Float32Array;
  5377. readonly leftViewMatrix: Float32Array;
  5378. readonly pose: VRPose;
  5379. readonly rightProjectionMatrix: Float32Array;
  5380. readonly rightViewMatrix: Float32Array;
  5381. readonly timestamp: number;
  5382. }
  5383. interface VRPose {
  5384. readonly angularAcceleration: Float32Array | null;
  5385. readonly angularVelocity: Float32Array | null;
  5386. readonly linearAcceleration: Float32Array | null;
  5387. readonly linearVelocity: Float32Array | null;
  5388. readonly orientation: Float32Array | null;
  5389. readonly position: Float32Array | null;
  5390. readonly timestamp: number;
  5391. }
  5392. interface VRStageParameters {
  5393. sittingToStandingTransform?: Float32Array;
  5394. sizeX?: number;
  5395. sizeY?: number;
  5396. }
  5397. interface Navigator {
  5398. getVRDisplays(): Promise<VRDisplay[]>;
  5399. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  5400. }
  5401. interface Window {
  5402. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  5403. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  5404. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  5405. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  5406. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  5407. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  5408. }
  5409. interface Gamepad {
  5410. readonly displayId: number;
  5411. }
  5412. /**
  5413. * Module Debug contains the (visual) components to debug a scene correctly
  5414. */
  5415. declare module BABYLON.Debug {
  5416. /**
  5417. * The Axes viewer will show 3 axes in a specific point in space
  5418. */
  5419. class AxesViewer {
  5420. private _xline;
  5421. private _yline;
  5422. private _zline;
  5423. private _xmesh;
  5424. private _ymesh;
  5425. private _zmesh;
  5426. scene: Nullable<Scene>;
  5427. scaleLines: number;
  5428. constructor(scene: Scene, scaleLines?: number);
  5429. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  5430. dispose(): void;
  5431. }
  5432. }
  5433. declare module BABYLON.Debug {
  5434. /**
  5435. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  5436. */
  5437. class BoneAxesViewer extends AxesViewer {
  5438. mesh: Nullable<Mesh>;
  5439. bone: Nullable<Bone>;
  5440. pos: Vector3;
  5441. xaxis: Vector3;
  5442. yaxis: Vector3;
  5443. zaxis: Vector3;
  5444. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  5445. update(): void;
  5446. dispose(): void;
  5447. }
  5448. }
  5449. declare module BABYLON {
  5450. class DebugLayer {
  5451. private _scene;
  5452. static InspectorURL: string;
  5453. private _inspector;
  5454. private BJSINSPECTOR;
  5455. constructor(scene: Scene);
  5456. /** Creates the inspector window. */
  5457. private _createInspector(config?);
  5458. isVisible(): boolean;
  5459. hide(): void;
  5460. show(config?: {
  5461. popup?: boolean;
  5462. initialTab?: number;
  5463. parentElement?: HTMLElement;
  5464. newColors?: {
  5465. backgroundColor?: string;
  5466. backgroundColorLighter?: string;
  5467. backgroundColorLighter2?: string;
  5468. backgroundColorLighter3?: string;
  5469. color?: string;
  5470. colorTop?: string;
  5471. colorBot?: string;
  5472. };
  5473. }): void;
  5474. }
  5475. }
  5476. declare module BABYLON.Debug {
  5477. /**
  5478. * Used to show the physics impostor around the specific mesh.
  5479. */
  5480. class PhysicsViewer {
  5481. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  5482. protected _meshes: Array<Nullable<AbstractMesh>>;
  5483. protected _scene: Nullable<Scene>;
  5484. protected _numMeshes: number;
  5485. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  5486. private _renderFunction;
  5487. private _debugBoxMesh;
  5488. private _debugSphereMesh;
  5489. private _debugMaterial;
  5490. constructor(scene: Scene);
  5491. protected _updateDebugMeshes(): void;
  5492. showImpostor(impostor: PhysicsImpostor): void;
  5493. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  5494. private _getDebugMaterial(scene);
  5495. private _getDebugBoxMesh(scene);
  5496. private _getDebugSphereMesh(scene);
  5497. private _getDebugMesh(impostor, scene);
  5498. dispose(): void;
  5499. }
  5500. }
  5501. declare module BABYLON {
  5502. class RayHelper {
  5503. ray: Nullable<Ray>;
  5504. private _renderPoints;
  5505. private _renderLine;
  5506. private _renderFunction;
  5507. private _scene;
  5508. private _updateToMeshFunction;
  5509. private _attachedToMesh;
  5510. private _meshSpaceDirection;
  5511. private _meshSpaceOrigin;
  5512. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  5513. constructor(ray: Ray);
  5514. show(scene: Scene, color: Color3): void;
  5515. hide(): void;
  5516. private _render();
  5517. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  5518. detachFromMesh(): void;
  5519. private _updateToMesh();
  5520. dispose(): void;
  5521. }
  5522. }
  5523. declare module BABYLON.Debug {
  5524. /**
  5525. * Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8
  5526. */
  5527. class SkeletonViewer {
  5528. skeleton: Skeleton;
  5529. mesh: AbstractMesh;
  5530. autoUpdateBonesMatrices: boolean;
  5531. renderingGroupId: number;
  5532. color: Color3;
  5533. private _scene;
  5534. private _debugLines;
  5535. private _debugMesh;
  5536. private _isEnabled;
  5537. private _renderFunction;
  5538. constructor(skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number);
  5539. isEnabled: boolean;
  5540. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  5541. private _getLinesForBonesWithLength(bones, meshMat);
  5542. private _getLinesForBonesNoLength(bones, meshMat);
  5543. update(): void;
  5544. dispose(): void;
  5545. }
  5546. }
  5547. declare module BABYLON {
  5548. class Collider {
  5549. /** Define if a collision was found */
  5550. collisionFound: boolean;
  5551. /**
  5552. * Define last intersection point in local space
  5553. */
  5554. intersectionPoint: Vector3;
  5555. /**
  5556. * Define last collided mesh
  5557. */
  5558. collidedMesh: Nullable<AbstractMesh>;
  5559. private _collisionPoint;
  5560. private _planeIntersectionPoint;
  5561. private _tempVector;
  5562. private _tempVector2;
  5563. private _tempVector3;
  5564. private _tempVector4;
  5565. private _edge;
  5566. private _baseToVertex;
  5567. private _destinationPoint;
  5568. private _slidePlaneNormal;
  5569. private _displacementVector;
  5570. _radius: Vector3;
  5571. _retry: number;
  5572. private _velocity;
  5573. private _basePoint;
  5574. private _epsilon;
  5575. _velocityWorldLength: number;
  5576. _basePointWorld: Vector3;
  5577. private _velocityWorld;
  5578. private _normalizedVelocity;
  5579. _initialVelocity: Vector3;
  5580. _initialPosition: Vector3;
  5581. private _nearestDistance;
  5582. private _collisionMask;
  5583. collisionMask: number;
  5584. /**
  5585. * Gets the plane normal used to compute the sliding response (in local space)
  5586. */
  5587. readonly slidePlaneNormal: Vector3;
  5588. _initialize(source: Vector3, dir: Vector3, e: number): void;
  5589. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  5590. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  5591. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  5592. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  5593. _getResponse(pos: Vector3, vel: Vector3): void;
  5594. }
  5595. }
  5596. declare module BABYLON {
  5597. var CollisionWorker: string;
  5598. interface ICollisionCoordinator {
  5599. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5600. init(scene: Scene): void;
  5601. destroy(): void;
  5602. onMeshAdded(mesh: AbstractMesh): void;
  5603. onMeshUpdated(mesh: AbstractMesh): void;
  5604. onMeshRemoved(mesh: AbstractMesh): void;
  5605. onGeometryAdded(geometry: Geometry): void;
  5606. onGeometryUpdated(geometry: Geometry): void;
  5607. onGeometryDeleted(geometry: Geometry): void;
  5608. }
  5609. interface SerializedMesh {
  5610. id: string;
  5611. name: string;
  5612. uniqueId: number;
  5613. geometryId: Nullable<string>;
  5614. sphereCenter: Array<number>;
  5615. sphereRadius: number;
  5616. boxMinimum: Array<number>;
  5617. boxMaximum: Array<number>;
  5618. worldMatrixFromCache: any;
  5619. subMeshes: Array<SerializedSubMesh>;
  5620. checkCollisions: boolean;
  5621. }
  5622. interface SerializedSubMesh {
  5623. position: number;
  5624. verticesStart: number;
  5625. verticesCount: number;
  5626. indexStart: number;
  5627. indexCount: number;
  5628. hasMaterial: boolean;
  5629. sphereCenter: Array<number>;
  5630. sphereRadius: number;
  5631. boxMinimum: Array<number>;
  5632. boxMaximum: Array<number>;
  5633. }
  5634. /**
  5635. * Interface describing the value associated with a geometry
  5636. */
  5637. interface SerializedGeometry {
  5638. /**
  5639. * Defines the unique ID of the geometry
  5640. */
  5641. id: string;
  5642. /**
  5643. * Defines the array containing the positions
  5644. */
  5645. positions: Float32Array;
  5646. /**
  5647. * Defines the array containing the indices
  5648. */
  5649. indices: Uint32Array;
  5650. /**
  5651. * Defines the array containing the normals
  5652. */
  5653. normals: Float32Array;
  5654. }
  5655. interface BabylonMessage {
  5656. taskType: WorkerTaskType;
  5657. payload: InitPayload | CollidePayload | UpdatePayload;
  5658. }
  5659. interface SerializedColliderToWorker {
  5660. position: Array<number>;
  5661. velocity: Array<number>;
  5662. radius: Array<number>;
  5663. }
  5664. enum WorkerTaskType {
  5665. INIT = 0,
  5666. UPDATE = 1,
  5667. COLLIDE = 2,
  5668. }
  5669. interface WorkerReply {
  5670. error: WorkerReplyType;
  5671. taskType: WorkerTaskType;
  5672. payload?: any;
  5673. }
  5674. interface CollisionReplyPayload {
  5675. newPosition: Array<number>;
  5676. collisionId: number;
  5677. collidedMeshUniqueId: number;
  5678. }
  5679. interface InitPayload {
  5680. }
  5681. interface CollidePayload {
  5682. collisionId: number;
  5683. collider: SerializedColliderToWorker;
  5684. maximumRetry: number;
  5685. excludedMeshUniqueId: Nullable<number>;
  5686. }
  5687. interface UpdatePayload {
  5688. updatedMeshes: {
  5689. [n: number]: SerializedMesh;
  5690. };
  5691. updatedGeometries: {
  5692. [s: string]: SerializedGeometry;
  5693. };
  5694. removedMeshes: Array<number>;
  5695. removedGeometries: Array<string>;
  5696. }
  5697. enum WorkerReplyType {
  5698. SUCCESS = 0,
  5699. UNKNOWN_ERROR = 1,
  5700. }
  5701. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  5702. private _scene;
  5703. private _scaledPosition;
  5704. private _scaledVelocity;
  5705. private _collisionsCallbackArray;
  5706. private _init;
  5707. private _runningUpdated;
  5708. private _worker;
  5709. private _addUpdateMeshesList;
  5710. private _addUpdateGeometriesList;
  5711. private _toRemoveMeshesArray;
  5712. private _toRemoveGeometryArray;
  5713. constructor();
  5714. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  5715. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  5716. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: 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: (transformNode: TransformNode) => void;
  5721. onMeshRemoved(mesh: AbstractMesh): void;
  5722. onGeometryAdded(geometry: Geometry): void;
  5723. onGeometryUpdated: (geometry: Geometry) => void;
  5724. onGeometryDeleted(geometry: Geometry): void;
  5725. private _afterRender;
  5726. private _onMessageFromWorker;
  5727. }
  5728. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  5729. private _scene;
  5730. private _scaledPosition;
  5731. private _scaledVelocity;
  5732. private _finalPosition;
  5733. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5734. init(scene: Scene): void;
  5735. destroy(): void;
  5736. onMeshAdded(mesh: AbstractMesh): void;
  5737. onMeshUpdated(mesh: AbstractMesh): void;
  5738. onMeshRemoved(mesh: AbstractMesh): void;
  5739. onGeometryAdded(geometry: Geometry): void;
  5740. onGeometryUpdated(geometry: Geometry): void;
  5741. onGeometryDeleted(geometry: Geometry): void;
  5742. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  5743. }
  5744. }
  5745. declare function importScripts(...urls: string[]): void;
  5746. declare const safePostMessage: any;
  5747. declare module BABYLON {
  5748. var WorkerIncluded: boolean;
  5749. class CollisionCache {
  5750. private _meshes;
  5751. private _geometries;
  5752. getMeshes(): {
  5753. [n: number]: SerializedMesh;
  5754. };
  5755. getGeometries(): {
  5756. [s: number]: SerializedGeometry;
  5757. };
  5758. getMesh(id: any): SerializedMesh;
  5759. addMesh(mesh: SerializedMesh): void;
  5760. removeMesh(uniqueId: number): void;
  5761. getGeometry(id: string): SerializedGeometry;
  5762. addGeometry(geometry: SerializedGeometry): void;
  5763. removeGeometry(id: string): void;
  5764. }
  5765. class CollideWorker {
  5766. collider: Collider;
  5767. private _collisionCache;
  5768. private finalPosition;
  5769. private collisionsScalingMatrix;
  5770. private collisionTranformationMatrix;
  5771. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  5772. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  5773. private checkCollision(mesh);
  5774. private processCollisionsForSubMeshes(transformMatrix, mesh);
  5775. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  5776. private checkSubmeshCollision(subMesh);
  5777. }
  5778. interface ICollisionDetector {
  5779. onInit(payload: InitPayload): void;
  5780. onUpdate(payload: UpdatePayload): void;
  5781. onCollision(payload: CollidePayload): void;
  5782. }
  5783. class CollisionDetectorTransferable implements ICollisionDetector {
  5784. private _collisionCache;
  5785. onInit(payload: InitPayload): void;
  5786. onUpdate(payload: UpdatePayload): void;
  5787. onCollision(payload: CollidePayload): void;
  5788. }
  5789. }
  5790. declare module BABYLON {
  5791. class IntersectionInfo {
  5792. bu: Nullable<number>;
  5793. bv: Nullable<number>;
  5794. distance: number;
  5795. faceId: number;
  5796. subMeshId: number;
  5797. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  5798. }
  5799. class PickingInfo {
  5800. hit: boolean;
  5801. distance: number;
  5802. pickedPoint: Nullable<Vector3>;
  5803. pickedMesh: Nullable<AbstractMesh>;
  5804. bu: number;
  5805. bv: number;
  5806. faceId: number;
  5807. subMeshId: number;
  5808. pickedSprite: Nullable<Sprite>;
  5809. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  5810. getTextureCoordinates(): Nullable<Vector2>;
  5811. }
  5812. }
  5813. declare module BABYLON {
  5814. class BoundingBox implements ICullable {
  5815. vectors: Vector3[];
  5816. center: Vector3;
  5817. centerWorld: Vector3;
  5818. extendSize: Vector3;
  5819. extendSizeWorld: Vector3;
  5820. directions: Vector3[];
  5821. vectorsWorld: Vector3[];
  5822. minimumWorld: Vector3;
  5823. maximumWorld: Vector3;
  5824. minimum: Vector3;
  5825. maximum: Vector3;
  5826. private _worldMatrix;
  5827. /**
  5828. * Creates a new bounding box
  5829. * @param min defines the minimum vector (in local space)
  5830. * @param max defines the maximum vector (in local space)
  5831. */
  5832. constructor(min: Vector3, max: Vector3);
  5833. /**
  5834. * Recreates the entire bounding box from scratch
  5835. * @param min defines the new minimum vector (in local space)
  5836. * @param max defines the new maximum vector (in local space)
  5837. */
  5838. reConstruct(min: Vector3, max: Vector3): void;
  5839. getWorldMatrix(): Matrix;
  5840. setWorldMatrix(matrix: Matrix): BoundingBox;
  5841. _update(world: Matrix): void;
  5842. isInFrustum(frustumPlanes: Plane[]): boolean;
  5843. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5844. intersectsPoint(point: Vector3): boolean;
  5845. intersectsSphere(sphere: BoundingSphere): boolean;
  5846. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  5847. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  5848. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  5849. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5850. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5851. }
  5852. }
  5853. declare module BABYLON {
  5854. interface ICullable {
  5855. isInFrustum(frustumPlanes: Plane[]): boolean;
  5856. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5857. }
  5858. class BoundingInfo implements ICullable {
  5859. minimum: Vector3;
  5860. maximum: Vector3;
  5861. boundingBox: BoundingBox;
  5862. boundingSphere: BoundingSphere;
  5863. private _isLocked;
  5864. constructor(minimum: Vector3, maximum: Vector3);
  5865. isLocked: boolean;
  5866. update(world: Matrix): void;
  5867. /**
  5868. * Recreate the bounding info to be centered around a specific point given a specific extend.
  5869. * @param center New center of the bounding info
  5870. * @param extend New extend of the bounding info
  5871. */
  5872. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  5873. isInFrustum(frustumPlanes: Plane[]): boolean;
  5874. /**
  5875. * Gets the world distance between the min and max points of the bounding box
  5876. */
  5877. readonly diagonalLength: number;
  5878. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5879. _checkCollision(collider: Collider): boolean;
  5880. intersectsPoint(point: Vector3): boolean;
  5881. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  5882. }
  5883. }
  5884. declare module BABYLON {
  5885. class BoundingSphere {
  5886. center: Vector3;
  5887. radius: number;
  5888. centerWorld: Vector3;
  5889. radiusWorld: number;
  5890. minimum: Vector3;
  5891. maximum: Vector3;
  5892. private _tempRadiusVector;
  5893. /**
  5894. * Creates a new bounding sphere
  5895. * @param min defines the minimum vector (in local space)
  5896. * @param max defines the maximum vector (in local space)
  5897. */
  5898. constructor(min: Vector3, max: Vector3);
  5899. /**
  5900. * Recreates the entire bounding sphere from scratch
  5901. * @param min defines the new minimum vector (in local space)
  5902. * @param max defines the new maximum vector (in local space)
  5903. */
  5904. reConstruct(min: Vector3, max: Vector3): void;
  5905. _update(world: Matrix): void;
  5906. isInFrustum(frustumPlanes: Plane[]): boolean;
  5907. intersectsPoint(point: Vector3): boolean;
  5908. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  5909. }
  5910. }
  5911. declare module BABYLON {
  5912. class Ray {
  5913. origin: Vector3;
  5914. direction: Vector3;
  5915. length: number;
  5916. private _edge1;
  5917. private _edge2;
  5918. private _pvec;
  5919. private _tvec;
  5920. private _qvec;
  5921. private _tmpRay;
  5922. constructor(origin: Vector3, direction: Vector3, length?: number);
  5923. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  5924. intersectsBox(box: BoundingBox): boolean;
  5925. intersectsSphere(sphere: BoundingSphere): boolean;
  5926. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  5927. intersectsPlane(plane: Plane): Nullable<number>;
  5928. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  5929. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  5930. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  5931. private static smallnum;
  5932. private static rayl;
  5933. /**
  5934. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  5935. * @param sega the first point of the segment to test the intersection against
  5936. * @param segb the second point of the segment to test the intersection against
  5937. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  5938. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  5939. */
  5940. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  5941. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5942. static Zero(): Ray;
  5943. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5944. /**
  5945. * 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
  5946. * transformed to the given world matrix.
  5947. * @param origin The origin point
  5948. * @param end The end point
  5949. * @param world a matrix to transform the ray to. Default is the identity matrix.
  5950. */
  5951. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  5952. static Transform(ray: Ray, matrix: Matrix): Ray;
  5953. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  5954. }
  5955. }
  5956. declare module BABYLON {
  5957. /**
  5958. * Interface for attribute information associated with buffer instanciation
  5959. */
  5960. class InstancingAttributeInfo {
  5961. /**
  5962. * Index/offset of the attribute in the vertex shader
  5963. */
  5964. index: number;
  5965. /**
  5966. * size of the attribute, 1, 2, 3 or 4
  5967. */
  5968. attributeSize: number;
  5969. /**
  5970. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  5971. * default is FLOAT
  5972. */
  5973. attribyteType: number;
  5974. /**
  5975. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  5976. */
  5977. normalized: boolean;
  5978. /**
  5979. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  5980. */
  5981. offset: number;
  5982. /**
  5983. * Name of the GLSL attribute, for debugging purpose only
  5984. */
  5985. attributeName: string;
  5986. }
  5987. /**
  5988. * Define options used to create a render target texture
  5989. */
  5990. class RenderTargetCreationOptions {
  5991. /**
  5992. * Specifies is mipmaps must be generated
  5993. */
  5994. generateMipMaps?: boolean;
  5995. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5996. generateDepthBuffer?: boolean;
  5997. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5998. generateStencilBuffer?: boolean;
  5999. /** Defines texture type (int by default) */
  6000. type?: number;
  6001. /** Defines sampling mode (trilinear by default) */
  6002. samplingMode?: number;
  6003. /** Defines format (RGBA by default) */
  6004. format?: number;
  6005. }
  6006. /**
  6007. * Define options used to create a depth texture
  6008. */
  6009. class DepthTextureCreationOptions {
  6010. /** Specifies whether or not a stencil should be allocated in the texture */
  6011. generateStencil?: boolean;
  6012. /** Specifies whether or not bilinear filtering is enable on the texture */
  6013. bilinearFiltering?: boolean;
  6014. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  6015. comparisonFunction?: number;
  6016. /** Specifies if the created texture is a cube texture */
  6017. isCube?: boolean;
  6018. }
  6019. /**
  6020. * Class used to describe the capabilities of the engine relatively to the current browser
  6021. */
  6022. class EngineCapabilities {
  6023. /** Maximum textures units per fragment shader */
  6024. maxTexturesImageUnits: number;
  6025. /** Maximum texture units per vertex shader */
  6026. maxVertexTextureImageUnits: number;
  6027. /** Maximum textures units in the entire pipeline */
  6028. maxCombinedTexturesImageUnits: number;
  6029. /** Maximum texture size */
  6030. maxTextureSize: number;
  6031. /** Maximum cube texture size */
  6032. maxCubemapTextureSize: number;
  6033. /** Maximum render texture size */
  6034. maxRenderTextureSize: number;
  6035. /** Maximum number of vertex attributes */
  6036. maxVertexAttribs: number;
  6037. /** Maximum number of varyings */
  6038. maxVaryingVectors: number;
  6039. /** Maximum number of uniforms per vertex shader */
  6040. maxVertexUniformVectors: number;
  6041. /** Maximum number of uniforms per fragment shader */
  6042. maxFragmentUniformVectors: number;
  6043. /** Defines if standard derivates (dx/dy) are supported */
  6044. standardDerivatives: boolean;
  6045. /** Defines if s3tc texture compression is supported */
  6046. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  6047. /** Defines if pvrtc texture compression is supported */
  6048. pvrtc: any;
  6049. /** Defines if etc1 texture compression is supported */
  6050. etc1: any;
  6051. /** Defines if etc2 texture compression is supported */
  6052. etc2: any;
  6053. /** Defines if astc texture compression is supported */
  6054. astc: any;
  6055. /** Defines if float textures are supported */
  6056. textureFloat: boolean;
  6057. /** Defines if vertex array objects are supported */
  6058. vertexArrayObject: boolean;
  6059. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  6060. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  6061. /** Gets the maximum level of anisotropy supported */
  6062. maxAnisotropy: number;
  6063. /** Defines if instancing is supported */
  6064. instancedArrays: boolean;
  6065. /** Defines if 32 bits indices are supported */
  6066. uintIndices: boolean;
  6067. /** Defines if high precision shaders are supported */
  6068. highPrecisionShaderSupported: boolean;
  6069. /** Defines if depth reading in the fragment shader is supported */
  6070. fragmentDepthSupported: boolean;
  6071. /** Defines if float texture linear filtering is supported*/
  6072. textureFloatLinearFiltering: boolean;
  6073. /** Defines if rendering to float textures is supported */
  6074. textureFloatRender: boolean;
  6075. /** Defines if half float textures are supported*/
  6076. textureHalfFloat: boolean;
  6077. /** Defines if half float texture linear filtering is supported*/
  6078. textureHalfFloatLinearFiltering: boolean;
  6079. /** Defines if rendering to half float textures is supported */
  6080. textureHalfFloatRender: boolean;
  6081. /** Defines if textureLOD shader command is supported */
  6082. textureLOD: boolean;
  6083. /** Defines if draw buffers extension is supported */
  6084. drawBuffersExtension: boolean;
  6085. /** Defines if depth textures are supported */
  6086. depthTextureExtension: boolean;
  6087. /** Defines if float color buffer are supported */
  6088. colorBufferFloat: boolean;
  6089. /** Gets disjoint timer query extension (null if not supported) */
  6090. timerQuery: EXT_disjoint_timer_query;
  6091. /** Defines if timestamp can be used with timer query */
  6092. canUseTimestampForTimerQuery: boolean;
  6093. }
  6094. /** Interface defining initialization parameters for Engine class */
  6095. interface EngineOptions extends WebGLContextAttributes {
  6096. /**
  6097. * Defines if the engine should no exceed a specified device ratio
  6098. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  6099. */
  6100. limitDeviceRatio?: number;
  6101. /**
  6102. * Defines if webvr should be enabled automatically
  6103. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6104. */
  6105. autoEnableWebVR?: boolean;
  6106. /**
  6107. * Defines if webgl2 should be turned off even if supported
  6108. * @see http://doc.babylonjs.com/features/webgl2
  6109. */
  6110. disableWebGL2Support?: boolean;
  6111. /**
  6112. * Defines if webaudio should be initialized as well
  6113. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6114. */
  6115. audioEngine?: boolean;
  6116. /**
  6117. * Defines if animations should run using a deterministic lock step
  6118. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6119. */
  6120. deterministicLockstep?: boolean;
  6121. /** Defines the maximum steps to use with deterministic lock step mode */
  6122. lockstepMaxSteps?: number;
  6123. /**
  6124. * Defines that engine should ignore context lost events
  6125. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  6126. */
  6127. doNotHandleContextLost?: boolean;
  6128. }
  6129. /**
  6130. * Defines the interface used by display changed events
  6131. */
  6132. interface IDisplayChangedEventArgs {
  6133. /** Gets the vrDisplay object (if any) */
  6134. vrDisplay: Nullable<any>;
  6135. /** Gets a boolean indicating if webVR is supported */
  6136. vrSupported: boolean;
  6137. }
  6138. /**
  6139. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  6140. */
  6141. class Engine {
  6142. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  6143. static ExceptionList: ({
  6144. key: string;
  6145. capture: string;
  6146. captureConstraint: number;
  6147. targets: string[];
  6148. } | {
  6149. key: string;
  6150. capture: null;
  6151. captureConstraint: null;
  6152. targets: string[];
  6153. })[];
  6154. /** Gets the list of created engines */
  6155. static Instances: Engine[];
  6156. /**
  6157. * Gets the latest created engine
  6158. */
  6159. static readonly LastCreatedEngine: Nullable<Engine>;
  6160. /**
  6161. * Gets the latest created scene
  6162. */
  6163. static readonly LastCreatedScene: Nullable<Scene>;
  6164. /**
  6165. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  6166. * @param flag defines which part of the materials must be marked as dirty
  6167. * @param predicate defines a predicate used to filter which materials should be affected
  6168. */
  6169. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  6170. private static _ALPHA_DISABLE;
  6171. private static _ALPHA_ADD;
  6172. private static _ALPHA_COMBINE;
  6173. private static _ALPHA_SUBTRACT;
  6174. private static _ALPHA_MULTIPLY;
  6175. private static _ALPHA_MAXIMIZED;
  6176. private static _ALPHA_ONEONE;
  6177. private static _ALPHA_PREMULTIPLIED;
  6178. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  6179. private static _ALPHA_INTERPOLATE;
  6180. private static _ALPHA_SCREENMODE;
  6181. private static _DELAYLOADSTATE_NONE;
  6182. private static _DELAYLOADSTATE_LOADED;
  6183. private static _DELAYLOADSTATE_LOADING;
  6184. private static _DELAYLOADSTATE_NOTLOADED;
  6185. private static _TEXTUREFORMAT_ALPHA;
  6186. private static _TEXTUREFORMAT_LUMINANCE;
  6187. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  6188. private static _TEXTUREFORMAT_RGB;
  6189. private static _TEXTUREFORMAT_RGBA;
  6190. private static _TEXTUREFORMAT_R32F;
  6191. private static _TEXTUREFORMAT_RG32F;
  6192. private static _TEXTUREFORMAT_RGB32F;
  6193. private static _TEXTUREFORMAT_RGBA32F;
  6194. private static _TEXTURETYPE_UNSIGNED_INT;
  6195. private static _TEXTURETYPE_FLOAT;
  6196. private static _TEXTURETYPE_HALF_FLOAT;
  6197. private static _NEVER;
  6198. private static _ALWAYS;
  6199. private static _LESS;
  6200. private static _EQUAL;
  6201. private static _LEQUAL;
  6202. private static _GREATER;
  6203. private static _GEQUAL;
  6204. private static _NOTEQUAL;
  6205. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  6206. static readonly NEVER: number;
  6207. /** 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 */
  6208. static readonly ALWAYS: number;
  6209. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  6210. static readonly LESS: number;
  6211. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  6212. static readonly EQUAL: number;
  6213. /** 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 */
  6214. static readonly LEQUAL: number;
  6215. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  6216. static readonly GREATER: number;
  6217. /** 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 */
  6218. static readonly GEQUAL: number;
  6219. /** 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 */
  6220. static readonly NOTEQUAL: number;
  6221. private static _KEEP;
  6222. private static _REPLACE;
  6223. private static _INCR;
  6224. private static _DECR;
  6225. private static _INVERT;
  6226. private static _INCR_WRAP;
  6227. private static _DECR_WRAP;
  6228. /** Passed to stencilOperation to specify that stencil value must be kept */
  6229. static readonly KEEP: number;
  6230. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6231. static readonly REPLACE: number;
  6232. /** Passed to stencilOperation to specify that stencil value must be incremented */
  6233. static readonly INCR: number;
  6234. /** Passed to stencilOperation to specify that stencil value must be decremented */
  6235. static readonly DECR: number;
  6236. /** Passed to stencilOperation to specify that stencil value must be inverted */
  6237. static readonly INVERT: number;
  6238. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  6239. static readonly INCR_WRAP: number;
  6240. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  6241. static readonly DECR_WRAP: number;
  6242. /** Defines that alpha blending is disabled */
  6243. static readonly ALPHA_DISABLE: number;
  6244. /** Defines that alpha blending to SRC + DEST */
  6245. static readonly ALPHA_ONEONE: number;
  6246. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  6247. static readonly ALPHA_ADD: number;
  6248. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  6249. static readonly ALPHA_COMBINE: number;
  6250. /** Defines that alpha blending to DEST - SRC * DEST */
  6251. static readonly ALPHA_SUBTRACT: number;
  6252. /** Defines that alpha blending to SRC * DEST */
  6253. static readonly ALPHA_MULTIPLY: number;
  6254. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  6255. static readonly ALPHA_MAXIMIZED: number;
  6256. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  6257. static readonly ALPHA_PREMULTIPLIED: number;
  6258. /**
  6259. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  6260. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  6261. */
  6262. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  6263. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  6264. static readonly ALPHA_INTERPOLATE: number;
  6265. /**
  6266. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  6267. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  6268. */
  6269. static readonly ALPHA_SCREENMODE: number;
  6270. /** Defines that the ressource is not delayed*/
  6271. static readonly DELAYLOADSTATE_NONE: number;
  6272. /** Defines that the ressource was successfully delay loaded */
  6273. static readonly DELAYLOADSTATE_LOADED: number;
  6274. /** Defines that the ressource is currently delay loading */
  6275. static readonly DELAYLOADSTATE_LOADING: number;
  6276. /** Defines that the ressource is delayed and has not started loading */
  6277. static readonly DELAYLOADSTATE_NOTLOADED: number;
  6278. /** ALPHA */
  6279. static readonly TEXTUREFORMAT_ALPHA: number;
  6280. /** LUMINANCE */
  6281. static readonly TEXTUREFORMAT_LUMINANCE: number;
  6282. /**
  6283. * R32F
  6284. */
  6285. static readonly TEXTUREFORMAT_R32F: number;
  6286. /**
  6287. * RG32F
  6288. */
  6289. static readonly TEXTUREFORMAT_RG32F: number;
  6290. /**
  6291. * RGB32F
  6292. */
  6293. static readonly TEXTUREFORMAT_RGB32F: number;
  6294. /**
  6295. * RGBA32F
  6296. */
  6297. static readonly TEXTUREFORMAT_RGBA32F: number;
  6298. /** LUMINANCE_ALPHA */
  6299. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  6300. /** RGB */
  6301. static readonly TEXTUREFORMAT_RGB: number;
  6302. /** RGBA */
  6303. static readonly TEXTUREFORMAT_RGBA: number;
  6304. /** UNSIGNED_INT */
  6305. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  6306. /** FLOAT */
  6307. static readonly TEXTURETYPE_FLOAT: number;
  6308. /** HALF_FLOAT */
  6309. static readonly TEXTURETYPE_HALF_FLOAT: number;
  6310. private static _SCALEMODE_FLOOR;
  6311. private static _SCALEMODE_NEAREST;
  6312. private static _SCALEMODE_CEILING;
  6313. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  6314. static readonly SCALEMODE_FLOOR: number;
  6315. /** Defines that texture rescaling will look for the nearest power of 2 size */
  6316. static readonly SCALEMODE_NEAREST: number;
  6317. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  6318. static readonly SCALEMODE_CEILING: number;
  6319. /**
  6320. * Returns the current version of the framework
  6321. */
  6322. static readonly Version: string;
  6323. /**
  6324. * Gets or sets the epsilon value used by collision engine
  6325. */
  6326. static CollisionsEpsilon: number;
  6327. /**
  6328. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  6329. */
  6330. static CodeRepository: string;
  6331. /**
  6332. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  6333. */
  6334. static ShadersRepository: string;
  6335. /**
  6336. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  6337. */
  6338. forcePOTTextures: boolean;
  6339. /**
  6340. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  6341. */
  6342. isFullscreen: boolean;
  6343. /**
  6344. * Gets a boolean indicating if the pointer is currently locked
  6345. */
  6346. isPointerLock: boolean;
  6347. /**
  6348. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  6349. */
  6350. cullBackFaces: boolean;
  6351. /**
  6352. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  6353. */
  6354. renderEvenInBackground: boolean;
  6355. /**
  6356. * Gets or sets a boolean indicating that cache can be kept between frames
  6357. */
  6358. preventCacheWipeBetweenFrames: boolean;
  6359. /**
  6360. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  6361. **/
  6362. enableOfflineSupport: boolean;
  6363. /**
  6364. * Gets the list of created scenes
  6365. */
  6366. scenes: Scene[];
  6367. /**
  6368. * Gets the list of created postprocesses
  6369. */
  6370. postProcesses: PostProcess[];
  6371. /**
  6372. * Observable event triggered each time the rendering canvas is resized
  6373. */
  6374. onResizeObservable: Observable<Engine>;
  6375. /**
  6376. * Observable event triggered each time the canvas loses focus
  6377. */
  6378. onCanvasBlurObservable: Observable<Engine>;
  6379. /**
  6380. * Observable event triggered each time the canvas gains focus
  6381. */
  6382. onCanvasFocusObservable: Observable<Engine>;
  6383. /**
  6384. * Observable event triggered each time the canvas receives pointerout event
  6385. */
  6386. onCanvasPointerOutObservable: Observable<PointerEvent>;
  6387. /**
  6388. * Observable event triggered before each texture is initialized
  6389. */
  6390. onBeforeTextureInitObservable: Observable<Texture>;
  6391. private _vrDisplay;
  6392. private _vrSupported;
  6393. private _oldSize;
  6394. private _oldHardwareScaleFactor;
  6395. private _vrExclusivePointerMode;
  6396. private _webVRInitPromise;
  6397. /**
  6398. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  6399. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  6400. */
  6401. readonly isInVRExclusivePointerMode: boolean;
  6402. /**
  6403. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  6404. */
  6405. disableUniformBuffers: boolean;
  6406. /** @ignore */
  6407. _uniformBuffers: UniformBuffer[];
  6408. /**
  6409. * Gets a boolean indicating that the engine supports uniform buffers
  6410. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6411. */
  6412. readonly supportsUniformBuffers: boolean;
  6413. /**
  6414. * Observable raised when the engine begins a new frame
  6415. */
  6416. onBeginFrameObservable: Observable<Engine>;
  6417. /**
  6418. * Observable raised when the engine ends the current frame
  6419. */
  6420. onEndFrameObservable: Observable<Engine>;
  6421. /**
  6422. * Observable raised when the engine is about to compile a shader
  6423. */
  6424. onBeforeShaderCompilationObservable: Observable<Engine>;
  6425. /**
  6426. * Observable raised when the engine has jsut compiled a shader
  6427. */
  6428. onAfterShaderCompilationObservable: Observable<Engine>;
  6429. private _gl;
  6430. private _renderingCanvas;
  6431. private _windowIsBackground;
  6432. private _webGLVersion;
  6433. /**
  6434. * Gets a boolean indicating that only power of 2 textures are supported
  6435. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  6436. */
  6437. readonly needPOTTextures: boolean;
  6438. /** @ignore */
  6439. _badOS: boolean;
  6440. /** @ignore */
  6441. _badDesktopOS: boolean;
  6442. /**
  6443. * Gets or sets a value indicating if we want to disable texture binding optmization.
  6444. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  6445. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  6446. */
  6447. disableTextureBindingOptimization: boolean;
  6448. /**
  6449. * Gets the audio engine
  6450. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6451. * @ignoreNaming
  6452. */
  6453. static audioEngine: AudioEngine;
  6454. private _onFocus;
  6455. private _onBlur;
  6456. private _onCanvasPointerOut;
  6457. private _onCanvasBlur;
  6458. private _onCanvasFocus;
  6459. private _onFullscreenChange;
  6460. private _onPointerLockChange;
  6461. private _onVRDisplayPointerRestricted;
  6462. private _onVRDisplayPointerUnrestricted;
  6463. private _onVrDisplayConnect;
  6464. private _onVrDisplayDisconnect;
  6465. private _onVrDisplayPresentChange;
  6466. /**
  6467. * Observable signaled when VR display mode changes
  6468. */
  6469. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  6470. /**
  6471. * Observable signaled when VR request present is complete
  6472. */
  6473. onVRRequestPresentComplete: Observable<boolean>;
  6474. /**
  6475. * Observable signaled when VR request present starts
  6476. */
  6477. onVRRequestPresentStart: Observable<Engine>;
  6478. private _hardwareScalingLevel;
  6479. /** @ignore */
  6480. protected _caps: EngineCapabilities;
  6481. private _pointerLockRequested;
  6482. private _isStencilEnable;
  6483. private _colorWrite;
  6484. private _loadingScreen;
  6485. /** @ignore */
  6486. _drawCalls: PerfCounter;
  6487. /** @ignore */
  6488. _textureCollisions: PerfCounter;
  6489. private _glVersion;
  6490. private _glRenderer;
  6491. private _glVendor;
  6492. private _videoTextureSupported;
  6493. private _renderingQueueLaunched;
  6494. private _activeRenderLoops;
  6495. private _deterministicLockstep;
  6496. private _lockstepMaxSteps;
  6497. /**
  6498. * Observable signaled when a context lost event is raised
  6499. */
  6500. onContextLostObservable: Observable<Engine>;
  6501. /**
  6502. * Observable signaled when a context restored event is raised
  6503. */
  6504. onContextRestoredObservable: Observable<Engine>;
  6505. private _onContextLost;
  6506. private _onContextRestored;
  6507. private _contextWasLost;
  6508. private _doNotHandleContextLost;
  6509. private _performanceMonitor;
  6510. private _fps;
  6511. private _deltaTime;
  6512. /**
  6513. * Turn this value on if you want to pause FPS computation when in background
  6514. */
  6515. disablePerformanceMonitorInBackground: boolean;
  6516. /**
  6517. * Gets the performance monitor attached to this engine
  6518. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  6519. */
  6520. readonly performanceMonitor: PerformanceMonitor;
  6521. /** @ignore */
  6522. protected _depthCullingState: _DepthCullingState;
  6523. /** @ignore */
  6524. protected _stencilState: _StencilState;
  6525. /** @ignore */
  6526. protected _alphaState: _AlphaState;
  6527. /** @ignore */
  6528. protected _alphaMode: number;
  6529. private _internalTexturesCache;
  6530. /** @ignore */
  6531. protected _activeChannel: number;
  6532. private _currentTextureChannel;
  6533. /** @ignore */
  6534. protected _boundTexturesCache: {
  6535. [key: string]: Nullable<InternalTexture>;
  6536. };
  6537. /** @ignore */
  6538. protected _currentEffect: Nullable<Effect>;
  6539. /** @ignore */
  6540. protected _currentProgram: Nullable<WebGLProgram>;
  6541. private _compiledEffects;
  6542. private _vertexAttribArraysEnabled;
  6543. /** @ignore */
  6544. protected _cachedViewport: Nullable<Viewport>;
  6545. private _cachedVertexArrayObject;
  6546. /** @ignore */
  6547. protected _cachedVertexBuffers: any;
  6548. /** @ignore */
  6549. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  6550. /** @ignore */
  6551. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  6552. /** @ignore */
  6553. protected _currentRenderTarget: Nullable<InternalTexture>;
  6554. private _uintIndicesCurrentlySet;
  6555. private _currentBoundBuffer;
  6556. /** @ignore */
  6557. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  6558. private _currentBufferPointers;
  6559. private _currentInstanceLocations;
  6560. private _currentInstanceBuffers;
  6561. private _textureUnits;
  6562. private _firstBoundInternalTextureTracker;
  6563. private _lastBoundInternalTextureTracker;
  6564. private _workingCanvas;
  6565. private _workingContext;
  6566. private _rescalePostProcess;
  6567. private _dummyFramebuffer;
  6568. private _externalData;
  6569. private _bindedRenderFunction;
  6570. private _vaoRecordInProgress;
  6571. private _mustWipeVertexAttributes;
  6572. private _emptyTexture;
  6573. private _emptyCubeTexture;
  6574. private _emptyTexture3D;
  6575. private _frameHandler;
  6576. private _nextFreeTextureSlots;
  6577. private _maxSimultaneousTextures;
  6578. private _activeRequests;
  6579. private _texturesSupported;
  6580. private _textureFormatInUse;
  6581. /**
  6582. * Gets the list of texture formats supported
  6583. */
  6584. readonly texturesSupported: Array<string>;
  6585. /**
  6586. * Gets the list of texture formats in use
  6587. */
  6588. readonly textureFormatInUse: Nullable<string>;
  6589. /**
  6590. * Gets the current viewport
  6591. */
  6592. readonly currentViewport: Nullable<Viewport>;
  6593. /**
  6594. * Gets the default empty texture
  6595. */
  6596. readonly emptyTexture: InternalTexture;
  6597. /**
  6598. * Gets the default empty 3D texture
  6599. */
  6600. readonly emptyTexture3D: InternalTexture;
  6601. /**
  6602. * Gets the default empty cube texture
  6603. */
  6604. readonly emptyCubeTexture: InternalTexture;
  6605. /**
  6606. * Creates a new engine
  6607. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  6608. * @param antialias defines enable antialiasing (default: false)
  6609. * @param options defines further options to be sent to the getContext() function
  6610. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  6611. */
  6612. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  6613. private _rebuildInternalTextures();
  6614. private _rebuildEffects();
  6615. private _rebuildBuffers();
  6616. private _initGLContext();
  6617. /**
  6618. * Gets version of the current webGL context
  6619. */
  6620. readonly webGLVersion: number;
  6621. /**
  6622. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  6623. */
  6624. readonly isStencilEnable: boolean;
  6625. private _prepareWorkingCanvas();
  6626. /**
  6627. * Reset the texture cache to empty state
  6628. */
  6629. resetTextureCache(): void;
  6630. /**
  6631. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  6632. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6633. * @returns true if engine is in deterministic lock step mode
  6634. */
  6635. isDeterministicLockStep(): boolean;
  6636. /**
  6637. * Gets the max steps when engine is running in deterministic lock step
  6638. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6639. * @returns the max steps
  6640. */
  6641. getLockstepMaxSteps(): number;
  6642. /**
  6643. * Gets an object containing information about the current webGL context
  6644. * @returns an object containing the vender, the renderer and the version of the current webGL context
  6645. */
  6646. getGlInfo(): {
  6647. vendor: string;
  6648. renderer: string;
  6649. version: string;
  6650. };
  6651. /**
  6652. * Gets current aspect ratio
  6653. * @param camera defines the camera to use to get the aspect ratio
  6654. * @param useScreen defines if screen size must be used (or the current render target if any)
  6655. * @returns a number defining the aspect ratio
  6656. */
  6657. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  6658. /**
  6659. * Gets the current render width
  6660. * @param useScreen defines if screen size must be used (or the current render target if any)
  6661. * @returns a number defining the current render width
  6662. */
  6663. getRenderWidth(useScreen?: boolean): number;
  6664. /**
  6665. * Gets the current render height
  6666. * @param useScreen defines if screen size must be used (or the current render target if any)
  6667. * @returns a number defining the current render height
  6668. */
  6669. getRenderHeight(useScreen?: boolean): number;
  6670. /**
  6671. * Gets the HTML canvas attached with the current webGL context
  6672. * @returns a HTML canvas
  6673. */
  6674. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  6675. /**
  6676. * Gets the client rect of the HTML canvas attached with the current webGL context
  6677. * @returns a client rectanglee
  6678. */
  6679. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  6680. /**
  6681. * Defines the hardware scaling level.
  6682. * By default the hardware scaling level is computed from the window device ratio.
  6683. * 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.
  6684. * @param level defines the level to use
  6685. */
  6686. setHardwareScalingLevel(level: number): void;
  6687. /**
  6688. * Gets the current hardware scaling level.
  6689. * By default the hardware scaling level is computed from the window device ratio.
  6690. * 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.
  6691. * @returns a number indicating the current hardware scaling level
  6692. */
  6693. getHardwareScalingLevel(): number;
  6694. /**
  6695. * Gets the list of loaded textures
  6696. * @returns an array containing all loaded textures
  6697. */
  6698. getLoadedTexturesCache(): InternalTexture[];
  6699. /**
  6700. * Gets the object containing all engine capabilities
  6701. * @returns the EngineCapabilities object
  6702. */
  6703. getCaps(): EngineCapabilities;
  6704. /** @ignore */
  6705. readonly drawCalls: number;
  6706. /** @ignore */
  6707. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  6708. /**
  6709. * Gets the current depth function
  6710. * @returns a number defining the depth function
  6711. */
  6712. getDepthFunction(): Nullable<number>;
  6713. /**
  6714. * Sets the current depth function
  6715. * @param depthFunc defines the function to use
  6716. */
  6717. setDepthFunction(depthFunc: number): void;
  6718. /**
  6719. * Sets the current depth function to GREATER
  6720. */
  6721. setDepthFunctionToGreater(): void;
  6722. /**
  6723. * Sets the current depth function to GEQUAL
  6724. */
  6725. setDepthFunctionToGreaterOrEqual(): void;
  6726. /**
  6727. * Sets the current depth function to LESS
  6728. */
  6729. setDepthFunctionToLess(): void;
  6730. /**
  6731. * Sets the current depth function to LEQUAL
  6732. */
  6733. setDepthFunctionToLessOrEqual(): void;
  6734. /**
  6735. * Gets a boolean indicating if stencil buffer is enabled
  6736. * @returns the current stencil buffer state
  6737. */
  6738. getStencilBuffer(): boolean;
  6739. /**
  6740. * Enable or disable the stencil buffer
  6741. * @param enable defines if the stencil buffer must be enabled or disabled
  6742. */
  6743. setStencilBuffer(enable: boolean): void;
  6744. /**
  6745. * Gets the current stencil mask
  6746. * @returns a number defining the new stencil mask to use
  6747. */
  6748. getStencilMask(): number;
  6749. /**
  6750. * Sets the current stencil mask
  6751. * @param mask defines the new stencil mask to use
  6752. */
  6753. setStencilMask(mask: number): void;
  6754. /**
  6755. * Gets the current stencil function
  6756. * @returns a number defining the stencil function to use
  6757. */
  6758. getStencilFunction(): number;
  6759. /**
  6760. * Gets the current stencil reference value
  6761. * @returns a number defining the stencil reference value to use
  6762. */
  6763. getStencilFunctionReference(): number;
  6764. /**
  6765. * Gets the current stencil mask
  6766. * @returns a number defining the stencil mask to use
  6767. */
  6768. getStencilFunctionMask(): number;
  6769. /**
  6770. * Sets the current stencil function
  6771. * @param stencilFunc defines the new stencil function to use
  6772. */
  6773. setStencilFunction(stencilFunc: number): void;
  6774. /**
  6775. * Sets the current stencil reference
  6776. * @param reference defines the new stencil reference to use
  6777. */
  6778. setStencilFunctionReference(reference: number): void;
  6779. /**
  6780. * Sets the current stencil mask
  6781. * @param mask defines the new stencil mask to use
  6782. */
  6783. setStencilFunctionMask(mask: number): void;
  6784. /**
  6785. * Gets the current stencil operation when stencil fails
  6786. * @returns a number defining stencil operation to use when stencil fails
  6787. */
  6788. getStencilOperationFail(): number;
  6789. /**
  6790. * Gets the current stencil operation when depth fails
  6791. * @returns a number defining stencil operation to use when depth fails
  6792. */
  6793. getStencilOperationDepthFail(): number;
  6794. /**
  6795. * Gets the current stencil operation when stencil passes
  6796. * @returns a number defining stencil operation to use when stencil passes
  6797. */
  6798. getStencilOperationPass(): number;
  6799. /**
  6800. * Sets the stencil operation to use when stencil fails
  6801. * @param operation defines the stencil operation to use when stencil fails
  6802. */
  6803. setStencilOperationFail(operation: number): void;
  6804. /**
  6805. * Sets the stencil operation to use when depth fails
  6806. * @param operation defines the stencil operation to use when depth fails
  6807. */
  6808. setStencilOperationDepthFail(operation: number): void;
  6809. /**
  6810. * Sets the stencil operation to use when stencil passes
  6811. * @param operation defines the stencil operation to use when stencil passes
  6812. */
  6813. setStencilOperationPass(operation: number): void;
  6814. /**
  6815. * Sets a boolean indicating if the dithering state is enabled or disabled
  6816. * @param value defines the dithering state
  6817. */
  6818. setDitheringState(value: boolean): void;
  6819. /**
  6820. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  6821. * @param value defines the rasterizer state
  6822. */
  6823. setRasterizerState(value: boolean): void;
  6824. /**
  6825. * stop executing a render loop function and remove it from the execution array
  6826. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  6827. */
  6828. stopRenderLoop(renderFunction?: () => void): void;
  6829. /** @ignore */
  6830. _renderLoop(): void;
  6831. /**
  6832. * Register and execute a render loop. The engine can have more than one render function
  6833. * @param renderFunction defines the function to continuously execute
  6834. */
  6835. runRenderLoop(renderFunction: () => void): void;
  6836. /**
  6837. * Toggle full screen mode
  6838. * @param requestPointerLock defines if a pointer lock should be requested from the user
  6839. * @param options defines an option object to be sent to the requestFullscreen function
  6840. */
  6841. switchFullscreen(requestPointerLock: boolean): void;
  6842. /**
  6843. * Clear the current render buffer or the current render target (if any is set up)
  6844. * @param color defines the color to use
  6845. * @param backBuffer defines if the back buffer must be cleared
  6846. * @param depth defines if the depth buffer must be cleared
  6847. * @param stencil defines if the stencil buffer must be cleared
  6848. */
  6849. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  6850. /**
  6851. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  6852. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  6853. * @param y defines the y-coordinate of the corner of the clear rectangle
  6854. * @param width defines the width of the clear rectangle
  6855. * @param height defines the height of the clear rectangle
  6856. * @param clearColor defines the clear color
  6857. */
  6858. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  6859. /**
  6860. * Set the WebGL's viewport
  6861. * @param viewport defines the viewport element to be used
  6862. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  6863. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  6864. */
  6865. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  6866. /**
  6867. * Directly set the WebGL Viewport
  6868. * @param x defines the x coordinate of the viewport (in screen space)
  6869. * @param y defines the y coordinate of the viewport (in screen space)
  6870. * @param width defines the width of the viewport (in screen space)
  6871. * @param height defines the height of the viewport (in screen space)
  6872. * @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
  6873. */
  6874. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  6875. /**
  6876. * Begin a new frame
  6877. */
  6878. beginFrame(): void;
  6879. /**
  6880. * Enf the current frame
  6881. */
  6882. endFrame(): void;
  6883. /**
  6884. * Resize the view according to the canvas' size
  6885. */
  6886. resize(): void;
  6887. /**
  6888. * Force a specific size of the canvas
  6889. * @param width defines the new canvas' width
  6890. * @param height defines the new canvas' height
  6891. */
  6892. setSize(width: number, height: number): void;
  6893. /**
  6894. * Gets a boolean indicating if a webVR device was detected
  6895. * @returns true if a webVR device was detected
  6896. */
  6897. isVRDevicePresent(): boolean;
  6898. /**
  6899. * Gets the current webVR device
  6900. * @returns the current webVR device (or null)
  6901. */
  6902. getVRDevice(): any;
  6903. /**
  6904. * Initializes a webVR display and starts listening to display change events
  6905. * The onVRDisplayChangedObservable will be notified upon these changes
  6906. * @returns The onVRDisplayChangedObservable
  6907. */
  6908. initWebVR(): Observable<IDisplayChangedEventArgs>;
  6909. /**
  6910. * Initializes a webVR display and starts listening to display change events
  6911. * The onVRDisplayChangedObservable will be notified upon these changes
  6912. * @returns A promise containing a VRDisplay and if vr is supported
  6913. */
  6914. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  6915. /**
  6916. * Call this function to switch to webVR mode
  6917. * Will do nothing if webVR is not supported or if there is no webVR device
  6918. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6919. */
  6920. enableVR(): void;
  6921. /**
  6922. * Call this function to leave webVR mode
  6923. * Will do nothing if webVR is not supported or if there is no webVR device
  6924. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6925. */
  6926. disableVR(): void;
  6927. private _onVRFullScreenTriggered;
  6928. private _getVRDisplaysAsync();
  6929. /**
  6930. * Binds the frame buffer to the specified texture.
  6931. * @param texture The texture to render to or null for the default canvas
  6932. * @param faceIndex The face of the texture to render to in case of cube texture
  6933. * @param requiredWidth The width of the target to render to
  6934. * @param requiredHeight The height of the target to render to
  6935. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  6936. * @param depthStencilTexture The depth stencil texture to use to render
  6937. */
  6938. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture): void;
  6939. private bindUnboundFramebuffer(framebuffer);
  6940. /**
  6941. * Unbind the current render target texture from the webGL context
  6942. * @param texture defines the render target texture to unbind
  6943. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  6944. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  6945. */
  6946. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  6947. /**
  6948. * Unbind a list of render target textures from the webGL context
  6949. * This is used only when drawBuffer extension or webGL2 are active
  6950. * @param textures defines the render target textures to unbind
  6951. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  6952. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  6953. */
  6954. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  6955. /**
  6956. * Force the mipmap generation for the given render target texture
  6957. * @param texture defines the render target texture to use
  6958. */
  6959. generateMipMapsForCubemap(texture: InternalTexture): void;
  6960. /**
  6961. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  6962. */
  6963. flushFramebuffer(): void;
  6964. /**
  6965. * Unbind the current render target and bind the default framebuffer
  6966. */
  6967. restoreDefaultFramebuffer(): void;
  6968. /**
  6969. * Create an uniform buffer
  6970. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6971. * @param elements defines the content of the uniform buffer
  6972. * @returns the webGL uniform buffer
  6973. */
  6974. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  6975. /**
  6976. * Create a dynamic uniform buffer
  6977. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6978. * @param elements defines the content of the uniform buffer
  6979. * @returns the webGL uniform buffer
  6980. */
  6981. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  6982. /**
  6983. * Update an existing uniform buffer
  6984. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6985. * @param uniformBuffer defines the target uniform buffer
  6986. * @param elements defines the content to update
  6987. * @param offset defines the offset in the uniform buffer where update should start
  6988. * @param count defines the size of the data to update
  6989. */
  6990. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  6991. private _resetVertexBufferBinding();
  6992. /**
  6993. * Creates a vertex buffer
  6994. * @param data the data for the vertex buffer
  6995. * @returns the new WebGL static buffer
  6996. */
  6997. createVertexBuffer(data: DataArray): WebGLBuffer;
  6998. /**
  6999. * Creates a dynamic vertex buffer
  7000. * @param data the data for the dynamic vertex buffer
  7001. * @returns the new WebGL dynamic buffer
  7002. */
  7003. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  7004. /**
  7005. * Update a dynamic index buffer
  7006. * @param indexBuffer defines the target index buffer
  7007. * @param indices defines the data to update
  7008. * @param offset defines the offset in the target index buffer where update should start
  7009. */
  7010. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  7011. /**
  7012. * Updates a dynamic vertex buffer.
  7013. * @param vertexBuffer the vertex buffer to update
  7014. * @param data the data used to update the vertex buffer
  7015. * @param byteOffset the byte offset of the data
  7016. * @param byteLength the byte length of the data
  7017. */
  7018. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  7019. private _resetIndexBufferBinding();
  7020. /**
  7021. * Creates a new index buffer
  7022. * @param indices defines the content of the index buffer
  7023. * @param updatable defines if the index buffer must be updatable
  7024. * @returns a new webGL buffer
  7025. */
  7026. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  7027. /**
  7028. * Bind a webGL buffer to the webGL context
  7029. * @param buffer defines the buffer to bind
  7030. */
  7031. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  7032. /**
  7033. * Bind an uniform buffer to the current webGL context
  7034. * @param buffer defines the buffer to bind
  7035. */
  7036. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  7037. /**
  7038. * Bind a buffer to the current webGL context at a given location
  7039. * @param buffer defines the buffer to bind
  7040. * @param location defines the index where to bind the buffer
  7041. */
  7042. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  7043. /**
  7044. * Bind a specific block at a given index in a specific shader program
  7045. * @param shaderProgram defines the shader program
  7046. * @param blockName defines the block name
  7047. * @param index defines the index where to bind the block
  7048. */
  7049. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  7050. private bindIndexBuffer(buffer);
  7051. private bindBuffer(buffer, target);
  7052. /**
  7053. * update the bound buffer with the given data
  7054. * @param data defines the data to update
  7055. */
  7056. updateArrayBuffer(data: Float32Array): void;
  7057. private _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  7058. private _bindIndexBufferWithCache(indexBuffer);
  7059. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  7060. /**
  7061. * Records a vertex array object
  7062. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7063. * @param vertexBuffers defines the list of vertex buffers to store
  7064. * @param indexBuffer defines the index buffer to store
  7065. * @param effect defines the effect to store
  7066. * @returns the new vertex array object
  7067. */
  7068. recordVertexArrayObject(vertexBuffers: {
  7069. [key: string]: VertexBuffer;
  7070. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  7071. /**
  7072. * Bind a specific vertex array object
  7073. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7074. * @param vertexArrayObject defines the vertex array object to bind
  7075. * @param indexBuffer defines the index buffer to bind
  7076. */
  7077. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  7078. /**
  7079. * Bind webGl buffers directly to the webGL context
  7080. * @param vertexBuffer defines the vertex buffer to bind
  7081. * @param indexBuffer defines the index buffer to bind
  7082. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  7083. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  7084. * @param effect defines the effect associated with the vertex buffer
  7085. */
  7086. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  7087. private _unbindVertexArrayObject();
  7088. /**
  7089. * Bind a list of vertex buffers to the webGL context
  7090. * @param vertexBuffers defines the list of vertex buffers to bind
  7091. * @param indexBuffer defines the index buffer to bind
  7092. * @param effect defines the effect associated with the vertex buffers
  7093. */
  7094. bindBuffers(vertexBuffers: {
  7095. [key: string]: Nullable<VertexBuffer>;
  7096. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  7097. /**
  7098. * Unbind all instance attributes
  7099. */
  7100. unbindInstanceAttributes(): void;
  7101. /**
  7102. * Release and free the memory of a vertex array object
  7103. * @param vao defines the vertex array object to delete
  7104. */
  7105. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  7106. /** @ignore */
  7107. _releaseBuffer(buffer: WebGLBuffer): boolean;
  7108. /**
  7109. * Creates a webGL buffer to use with instanciation
  7110. * @param capacity defines the size of the buffer
  7111. * @returns the webGL buffer
  7112. */
  7113. createInstancesBuffer(capacity: number): WebGLBuffer;
  7114. /**
  7115. * Delete a webGL buffer used with instanciation
  7116. * @param buffer defines the webGL buffer to delete
  7117. */
  7118. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  7119. /**
  7120. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  7121. * @param instancesBuffer defines the webGL buffer to update and bind
  7122. * @param data defines the data to store in the buffer
  7123. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  7124. */
  7125. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  7126. /**
  7127. * Apply all cached states (depth, culling, stencil and alpha)
  7128. */
  7129. applyStates(): void;
  7130. /**
  7131. * Send a draw order
  7132. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7133. * @param indexStart defines the starting index
  7134. * @param indexCount defines the number of index to draw
  7135. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7136. */
  7137. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  7138. /**
  7139. * Draw a list of points
  7140. * @param verticesStart defines the index of first vertex to draw
  7141. * @param verticesCount defines the count of vertices to draw
  7142. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7143. */
  7144. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7145. /**
  7146. * Draw a list of unindexed primitives
  7147. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7148. * @param verticesStart defines the index of first vertex to draw
  7149. * @param verticesCount defines the count of vertices to draw
  7150. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7151. */
  7152. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7153. /**
  7154. * Draw a list of indexed primitives
  7155. * @param fillMode defines the primitive to use
  7156. * @param indexStart defines the starting index
  7157. * @param indexCount defines the number of index to draw
  7158. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7159. */
  7160. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  7161. /**
  7162. * Draw a list of unindexed primitives
  7163. * @param fillMode defines the primitive to use
  7164. * @param verticesStart defines the index of first vertex to draw
  7165. * @param verticesCount defines the count of vertices to draw
  7166. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7167. */
  7168. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7169. private _drawMode(fillMode);
  7170. /** @ignore */
  7171. _releaseEffect(effect: Effect): void;
  7172. /** @ignore */
  7173. _deleteProgram(program: WebGLProgram): void;
  7174. /**
  7175. * Create a new effect (used to store vertex/fragment shaders)
  7176. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  7177. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  7178. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  7179. * @param samplers defines an array of string used to represent textures
  7180. * @param defines defines the string containing the defines to use to compile the shaders
  7181. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  7182. * @param onCompiled defines a function to call when the effect creation is successful
  7183. * @param onError defines a function to call when the effect creation has failed
  7184. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  7185. * @returns the new Effect
  7186. */
  7187. 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;
  7188. /**
  7189. * Create an effect to use with particle systems
  7190. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  7191. * @param uniformsNames defines a list of attribute names
  7192. * @param samplers defines an array of string used to represent textures
  7193. * @param defines defines the string containing the defines to use to compile the shaders
  7194. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  7195. * @param onCompiled defines a function to call when the effect creation is successful
  7196. * @param onError defines a function to call when the effect creation has failed
  7197. * @returns the new Effect
  7198. */
  7199. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  7200. /**
  7201. * Directly creates a webGL program
  7202. * @param vertexCode defines the vertex shader code to use
  7203. * @param fragmentCode defines the fragment shader code to use
  7204. * @param context defines the webGL context to use (if not set, the current one will be used)
  7205. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  7206. * @returns the new webGL program
  7207. */
  7208. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  7209. /**
  7210. * Creates a webGL program
  7211. * @param vertexCode defines the vertex shader code to use
  7212. * @param fragmentCode defines the fragment shader code to use
  7213. * @param defines defines the string containing the defines to use to compile the shaders
  7214. * @param context defines the webGL context to use (if not set, the current one will be used)
  7215. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  7216. * @returns the new webGL program
  7217. */
  7218. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  7219. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  7220. /**
  7221. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  7222. * @param shaderProgram defines the webGL program to use
  7223. * @param uniformsNames defines the list of uniform names
  7224. * @returns an array of webGL uniform locations
  7225. */
  7226. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  7227. /**
  7228. * Gets the lsit of active attributes for a given webGL program
  7229. * @param shaderProgram defines the webGL program to use
  7230. * @param attributesNames defines the list of attribute names to get
  7231. * @returns an array of indices indicating the offset of each attribute
  7232. */
  7233. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  7234. /**
  7235. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  7236. * @param effect defines the effect to activate
  7237. */
  7238. enableEffect(effect: Nullable<Effect>): void;
  7239. /**
  7240. * Set the value of an uniform to an array of int32
  7241. * @param uniform defines the webGL uniform location where to store the value
  7242. * @param array defines the array of int32 to store
  7243. */
  7244. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7245. /**
  7246. * Set the value of an uniform to an array of int32 (stored as vec2)
  7247. * @param uniform defines the webGL uniform location where to store the value
  7248. * @param array defines the array of int32 to store
  7249. */
  7250. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7251. /**
  7252. * Set the value of an uniform to an array of int32 (stored as vec3)
  7253. * @param uniform defines the webGL uniform location where to store the value
  7254. * @param array defines the array of int32 to store
  7255. */
  7256. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7257. /**
  7258. * Set the value of an uniform to an array of int32 (stored as vec4)
  7259. * @param uniform defines the webGL uniform location where to store the value
  7260. * @param array defines the array of int32 to store
  7261. */
  7262. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7263. /**
  7264. * Set the value of an uniform to an array of float32
  7265. * @param uniform defines the webGL uniform location where to store the value
  7266. * @param array defines the array of float32 to store
  7267. */
  7268. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7269. /**
  7270. * Set the value of an uniform to an array of float32 (stored as vec2)
  7271. * @param uniform defines the webGL uniform location where to store the value
  7272. * @param array defines the array of float32 to store
  7273. */
  7274. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7275. /**
  7276. * Set the value of an uniform to an array of float32 (stored as vec3)
  7277. * @param uniform defines the webGL uniform location where to store the value
  7278. * @param array defines the array of float32 to store
  7279. */
  7280. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7281. /**
  7282. * Set the value of an uniform to an array of float32 (stored as vec4)
  7283. * @param uniform defines the webGL uniform location where to store the value
  7284. * @param array defines the array of float32 to store
  7285. */
  7286. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7287. /**
  7288. * Set the value of an uniform to an array of number
  7289. * @param uniform defines the webGL uniform location where to store the value
  7290. * @param array defines the array of number to store
  7291. */
  7292. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7293. /**
  7294. * Set the value of an uniform to an array of number (stored as vec2)
  7295. * @param uniform defines the webGL uniform location where to store the value
  7296. * @param array defines the array of number to store
  7297. */
  7298. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7299. /**
  7300. * Set the value of an uniform to an array of number (stored as vec3)
  7301. * @param uniform defines the webGL uniform location where to store the value
  7302. * @param array defines the array of number to store
  7303. */
  7304. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7305. /**
  7306. * Set the value of an uniform to an array of number (stored as vec4)
  7307. * @param uniform defines the webGL uniform location where to store the value
  7308. * @param array defines the array of number to store
  7309. */
  7310. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7311. /**
  7312. * Set the value of an uniform to an array of float32 (stored as matrices)
  7313. * @param uniform defines the webGL uniform location where to store the value
  7314. * @param matrices defines the array of float32 to store
  7315. */
  7316. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  7317. /**
  7318. * Set the value of an uniform to a matrix
  7319. * @param uniform defines the webGL uniform location where to store the value
  7320. * @param matrix defines the matrix to store
  7321. */
  7322. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  7323. /**
  7324. * Set the value of an uniform to a matrix (3x3)
  7325. * @param uniform defines the webGL uniform location where to store the value
  7326. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  7327. */
  7328. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  7329. /**
  7330. * Set the value of an uniform to a matrix (2x2)
  7331. * @param uniform defines the webGL uniform location where to store the value
  7332. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  7333. */
  7334. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  7335. /**
  7336. * Set the value of an uniform to a number (int)
  7337. * @param uniform defines the webGL uniform location where to store the value
  7338. * @param value defines the int number to store
  7339. */
  7340. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  7341. /**
  7342. * Set the value of an uniform to a number (float)
  7343. * @param uniform defines the webGL uniform location where to store the value
  7344. * @param value defines the float number to store
  7345. */
  7346. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  7347. /**
  7348. * Set the value of an uniform to a vec2
  7349. * @param uniform defines the webGL uniform location where to store the value
  7350. * @param x defines the 1st component of the value
  7351. * @param y defines the 2nd component of the value
  7352. */
  7353. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  7354. /**
  7355. * Set the value of an uniform to a vec3
  7356. * @param uniform defines the webGL uniform location where to store the value
  7357. * @param x defines the 1st component of the value
  7358. * @param y defines the 2nd component of the value
  7359. * @param z defines the 3rd component of the value
  7360. */
  7361. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  7362. /**
  7363. * Set the value of an uniform to a boolean
  7364. * @param uniform defines the webGL uniform location where to store the value
  7365. * @param bool defines the boolean to store
  7366. */
  7367. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  7368. /**
  7369. * Set the value of an uniform to a vec4
  7370. * @param uniform defines the webGL uniform location where to store the value
  7371. * @param x defines the 1st component of the value
  7372. * @param y defines the 2nd component of the value
  7373. * @param z defines the 3rd component of the value
  7374. * @param w defines the 4th component of the value
  7375. */
  7376. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  7377. /**
  7378. * Set the value of an uniform to a Color3
  7379. * @param uniform defines the webGL uniform location where to store the value
  7380. * @param color3 defines the color to store
  7381. */
  7382. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  7383. /**
  7384. * Set the value of an uniform to a Color3 and an alpha value
  7385. * @param uniform defines the webGL uniform location where to store the value
  7386. * @param color3 defines the color to store
  7387. * @param alpha defines the alpha component to store
  7388. */
  7389. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  7390. /**
  7391. * Sets a Color4 on a uniform variable
  7392. * @param uniform defines the uniform location
  7393. * @param color4 defines the value to be set
  7394. */
  7395. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  7396. /**
  7397. * Set various states to the webGL context
  7398. * @param culling defines backface culling state
  7399. * @param zOffset defines the value to apply to zOffset (0 by default)
  7400. * @param force defines if states must be applied even if cache is up to date
  7401. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  7402. */
  7403. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  7404. /**
  7405. * Set the z offset to apply to current rendering
  7406. * @param value defines the offset to apply
  7407. */
  7408. setZOffset(value: number): void;
  7409. /**
  7410. * Gets the current value of the zOffset
  7411. * @returns the current zOffset state
  7412. */
  7413. getZOffset(): number;
  7414. /**
  7415. * Enable or disable depth buffering
  7416. * @param enable defines the state to set
  7417. */
  7418. setDepthBuffer(enable: boolean): void;
  7419. /**
  7420. * Gets a boolean indicating if depth writing is enabled
  7421. * @returns the current depth writing state
  7422. */
  7423. getDepthWrite(): boolean;
  7424. /**
  7425. * Enable or disable depth writing
  7426. * @param enable defines the state to set
  7427. */
  7428. setDepthWrite(enable: boolean): void;
  7429. /**
  7430. * Enable or disable color writing
  7431. * @param enable defines the state to set
  7432. */
  7433. setColorWrite(enable: boolean): void;
  7434. /**
  7435. * Gets a boolean indicating if color writing is enabled
  7436. * @returns the current color writing state
  7437. */
  7438. getColorWrite(): boolean;
  7439. /**
  7440. * Sets alpha constants used by some alpha blending modes
  7441. * @param r defines the red component
  7442. * @param g defines the green component
  7443. * @param b defines the blue component
  7444. * @param a defines the alpha component
  7445. */
  7446. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  7447. /**
  7448. * Sets the current alpha mode
  7449. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  7450. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  7451. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  7452. */
  7453. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  7454. /**
  7455. * Gets the current alpha mode
  7456. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  7457. * @returns the current alpha mode
  7458. */
  7459. getAlphaMode(): number;
  7460. /**
  7461. * Force the entire cache to be cleared
  7462. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  7463. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  7464. */
  7465. wipeCaches(bruteForce?: boolean): void;
  7466. /**
  7467. * Set the compressed texture format to use, based on the formats you have, and the formats
  7468. * supported by the hardware / browser.
  7469. *
  7470. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  7471. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  7472. * to API arguments needed to compressed textures. This puts the burden on the container
  7473. * generator to house the arcane code for determining these for current & future formats.
  7474. *
  7475. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  7476. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  7477. *
  7478. * Note: The result of this call is not taken into account when a texture is base64.
  7479. *
  7480. * @param formatsAvailable defines the list of those format families you have created
  7481. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  7482. *
  7483. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  7484. * @returns The extension selected.
  7485. */
  7486. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  7487. /** @ignore */
  7488. _createTexture(): WebGLTexture;
  7489. /**
  7490. * Usually called from BABYLON.Texture.ts.
  7491. * Passed information to create a WebGLTexture
  7492. * @param urlArg defines a value which contains one of the following:
  7493. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  7494. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  7495. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  7496. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  7497. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  7498. * @param scene needed for loading to the correct scene
  7499. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  7500. * @param onLoad optional callback to be called upon successful completion
  7501. * @param onError optional callback to be called upon failure
  7502. * @param buffer a source of a file previously fetched as either an ArrayBuffer (compressed or image format) or HTMLImageElement (image format)
  7503. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  7504. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  7505. * @returns a InternalTexture for assignment back into BABYLON.Texture
  7506. */
  7507. 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<ArrayBuffer | HTMLImageElement>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>): InternalTexture;
  7508. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  7509. /**
  7510. * Update a raw texture
  7511. * @param texture defines the texture to update
  7512. * @param data defines the data to store in the texture
  7513. * @param format defines the format of the data
  7514. * @param invertY defines if data must be stored with Y axis inverted
  7515. * @param compression defines the compression used (null by default)
  7516. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  7517. */
  7518. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  7519. /**
  7520. * Creates a raw texture
  7521. * @param data defines the data to store in the texture
  7522. * @param width defines the width of the texture
  7523. * @param height defines the height of the texture
  7524. * @param format defines the format of the data
  7525. * @param generateMipMaps defines if the engine should generate the mip levels
  7526. * @param invertY defines if data must be stored with Y axis inverted
  7527. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  7528. * @param compression defines the compression used (null by default)
  7529. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  7530. * @returns the raw texture inside an InternalTexture
  7531. */
  7532. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  7533. /**
  7534. * Creates a dynamic texture
  7535. * @param width defines the width of the texture
  7536. * @param height defines the height of the texture
  7537. * @param generateMipMaps defines if the engine should generate the mip levels
  7538. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  7539. * @returns the dynamic texture inside an InternalTexture
  7540. */
  7541. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  7542. /**
  7543. * Update the sampling mode of a given texture
  7544. * @param samplingMode defines the required sampling mode
  7545. * @param texture defines the texture to update
  7546. */
  7547. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  7548. /**
  7549. * Update the content of a dynamic texture
  7550. * @param texture defines the texture to update
  7551. * @param canvas defines the canvas containing the source
  7552. * @param invertY defines if data must be stored with Y axis inverted
  7553. * @param premulAlpha defines if alpha is stored as premultiplied
  7554. * @param format defines the format of the data
  7555. */
  7556. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  7557. /**
  7558. * Update a video texture
  7559. * @param texture defines the texture to update
  7560. * @param video defines the video element to use
  7561. * @param invertY defines if data must be stored with Y axis inverted
  7562. */
  7563. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  7564. /**
  7565. * Updates a depth texture Comparison Mode and Function.
  7566. * If the comparison Function is equal to 0, the mode will be set to none.
  7567. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  7568. * @param texture The texture to set the comparison function for
  7569. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  7570. */
  7571. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  7572. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  7573. /**
  7574. * Creates a depth stencil texture.
  7575. * This is only available in WebGL 2 or with the depth texture extension available.
  7576. * @param size The size of face edge in the texture.
  7577. * @param options The options defining the texture.
  7578. * @returns The texture
  7579. */
  7580. createDepthStencilTexture(size: number | {
  7581. width: number;
  7582. height: number;
  7583. }, options: DepthTextureCreationOptions): InternalTexture;
  7584. /**
  7585. * Creates a depth stencil texture.
  7586. * This is only available in WebGL 2 or with the depth texture extension available.
  7587. * @param size The size of face edge in the texture.
  7588. * @param options The options defining the texture.
  7589. * @returns The texture
  7590. */
  7591. private _createDepthStencilTexture(size, options);
  7592. /**
  7593. * Creates a depth stencil cube texture.
  7594. * This is only available in WebGL 2.
  7595. * @param size The size of face edge in the cube texture.
  7596. * @param options The options defining the cube texture.
  7597. * @returns The cube texture
  7598. */
  7599. private _createDepthStencilCubeTexture(size, options);
  7600. /**
  7601. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  7602. * @param renderTarget The render target to set the frame buffer for
  7603. */
  7604. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  7605. /**
  7606. * Creates a new render target texture
  7607. * @param size defines the size of the texture
  7608. * @param options defines the options used to create the texture
  7609. * @returns a new render target texture stored in an InternalTexture
  7610. */
  7611. createRenderTargetTexture(size: number | {
  7612. width: number;
  7613. height: number;
  7614. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  7615. /**
  7616. * Create a multi render target texture
  7617. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  7618. * @param size defines the size of the texture
  7619. * @param options defines the creation options
  7620. * @returns the cube texture as an InternalTexture
  7621. */
  7622. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  7623. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  7624. /**
  7625. * Updates the sample count of a render target texture
  7626. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  7627. * @param texture defines the texture to update
  7628. * @param samples defines the sample count to set
  7629. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  7630. */
  7631. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  7632. /**
  7633. * Update the sample count for a given multiple render target texture
  7634. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  7635. * @param textures defines the textures to update
  7636. * @param samples defines the sample count to set
  7637. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  7638. */
  7639. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  7640. /** @ignore */
  7641. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  7642. /** @ignore */
  7643. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  7644. /**
  7645. * Creates a new render target cube texture
  7646. * @param size defines the size of the texture
  7647. * @param options defines the options used to create the texture
  7648. * @returns a new render target cube texture stored in an InternalTexture
  7649. */
  7650. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  7651. /**
  7652. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  7653. * @param rootUrl defines the url where the file to load is located
  7654. * @param scene defines the current scene
  7655. * @param scale defines scale to apply to the mip map selection
  7656. * @param offset defines offset to apply to the mip map selection
  7657. * @param onLoad defines an optional callback raised when the texture is loaded
  7658. * @param onError defines an optional callback raised if there is an issue to load the texture
  7659. * @param format defines the format of the data
  7660. * @param forcedExtension defines the extension to use to pick the right loader
  7661. * @returns the cube texture as an InternalTexture
  7662. */
  7663. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, scale: number, offset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any): InternalTexture;
  7664. /**
  7665. * Creates a cube texture
  7666. * @param rootUrl defines the url where the files to load is located
  7667. * @param scene defines the current scene
  7668. * @param files defines the list of files to load (1 per face)
  7669. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7670. * @param onLoad defines an optional callback raised when the texture is loaded
  7671. * @param onError defines an optional callback raised if there is an issue to load the texture
  7672. * @param format defines the format of the data
  7673. * @param forcedExtension defines the extension to use to pick the right loader
  7674. * @returns the cube texture as an InternalTexture
  7675. */
  7676. 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): InternalTexture;
  7677. private setCubeMapTextureParams(gl, loadMipmap);
  7678. /**
  7679. * Update a raw cube texture
  7680. * @param texture defines the texture to udpdate
  7681. * @param data defines the data to store
  7682. * @param format defines the data format
  7683. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  7684. * @param invertY defines if data must be stored with Y axis inverted
  7685. * @param compression defines the compression used (null by default)
  7686. * @param level defines which level of the texture to update
  7687. */
  7688. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  7689. /**
  7690. * Creates a new raw cube texture
  7691. * @param data defines the array of data to use to create each face
  7692. * @param size defines the size of the textures
  7693. * @param format defines the format of the data
  7694. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  7695. * @param generateMipMaps defines if the engine should generate the mip levels
  7696. * @param invertY defines if data must be stored with Y axis inverted
  7697. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  7698. * @param compression defines the compression used (null by default)
  7699. * @returns the cube texture as an InternalTexture
  7700. */
  7701. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  7702. /**
  7703. * Creates a new raw cube texture from a specified url
  7704. * @param url defines the url where the data is located
  7705. * @param scene defines the current scene
  7706. * @param size defines the size of the textures
  7707. * @param format defines the format of the data
  7708. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  7709. * @param noMipmap defines if the engine should avoid generating the mip levels
  7710. * @param callback defines a callback used to extract texture data from loaded data
  7711. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  7712. * @param onLoad defines a callback called when texture is loaded
  7713. * @param onError defines a callback called if there is an error
  7714. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  7715. * @param invertY defines if data must be stored with Y axis inverted
  7716. * @returns the cube texture as an InternalTexture
  7717. */
  7718. 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;
  7719. /**
  7720. * Update a raw 3D texture
  7721. * @param texture defines the texture to update
  7722. * @param data defines the data to store
  7723. * @param format defines the data format
  7724. * @param invertY defines if data must be stored with Y axis inverted
  7725. * @param compression defines the used compression (can be null)
  7726. */
  7727. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>): void;
  7728. /**
  7729. * Creates a new raw 3D texture
  7730. * @param data defines the data used to create the texture
  7731. * @param width defines the width of the texture
  7732. * @param height defines the height of the texture
  7733. * @param depth defines the depth of the texture
  7734. * @param format defines the format of the texture
  7735. * @param generateMipMaps defines if the engine must generate mip levels
  7736. * @param invertY defines if data must be stored with Y axis inverted
  7737. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  7738. * @param compression defines the compressed used (can be null)
  7739. * @returns a new raw 3D texture (stored in an InternalTexture)
  7740. */
  7741. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  7742. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  7743. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  7744. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  7745. /** @ignore */
  7746. _releaseFramebufferObjects(texture: InternalTexture): void;
  7747. /** @ignore */
  7748. _releaseTexture(texture: InternalTexture): void;
  7749. private setProgram(program);
  7750. private _boundUniforms;
  7751. /**
  7752. * Binds an effect to the webGL context
  7753. * @param effect defines the effect to bind
  7754. */
  7755. bindSamplers(effect: Effect): void;
  7756. private _moveBoundTextureOnTop(internalTexture);
  7757. private _getCorrectTextureChannel(channel, internalTexture);
  7758. private _linkTrackers(previous, next);
  7759. private _removeDesignatedSlot(internalTexture);
  7760. private _activateCurrentTexture();
  7761. /** @ignore */
  7762. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): void;
  7763. /** @ignore */
  7764. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  7765. /**
  7766. * Sets a texture to the webGL context from a postprocess
  7767. * @param channel defines the channel to use
  7768. * @param postProcess defines the source postprocess
  7769. */
  7770. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  7771. /**
  7772. * Binds the output of the passed in post process to the texture channel specified
  7773. * @param channel The channel the texture should be bound to
  7774. * @param postProcess The post process which's output should be bound
  7775. */
  7776. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  7777. /**
  7778. * Unbind all textures from the webGL context
  7779. */
  7780. unbindAllTextures(): void;
  7781. /**
  7782. * Sets a texture to the according uniform.
  7783. * @param channel The texture channel
  7784. * @param uniform The uniform to set
  7785. * @param texture The texture to apply
  7786. */
  7787. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  7788. /**
  7789. * Sets a depth stencil texture from a render target to the according uniform.
  7790. * @param channel The texture channel
  7791. * @param uniform The uniform to set
  7792. * @param texture The render target texture containing the depth stencil texture to apply
  7793. */
  7794. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  7795. private _bindSamplerUniformToChannel(sourceSlot, destination);
  7796. private _getTextureWrapMode(mode);
  7797. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  7798. /**
  7799. * Sets an array of texture to the webGL context
  7800. * @param channel defines the channel where the texture array must be set
  7801. * @param uniform defines the associated uniform location
  7802. * @param textures defines the array of textures to bind
  7803. */
  7804. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  7805. /** @ignore */
  7806. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  7807. private _setTextureParameterFloat(target, parameter, value, texture);
  7808. private _setTextureParameterInteger(target, parameter, value, texture?);
  7809. /**
  7810. * Reads pixels from the current frame buffer. Please note that this function can be slow
  7811. * @param x defines the x coordinate of the rectangle where pixels must be read
  7812. * @param y defines the y coordinate of the rectangle where pixels must be read
  7813. * @param width defines the width of the rectangle where pixels must be read
  7814. * @param height defines the height of the rectangle where pixels must be read
  7815. * @returns a Uint8Array containing RGBA colors
  7816. */
  7817. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  7818. /**
  7819. * Add an externaly attached data from its key.
  7820. * This method call will fail and return false, if such key already exists.
  7821. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  7822. * @param key the unique key that identifies the data
  7823. * @param data the data object to associate to the key for this Engine instance
  7824. * @return true if no such key were already present and the data was added successfully, false otherwise
  7825. */
  7826. addExternalData<T>(key: string, data: T): boolean;
  7827. /**
  7828. * Get an externaly attached data from its key
  7829. * @param key the unique key that identifies the data
  7830. * @return the associated data, if present (can be null), or undefined if not present
  7831. */
  7832. getExternalData<T>(key: string): T;
  7833. /**
  7834. * Get an externaly attached data from its key, create it using a factory if it's not already present
  7835. * @param key the unique key that identifies the data
  7836. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  7837. * @return the associated data, can be null if the factory returned null.
  7838. */
  7839. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  7840. /**
  7841. * Remove an externaly attached data from the Engine instance
  7842. * @param key the unique key that identifies the data
  7843. * @return true if the data was successfully removed, false if it doesn't exist
  7844. */
  7845. removeExternalData(key: string): boolean;
  7846. /**
  7847. * Unbind all vertex attributes from the webGL context
  7848. */
  7849. unbindAllAttributes(): void;
  7850. /**
  7851. * 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
  7852. */
  7853. releaseEffects(): void;
  7854. /**
  7855. * Dispose and release all associated resources
  7856. */
  7857. dispose(): void;
  7858. /**
  7859. * Display the loading screen
  7860. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7861. */
  7862. displayLoadingUI(): void;
  7863. /**
  7864. * Hide the loading screen
  7865. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7866. */
  7867. hideLoadingUI(): void;
  7868. /**
  7869. * Gets the current loading screen object
  7870. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7871. */
  7872. /**
  7873. * Sets the current loading screen object
  7874. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7875. */
  7876. loadingScreen: ILoadingScreen;
  7877. /**
  7878. * Sets the current loading screen text
  7879. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7880. */
  7881. loadingUIText: string;
  7882. /**
  7883. * Sets the current loading screen background color
  7884. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7885. */
  7886. loadingUIBackgroundColor: string;
  7887. /**
  7888. * Attach a new callback raised when context lost event is fired
  7889. * @param callback defines the callback to call
  7890. */
  7891. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  7892. /**
  7893. * Attach a new callback raised when context restored event is fired
  7894. * @param callback defines the callback to call
  7895. */
  7896. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  7897. /**
  7898. * Gets the source code of the vertex shader associated with a specific webGL program
  7899. * @param program defines the program to use
  7900. * @returns a string containing the source code of the vertex shader associated with the program
  7901. */
  7902. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  7903. /**
  7904. * Gets the source code of the fragment shader associated with a specific webGL program
  7905. * @param program defines the program to use
  7906. * @returns a string containing the source code of the fragment shader associated with the program
  7907. */
  7908. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  7909. /**
  7910. * Get the current error code of the webGL context
  7911. * @returns the error code
  7912. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  7913. */
  7914. getError(): number;
  7915. /**
  7916. * Gets the current framerate
  7917. * @returns a number representing the framerate
  7918. */
  7919. getFps(): number;
  7920. /**
  7921. * Gets the time spent between current and previous frame
  7922. * @returns a number representing the delta time in ms
  7923. */
  7924. getDeltaTime(): number;
  7925. private _measureFps();
  7926. /** @ignore */
  7927. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number): ArrayBufferView;
  7928. private _canRenderToFloatFramebuffer();
  7929. private _canRenderToHalfFloatFramebuffer();
  7930. private _canRenderToFramebuffer(type);
  7931. /** @ignore */
  7932. _getWebGLTextureType(type: number): number;
  7933. private _getInternalFormat(format);
  7934. /** @ignore */
  7935. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  7936. /** @ignore */
  7937. _getRGBAMultiSampleBufferFormat(type: number): number;
  7938. /**
  7939. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  7940. * @return the new query
  7941. */
  7942. createQuery(): WebGLQuery;
  7943. /**
  7944. * Delete and release a webGL query
  7945. * @param query defines the query to delete
  7946. * @return the current engine
  7947. */
  7948. deleteQuery(query: WebGLQuery): Engine;
  7949. /**
  7950. * Check if a given query has resolved and got its value
  7951. * @param query defines the query to check
  7952. * @returns true if the query got its value
  7953. */
  7954. isQueryResultAvailable(query: WebGLQuery): boolean;
  7955. /**
  7956. * Gets the value of a given query
  7957. * @param query defines the query to check
  7958. * @returns the value of the query
  7959. */
  7960. getQueryResult(query: WebGLQuery): number;
  7961. /**
  7962. * Initiates an occlusion query
  7963. * @param algorithmType defines the algorithm to use
  7964. * @param query defines the query to use
  7965. * @returns the current engine
  7966. * @see http://doc.babylonjs.com/features/occlusionquery
  7967. */
  7968. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  7969. /**
  7970. * Ends an occlusion query
  7971. * @see http://doc.babylonjs.com/features/occlusionquery
  7972. * @param algorithmType defines the algorithm to use
  7973. * @returns the current engine
  7974. */
  7975. endOcclusionQuery(algorithmType: number): Engine;
  7976. private _createTimeQuery();
  7977. private _deleteTimeQuery(query);
  7978. private _getTimeQueryResult(query);
  7979. private _getTimeQueryAvailability(query);
  7980. private _currentNonTimestampToken;
  7981. /**
  7982. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  7983. * Please note that only one query can be issued at a time
  7984. * @returns a time token used to track the time span
  7985. */
  7986. startTimeQuery(): Nullable<_TimeToken>;
  7987. /**
  7988. * Ends a time query
  7989. * @param token defines the token used to measure the time span
  7990. * @returns the time spent (in ns)
  7991. */
  7992. endTimeQuery(token: _TimeToken): int;
  7993. private getGlAlgorithmType(algorithmType);
  7994. /**
  7995. * Creates a webGL transform feedback object
  7996. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  7997. * @returns the webGL transform feedback object
  7998. */
  7999. createTransformFeedback(): WebGLTransformFeedback;
  8000. /**
  8001. * Delete a webGL transform feedback object
  8002. * @param value defines the webGL transform feedback object to delete
  8003. */
  8004. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  8005. /**
  8006. * Bind a webGL transform feedback object to the webgl context
  8007. * @param value defines the webGL transform feedback object to bind
  8008. */
  8009. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  8010. /**
  8011. * Begins a transform feedback operation
  8012. * @param usePoints defines if points or triangles must be used
  8013. */
  8014. beginTransformFeedback(usePoints?: boolean): void;
  8015. /**
  8016. * Ends a transform feedback operation
  8017. */
  8018. endTransformFeedback(): void;
  8019. /**
  8020. * Specify the varyings to use with transform feedback
  8021. * @param program defines the associated webGL program
  8022. * @param value defines the list of strings representing the varying names
  8023. */
  8024. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  8025. /**
  8026. * Bind a webGL buffer for a transform feedback operation
  8027. * @param value defines the webGL buffer to bind
  8028. */
  8029. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  8030. /** @ignore */
  8031. _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;
  8032. /** @ignore */
  8033. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  8034. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  8035. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  8036. /**
  8037. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  8038. * @returns true if the engine can be created
  8039. * @ignoreNaming
  8040. */
  8041. static isSupported(): boolean;
  8042. }
  8043. }
  8044. declare module BABYLON {
  8045. class NullEngineOptions {
  8046. renderWidth: number;
  8047. renderHeight: number;
  8048. textureSize: number;
  8049. deterministicLockstep: boolean;
  8050. lockstepMaxSteps: number;
  8051. }
  8052. /**
  8053. * The null engine class provides support for headless version of babylon.js.
  8054. * This can be used in server side scenario or for testing purposes
  8055. */
  8056. class NullEngine extends Engine {
  8057. private _options;
  8058. isDeterministicLockStep(): boolean;
  8059. getLockstepMaxSteps(): number;
  8060. getHardwareScalingLevel(): number;
  8061. constructor(options?: NullEngineOptions);
  8062. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8063. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  8064. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8065. getRenderWidth(useScreen?: boolean): number;
  8066. getRenderHeight(useScreen?: boolean): number;
  8067. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8068. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  8069. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  8070. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8071. bindSamplers(effect: Effect): void;
  8072. enableEffect(effect: Effect): void;
  8073. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8074. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  8075. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  8076. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  8077. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  8078. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  8079. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  8080. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  8081. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  8082. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  8083. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  8084. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  8085. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  8086. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  8087. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  8088. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8089. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8090. setFloat(uniform: WebGLUniformLocation, value: number): void;
  8091. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  8092. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  8093. setBool(uniform: WebGLUniformLocation, bool: number): void;
  8094. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  8095. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  8096. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  8097. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8098. bindBuffers(vertexBuffers: {
  8099. [key: string]: VertexBuffer;
  8100. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  8101. wipeCaches(bruteForce?: boolean): void;
  8102. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8103. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8104. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8105. _createTexture(): WebGLTexture;
  8106. _releaseTexture(texture: InternalTexture): void;
  8107. 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;
  8108. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8109. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8110. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  8111. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8112. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8113. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8114. /**
  8115. * Updates a dynamic vertex buffer.
  8116. * @param vertexBuffer the vertex buffer to update
  8117. * @param data the data used to update the vertex buffer
  8118. * @param byteOffset the byte offset of the data (optional)
  8119. * @param byteLength the byte length of the data (optional)
  8120. */
  8121. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  8122. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  8123. _bindTexture(channel: number, texture: InternalTexture): void;
  8124. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8125. }
  8126. }
  8127. interface WebGLRenderingContext {
  8128. readonly RASTERIZER_DISCARD: number;
  8129. readonly DEPTH_COMPONENT24: number;
  8130. readonly TEXTURE_3D: number;
  8131. readonly TEXTURE_2D_ARRAY: number;
  8132. readonly TEXTURE_COMPARE_FUNC: number;
  8133. readonly TEXTURE_COMPARE_MODE: number;
  8134. readonly COMPARE_REF_TO_TEXTURE: number;
  8135. readonly TEXTURE_WRAP_R: number;
  8136. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  8137. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  8138. 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;
  8139. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  8140. readonly TRANSFORM_FEEDBACK: number;
  8141. readonly INTERLEAVED_ATTRIBS: number;
  8142. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  8143. createTransformFeedback(): WebGLTransformFeedback;
  8144. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  8145. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  8146. beginTransformFeedback(primitiveMode: number): void;
  8147. endTransformFeedback(): void;
  8148. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  8149. }
  8150. interface ImageBitmap {
  8151. readonly width: number;
  8152. readonly height: number;
  8153. close(): void;
  8154. }
  8155. interface WebGLQuery extends WebGLObject {
  8156. }
  8157. declare var WebGLQuery: {
  8158. prototype: WebGLQuery;
  8159. new (): WebGLQuery;
  8160. };
  8161. interface WebGLSampler extends WebGLObject {
  8162. }
  8163. declare var WebGLSampler: {
  8164. prototype: WebGLSampler;
  8165. new (): WebGLSampler;
  8166. };
  8167. interface WebGLSync extends WebGLObject {
  8168. }
  8169. declare var WebGLSync: {
  8170. prototype: WebGLSync;
  8171. new (): WebGLSync;
  8172. };
  8173. interface WebGLTransformFeedback extends WebGLObject {
  8174. }
  8175. declare var WebGLTransformFeedback: {
  8176. prototype: WebGLTransformFeedback;
  8177. new (): WebGLTransformFeedback;
  8178. };
  8179. interface WebGLVertexArrayObject extends WebGLObject {
  8180. }
  8181. declare var WebGLVertexArrayObject: {
  8182. prototype: WebGLVertexArrayObject;
  8183. new (): WebGLVertexArrayObject;
  8184. };
  8185. declare module BABYLON {
  8186. class KeyboardEventTypes {
  8187. static _KEYDOWN: number;
  8188. static _KEYUP: number;
  8189. static readonly KEYDOWN: number;
  8190. static readonly KEYUP: number;
  8191. }
  8192. class KeyboardInfo {
  8193. type: number;
  8194. event: KeyboardEvent;
  8195. constructor(type: number, event: KeyboardEvent);
  8196. }
  8197. /**
  8198. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8199. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8200. */
  8201. class KeyboardInfoPre extends KeyboardInfo {
  8202. constructor(type: number, event: KeyboardEvent);
  8203. skipOnPointerObservable: boolean;
  8204. }
  8205. }
  8206. declare module BABYLON {
  8207. class PointerEventTypes {
  8208. static _POINTERDOWN: number;
  8209. static _POINTERUP: number;
  8210. static _POINTERMOVE: number;
  8211. static _POINTERWHEEL: number;
  8212. static _POINTERPICK: number;
  8213. static _POINTERTAP: number;
  8214. static _POINTERDOUBLETAP: number;
  8215. static readonly POINTERDOWN: number;
  8216. static readonly POINTERUP: number;
  8217. static readonly POINTERMOVE: number;
  8218. static readonly POINTERWHEEL: number;
  8219. static readonly POINTERPICK: number;
  8220. static readonly POINTERTAP: number;
  8221. static readonly POINTERDOUBLETAP: number;
  8222. }
  8223. class PointerInfoBase {
  8224. type: number;
  8225. event: PointerEvent | MouseWheelEvent;
  8226. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  8227. }
  8228. /**
  8229. * This class is used to store pointer related info for the onPrePointerObservable event.
  8230. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  8231. */
  8232. class PointerInfoPre extends PointerInfoBase {
  8233. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  8234. localPosition: Vector2;
  8235. skipOnPointerObservable: boolean;
  8236. }
  8237. /**
  8238. * This type contains all the data related to a pointer event in Babylon.js.
  8239. * 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.
  8240. */
  8241. class PointerInfo extends PointerInfoBase {
  8242. pickInfo: Nullable<PickingInfo>;
  8243. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  8244. }
  8245. }
  8246. declare module BABYLON {
  8247. /**
  8248. * Represents the different options available during the creation of
  8249. * a Environment helper.
  8250. *
  8251. * This can control the default ground, skybox and image processing setup of your scene.
  8252. */
  8253. interface IEnvironmentHelperOptions {
  8254. /**
  8255. * Specifies wether or not to create a ground.
  8256. * True by default.
  8257. */
  8258. createGround: boolean;
  8259. /**
  8260. * Specifies the ground size.
  8261. * 15 by default.
  8262. */
  8263. groundSize: number;
  8264. /**
  8265. * The texture used on the ground for the main color.
  8266. * Comes from the BabylonJS CDN by default.
  8267. *
  8268. * Remarks: Can be either a texture or a url.
  8269. */
  8270. groundTexture: string | BaseTexture;
  8271. /**
  8272. * The color mixed in the ground texture by default.
  8273. * BabylonJS clearColor by default.
  8274. */
  8275. groundColor: Color3;
  8276. /**
  8277. * Specifies the ground opacity.
  8278. * 1 by default.
  8279. */
  8280. groundOpacity: number;
  8281. /**
  8282. * Enables the ground to receive shadows.
  8283. * True by default.
  8284. */
  8285. enableGroundShadow: boolean;
  8286. /**
  8287. * Helps preventing the shadow to be fully black on the ground.
  8288. * 0.5 by default.
  8289. */
  8290. groundShadowLevel: number;
  8291. /**
  8292. * Creates a mirror texture attach to the ground.
  8293. * false by default.
  8294. */
  8295. enableGroundMirror: boolean;
  8296. /**
  8297. * Specifies the ground mirror size ratio.
  8298. * 0.3 by default as the default kernel is 64.
  8299. */
  8300. groundMirrorSizeRatio: number;
  8301. /**
  8302. * Specifies the ground mirror blur kernel size.
  8303. * 64 by default.
  8304. */
  8305. groundMirrorBlurKernel: number;
  8306. /**
  8307. * Specifies the ground mirror visibility amount.
  8308. * 1 by default
  8309. */
  8310. groundMirrorAmount: number;
  8311. /**
  8312. * Specifies the ground mirror reflectance weight.
  8313. * This uses the standard weight of the background material to setup the fresnel effect
  8314. * of the mirror.
  8315. * 1 by default.
  8316. */
  8317. groundMirrorFresnelWeight: number;
  8318. /**
  8319. * Specifies the ground mirror Falloff distance.
  8320. * This can helps reducing the size of the reflection.
  8321. * 0 by Default.
  8322. */
  8323. groundMirrorFallOffDistance: number;
  8324. /**
  8325. * Specifies the ground mirror texture type.
  8326. * Unsigned Int by Default.
  8327. */
  8328. groundMirrorTextureType: number;
  8329. /**
  8330. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  8331. * the shown objects.
  8332. */
  8333. groundYBias: number;
  8334. /**
  8335. * Specifies wether or not to create a skybox.
  8336. * True by default.
  8337. */
  8338. createSkybox: boolean;
  8339. /**
  8340. * Specifies the skybox size.
  8341. * 20 by default.
  8342. */
  8343. skyboxSize: number;
  8344. /**
  8345. * The texture used on the skybox for the main color.
  8346. * Comes from the BabylonJS CDN by default.
  8347. *
  8348. * Remarks: Can be either a texture or a url.
  8349. */
  8350. skyboxTexture: string | BaseTexture;
  8351. /**
  8352. * The color mixed in the skybox texture by default.
  8353. * BabylonJS clearColor by default.
  8354. */
  8355. skyboxColor: Color3;
  8356. /**
  8357. * The background rotation around the Y axis of the scene.
  8358. * This helps aligning the key lights of your scene with the background.
  8359. * 0 by default.
  8360. */
  8361. backgroundYRotation: number;
  8362. /**
  8363. * Compute automatically the size of the elements to best fit with the scene.
  8364. */
  8365. sizeAuto: boolean;
  8366. /**
  8367. * Default position of the rootMesh if autoSize is not true.
  8368. */
  8369. rootPosition: Vector3;
  8370. /**
  8371. * Sets up the image processing in the scene.
  8372. * true by default.
  8373. */
  8374. setupImageProcessing: boolean;
  8375. /**
  8376. * The texture used as your environment texture in the scene.
  8377. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  8378. *
  8379. * Remarks: Can be either a texture or a url.
  8380. */
  8381. environmentTexture: string | BaseTexture;
  8382. /**
  8383. * The value of the exposure to apply to the scene.
  8384. * 0.6 by default if setupImageProcessing is true.
  8385. */
  8386. cameraExposure: number;
  8387. /**
  8388. * The value of the contrast to apply to the scene.
  8389. * 1.6 by default if setupImageProcessing is true.
  8390. */
  8391. cameraContrast: number;
  8392. /**
  8393. * Specifies wether or not tonemapping should be enabled in the scene.
  8394. * true by default if setupImageProcessing is true.
  8395. */
  8396. toneMappingEnabled: boolean;
  8397. }
  8398. /**
  8399. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  8400. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  8401. * It also helps with the default setup of your imageProcessing configuration.
  8402. */
  8403. class EnvironmentHelper {
  8404. /**
  8405. * Default ground texture URL.
  8406. */
  8407. private static _groundTextureCDNUrl;
  8408. /**
  8409. * Default skybox texture URL.
  8410. */
  8411. private static _skyboxTextureCDNUrl;
  8412. /**
  8413. * Default environment texture URL.
  8414. */
  8415. private static _environmentTextureCDNUrl;
  8416. /**
  8417. * Creates the default options for the helper.
  8418. */
  8419. private static _getDefaultOptions();
  8420. private _rootMesh;
  8421. /**
  8422. * Gets the root mesh created by the helper.
  8423. */
  8424. readonly rootMesh: Mesh;
  8425. private _skybox;
  8426. /**
  8427. * Gets the skybox created by the helper.
  8428. */
  8429. readonly skybox: Nullable<Mesh>;
  8430. private _skyboxTexture;
  8431. /**
  8432. * Gets the skybox texture created by the helper.
  8433. */
  8434. readonly skyboxTexture: Nullable<BaseTexture>;
  8435. private _skyboxMaterial;
  8436. /**
  8437. * Gets the skybox material created by the helper.
  8438. */
  8439. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  8440. private _ground;
  8441. /**
  8442. * Gets the ground mesh created by the helper.
  8443. */
  8444. readonly ground: Nullable<Mesh>;
  8445. private _groundTexture;
  8446. /**
  8447. * Gets the ground texture created by the helper.
  8448. */
  8449. readonly groundTexture: Nullable<BaseTexture>;
  8450. private _groundMirror;
  8451. /**
  8452. * Gets the ground mirror created by the helper.
  8453. */
  8454. readonly groundMirror: Nullable<MirrorTexture>;
  8455. /**
  8456. * Gets the ground mirror render list to helps pushing the meshes
  8457. * you wish in the ground reflection.
  8458. */
  8459. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  8460. private _groundMaterial;
  8461. /**
  8462. * Gets the ground material created by the helper.
  8463. */
  8464. readonly groundMaterial: Nullable<BackgroundMaterial>;
  8465. /**
  8466. * Stores the creation options.
  8467. */
  8468. private readonly _scene;
  8469. private _options;
  8470. /**
  8471. * This observable will be notified with any error during the creation of the environment,
  8472. * mainly texture creation errors.
  8473. */
  8474. onErrorObservable: Observable<{
  8475. message?: string;
  8476. exception?: any;
  8477. }>;
  8478. /**
  8479. * constructor
  8480. * @param options
  8481. * @param scene The scene to add the material to
  8482. */
  8483. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  8484. /**
  8485. * Updates the background according to the new options
  8486. * @param options
  8487. */
  8488. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  8489. /**
  8490. * Sets the primary color of all the available elements.
  8491. * @param color the main color to affect to the ground and the background
  8492. * @param perceptual Specifies wether the chosen color has been set as intented to be seen e.g. in gamma space not accounting for exposure and tone mapping
  8493. */
  8494. setMainColor(color: Color3, perceptual?: boolean): void;
  8495. /**
  8496. * Setup the image processing according to the specified options.
  8497. */
  8498. private _setupImageProcessing();
  8499. /**
  8500. * Setup the environment texture according to the specified options.
  8501. */
  8502. private _setupEnvironmentTexture();
  8503. /**
  8504. * Setup the background according to the specified options.
  8505. */
  8506. private _setupBackground();
  8507. /**
  8508. * Get the scene sizes according to the setup.
  8509. */
  8510. private _getSceneSize();
  8511. /**
  8512. * Setup the ground according to the specified options.
  8513. */
  8514. private _setupGround(sceneSize);
  8515. /**
  8516. * Setup the ground material according to the specified options.
  8517. */
  8518. private _setupGroundMaterial();
  8519. /**
  8520. * Setup the ground diffuse texture according to the specified options.
  8521. */
  8522. private _setupGroundDiffuseTexture();
  8523. /**
  8524. * Setup the ground mirror texture according to the specified options.
  8525. */
  8526. private _setupGroundMirrorTexture(sceneSize);
  8527. /**
  8528. * Setup the ground to receive the mirror texture.
  8529. */
  8530. private _setupMirrorInGroundMaterial();
  8531. /**
  8532. * Setup the skybox according to the specified options.
  8533. */
  8534. private _setupSkybox(sceneSize);
  8535. /**
  8536. * Setup the skybox material according to the specified options.
  8537. */
  8538. private _setupSkyboxMaterial();
  8539. /**
  8540. * Setup the skybox reflection texture according to the specified options.
  8541. */
  8542. private _setupSkyboxReflectionTexture();
  8543. private _errorHandler;
  8544. /**
  8545. * Dispose all the elements created by the Helper.
  8546. */
  8547. dispose(): void;
  8548. }
  8549. }
  8550. declare module BABYLON {
  8551. /**
  8552. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  8553. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  8554. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  8555. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  8556. */
  8557. class VideoDome extends Node {
  8558. /**
  8559. * The video texture being displayed on the sphere
  8560. */
  8561. protected _videoTexture: VideoTexture;
  8562. /**
  8563. * The skybox material
  8564. */
  8565. protected _material: BackgroundMaterial;
  8566. /**
  8567. * The surface used for the skybox
  8568. */
  8569. protected _mesh: Mesh;
  8570. /**
  8571. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  8572. * Also see the options.resolution property.
  8573. */
  8574. fovMultiplier: number;
  8575. /**
  8576. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  8577. * @param name Element's name, child elements will append suffixes for their own names.
  8578. * @param urlsOrVideo
  8579. * @param options An object containing optional or exposed sub element properties:
  8580. * @param options **resolution=12** Integer, lower resolutions have more artifacts at extreme fovs
  8581. * @param options **clickToPlay=false** Add a click to play listener to the video, does not prevent autoplay.
  8582. * @param options **autoPlay=true** Automatically attempt to being playing the video.
  8583. * @param options **loop=true** Automatically loop video on end.
  8584. * @param options **size=1000** Physical radius to create the dome at, defaults to approximately half the far clip plane.
  8585. */
  8586. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  8587. resolution?: number;
  8588. clickToPlay?: boolean;
  8589. autoPlay?: boolean;
  8590. loop?: boolean;
  8591. size?: number;
  8592. }, scene: Scene);
  8593. /**
  8594. * Releases resources associated with this node.
  8595. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8596. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8597. */
  8598. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8599. }
  8600. }
  8601. declare module BABYLON {
  8602. class StickValues {
  8603. x: number;
  8604. y: number;
  8605. constructor(x: number, y: number);
  8606. }
  8607. interface GamepadButtonChanges {
  8608. changed: boolean;
  8609. pressChanged: boolean;
  8610. touchChanged: boolean;
  8611. valueChanged: boolean;
  8612. }
  8613. class Gamepad {
  8614. id: string;
  8615. index: number;
  8616. browserGamepad: any;
  8617. type: number;
  8618. private _leftStick;
  8619. private _rightStick;
  8620. _isConnected: boolean;
  8621. private _leftStickAxisX;
  8622. private _leftStickAxisY;
  8623. private _rightStickAxisX;
  8624. private _rightStickAxisY;
  8625. private _onleftstickchanged;
  8626. private _onrightstickchanged;
  8627. static GAMEPAD: number;
  8628. static GENERIC: number;
  8629. static XBOX: number;
  8630. static POSE_ENABLED: number;
  8631. protected _invertLeftStickY: boolean;
  8632. readonly isConnected: boolean;
  8633. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  8634. onleftstickchanged(callback: (values: StickValues) => void): void;
  8635. onrightstickchanged(callback: (values: StickValues) => void): void;
  8636. leftStick: StickValues;
  8637. rightStick: StickValues;
  8638. update(): void;
  8639. dispose(): void;
  8640. }
  8641. class GenericPad extends Gamepad {
  8642. private _buttons;
  8643. private _onbuttondown;
  8644. private _onbuttonup;
  8645. onButtonDownObservable: Observable<number>;
  8646. onButtonUpObservable: Observable<number>;
  8647. onbuttondown(callback: (buttonPressed: number) => void): void;
  8648. onbuttonup(callback: (buttonReleased: number) => void): void;
  8649. constructor(id: string, index: number, browserGamepad: any);
  8650. private _setButtonValue(newValue, currentValue, buttonIndex);
  8651. update(): void;
  8652. dispose(): void;
  8653. }
  8654. }
  8655. declare module BABYLON {
  8656. class GamepadManager {
  8657. private _scene;
  8658. private _babylonGamepads;
  8659. private _oneGamepadConnected;
  8660. _isMonitoring: boolean;
  8661. private _gamepadEventSupported;
  8662. private _gamepadSupport;
  8663. onGamepadConnectedObservable: Observable<Gamepad>;
  8664. onGamepadDisconnectedObservable: Observable<Gamepad>;
  8665. private _onGamepadConnectedEvent;
  8666. private _onGamepadDisconnectedEvent;
  8667. constructor(_scene?: Scene | undefined);
  8668. readonly gamepads: Gamepad[];
  8669. getGamepadByType(type?: number): Nullable<Gamepad>;
  8670. dispose(): void;
  8671. private _addNewGamepad(gamepad);
  8672. private _startMonitoringGamepads();
  8673. private _stopMonitoringGamepads();
  8674. _checkGamepadsStatus(): void;
  8675. private _updateGamepadObjects();
  8676. }
  8677. }
  8678. declare module BABYLON {
  8679. enum Xbox360Button {
  8680. A = 0,
  8681. B = 1,
  8682. X = 2,
  8683. Y = 3,
  8684. Start = 4,
  8685. Back = 5,
  8686. LB = 6,
  8687. RB = 7,
  8688. LeftStick = 8,
  8689. RightStick = 9,
  8690. }
  8691. enum Xbox360Dpad {
  8692. Up = 0,
  8693. Down = 1,
  8694. Left = 2,
  8695. Right = 3,
  8696. }
  8697. class Xbox360Pad extends Gamepad {
  8698. private _leftTrigger;
  8699. private _rightTrigger;
  8700. private _onlefttriggerchanged;
  8701. private _onrighttriggerchanged;
  8702. private _onbuttondown;
  8703. private _onbuttonup;
  8704. private _ondpaddown;
  8705. private _ondpadup;
  8706. onButtonDownObservable: Observable<Xbox360Button>;
  8707. onButtonUpObservable: Observable<Xbox360Button>;
  8708. onPadDownObservable: Observable<Xbox360Dpad>;
  8709. onPadUpObservable: Observable<Xbox360Dpad>;
  8710. private _buttonA;
  8711. private _buttonB;
  8712. private _buttonX;
  8713. private _buttonY;
  8714. private _buttonBack;
  8715. private _buttonStart;
  8716. private _buttonLB;
  8717. private _buttonRB;
  8718. private _buttonLeftStick;
  8719. private _buttonRightStick;
  8720. private _dPadUp;
  8721. private _dPadDown;
  8722. private _dPadLeft;
  8723. private _dPadRight;
  8724. private _isXboxOnePad;
  8725. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  8726. onlefttriggerchanged(callback: (value: number) => void): void;
  8727. onrighttriggerchanged(callback: (value: number) => void): void;
  8728. leftTrigger: number;
  8729. rightTrigger: number;
  8730. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  8731. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  8732. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  8733. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  8734. private _setButtonValue(newValue, currentValue, buttonType);
  8735. private _setDPadValue(newValue, currentValue, buttonType);
  8736. buttonA: number;
  8737. buttonB: number;
  8738. buttonX: number;
  8739. buttonY: number;
  8740. buttonStart: number;
  8741. buttonBack: number;
  8742. buttonLB: number;
  8743. buttonRB: number;
  8744. buttonLeftStick: number;
  8745. buttonRightStick: number;
  8746. dPadUp: number;
  8747. dPadDown: number;
  8748. dPadLeft: number;
  8749. dPadRight: number;
  8750. update(): void;
  8751. dispose(): void;
  8752. }
  8753. }
  8754. declare module BABYLON {
  8755. /**
  8756. * This class can be used to get instrumentation data from a Babylon engine
  8757. */
  8758. class EngineInstrumentation implements IDisposable {
  8759. engine: Engine;
  8760. private _captureGPUFrameTime;
  8761. private _gpuFrameTimeToken;
  8762. private _gpuFrameTime;
  8763. private _captureShaderCompilationTime;
  8764. private _shaderCompilationTime;
  8765. private _onBeginFrameObserver;
  8766. private _onEndFrameObserver;
  8767. private _onBeforeShaderCompilationObserver;
  8768. private _onAfterShaderCompilationObserver;
  8769. /**
  8770. * Gets the perf counter used for GPU frame time
  8771. */
  8772. readonly gpuFrameTimeCounter: PerfCounter;
  8773. /**
  8774. * Gets the GPU frame time capture status
  8775. */
  8776. /**
  8777. * Enable or disable the GPU frame time capture
  8778. */
  8779. captureGPUFrameTime: boolean;
  8780. /**
  8781. * Gets the perf counter used for shader compilation time
  8782. */
  8783. readonly shaderCompilationTimeCounter: PerfCounter;
  8784. /**
  8785. * Gets the shader compilation time capture status
  8786. */
  8787. /**
  8788. * Enable or disable the shader compilation time capture
  8789. */
  8790. captureShaderCompilationTime: boolean;
  8791. constructor(engine: Engine);
  8792. dispose(): void;
  8793. }
  8794. }
  8795. declare module BABYLON {
  8796. /**
  8797. * This class can be used to get instrumentation data from a Babylon engine
  8798. */
  8799. class SceneInstrumentation implements IDisposable {
  8800. scene: Scene;
  8801. private _captureActiveMeshesEvaluationTime;
  8802. private _activeMeshesEvaluationTime;
  8803. private _captureRenderTargetsRenderTime;
  8804. private _renderTargetsRenderTime;
  8805. private _captureFrameTime;
  8806. private _frameTime;
  8807. private _captureRenderTime;
  8808. private _renderTime;
  8809. private _captureInterFrameTime;
  8810. private _interFrameTime;
  8811. private _captureParticlesRenderTime;
  8812. private _particlesRenderTime;
  8813. private _captureSpritesRenderTime;
  8814. private _spritesRenderTime;
  8815. private _capturePhysicsTime;
  8816. private _physicsTime;
  8817. private _captureAnimationsTime;
  8818. private _animationsTime;
  8819. private _onBeforeActiveMeshesEvaluationObserver;
  8820. private _onAfterActiveMeshesEvaluationObserver;
  8821. private _onBeforeRenderTargetsRenderObserver;
  8822. private _onAfterRenderTargetsRenderObserver;
  8823. private _onAfterRenderObserver;
  8824. private _onBeforeDrawPhaseObserver;
  8825. private _onAfterDrawPhaseObserver;
  8826. private _onBeforeAnimationsObserver;
  8827. private _onBeforeParticlesRenderingObserver;
  8828. private _onAfterParticlesRenderingObserver;
  8829. private _onBeforeSpritesRenderingObserver;
  8830. private _onAfterSpritesRenderingObserver;
  8831. private _onBeforePhysicsObserver;
  8832. private _onAfterPhysicsObserver;
  8833. private _onAfterAnimationsObserver;
  8834. /**
  8835. * Gets the perf counter used for active meshes evaluation time
  8836. */
  8837. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  8838. /**
  8839. * Gets the active meshes evaluation time capture status
  8840. */
  8841. /**
  8842. * Enable or disable the active meshes evaluation time capture
  8843. */
  8844. captureActiveMeshesEvaluationTime: boolean;
  8845. /**
  8846. * Gets the perf counter used for render targets render time
  8847. */
  8848. readonly renderTargetsRenderTimeCounter: PerfCounter;
  8849. /**
  8850. * Gets the render targets render time capture status
  8851. */
  8852. /**
  8853. * Enable or disable the render targets render time capture
  8854. */
  8855. captureRenderTargetsRenderTime: boolean;
  8856. /**
  8857. * Gets the perf counter used for particles render time
  8858. */
  8859. readonly particlesRenderTimeCounter: PerfCounter;
  8860. /**
  8861. * Gets the particles render time capture status
  8862. */
  8863. /**
  8864. * Enable or disable the particles render time capture
  8865. */
  8866. captureParticlesRenderTime: boolean;
  8867. /**
  8868. * Gets the perf counter used for sprites render time
  8869. */
  8870. readonly spritesRenderTimeCounter: PerfCounter;
  8871. /**
  8872. * Gets the sprites render time capture status
  8873. */
  8874. /**
  8875. * Enable or disable the sprites render time capture
  8876. */
  8877. captureSpritesRenderTime: boolean;
  8878. /**
  8879. * Gets the perf counter used for physics time
  8880. */
  8881. readonly physicsTimeCounter: PerfCounter;
  8882. /**
  8883. * Gets the physics time capture status
  8884. */
  8885. /**
  8886. * Enable or disable the physics time capture
  8887. */
  8888. capturePhysicsTime: boolean;
  8889. /**
  8890. * Gets the perf counter used for animations time
  8891. */
  8892. readonly animationsTimeCounter: PerfCounter;
  8893. /**
  8894. * Gets the animations time capture status
  8895. */
  8896. /**
  8897. * Enable or disable the animations time capture
  8898. */
  8899. captureAnimationsTime: boolean;
  8900. /**
  8901. * Gets the perf counter used for frame time capture
  8902. */
  8903. readonly frameTimeCounter: PerfCounter;
  8904. /**
  8905. * Gets the frame time capture status
  8906. */
  8907. /**
  8908. * Enable or disable the frame time capture
  8909. */
  8910. captureFrameTime: boolean;
  8911. /**
  8912. * Gets the perf counter used for inter-frames time capture
  8913. */
  8914. readonly interFrameTimeCounter: PerfCounter;
  8915. /**
  8916. * Gets the inter-frames time capture status
  8917. */
  8918. /**
  8919. * Enable or disable the inter-frames time capture
  8920. */
  8921. captureInterFrameTime: boolean;
  8922. /**
  8923. * Gets the perf counter used for render time capture
  8924. */
  8925. readonly renderTimeCounter: PerfCounter;
  8926. /**
  8927. * Gets the render time capture status
  8928. */
  8929. /**
  8930. * Enable or disable the render time capture
  8931. */
  8932. captureRenderTime: boolean;
  8933. /**
  8934. * Gets the perf counter used for draw calls
  8935. */
  8936. readonly drawCallsCounter: PerfCounter;
  8937. /**
  8938. * Gets the perf counter used for texture collisions
  8939. */
  8940. readonly textureCollisionsCounter: PerfCounter;
  8941. constructor(scene: Scene);
  8942. dispose(): void;
  8943. }
  8944. }
  8945. declare module BABYLON {
  8946. class _TimeToken {
  8947. _startTimeQuery: Nullable<WebGLQuery>;
  8948. _endTimeQuery: Nullable<WebGLQuery>;
  8949. _timeElapsedQuery: Nullable<WebGLQuery>;
  8950. _timeElapsedQueryEnded: boolean;
  8951. }
  8952. }
  8953. declare module BABYLON {
  8954. /**
  8955. * Effect layer options. This helps customizing the behaviour
  8956. * of the effect layer.
  8957. */
  8958. interface IEffectLayerOptions {
  8959. /**
  8960. * Multiplication factor apply to the canvas size to compute the render target size
  8961. * used to generated the objects (the smaller the faster).
  8962. */
  8963. mainTextureRatio: number;
  8964. /**
  8965. * Enforces a fixed size texture to ensure effect stability across devices.
  8966. */
  8967. mainTextureFixedSize?: number;
  8968. /**
  8969. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  8970. */
  8971. alphaBlendingMode: number;
  8972. /**
  8973. * The camera attached to the layer.
  8974. */
  8975. camera: Nullable<Camera>;
  8976. }
  8977. /**
  8978. * The effect layer Helps adding post process effect blended with the main pass.
  8979. *
  8980. * This can be for instance use to generate glow or higlight effects on the scene.
  8981. *
  8982. * The effect layer class can not be used directly and is intented to inherited from to be
  8983. * customized per effects.
  8984. */
  8985. abstract class EffectLayer {
  8986. private _vertexBuffers;
  8987. private _indexBuffer;
  8988. private _cachedDefines;
  8989. private _effectLayerMapGenerationEffect;
  8990. private _effectLayerOptions;
  8991. private _mergeEffect;
  8992. protected _scene: Scene;
  8993. protected _engine: Engine;
  8994. protected _maxSize: number;
  8995. protected _mainTextureDesiredSize: ISize;
  8996. protected _mainTexture: RenderTargetTexture;
  8997. protected _shouldRender: boolean;
  8998. protected _postProcesses: PostProcess[];
  8999. protected _textures: BaseTexture[];
  9000. protected _emissiveTextureAndColor: {
  9001. texture: Nullable<BaseTexture>;
  9002. color: Color4;
  9003. };
  9004. /**
  9005. * The name of the layer
  9006. */
  9007. name: string;
  9008. /**
  9009. * The clear color of the texture used to generate the glow map.
  9010. */
  9011. neutralColor: Color4;
  9012. /**
  9013. * Specifies wether the highlight layer is enabled or not.
  9014. */
  9015. isEnabled: boolean;
  9016. /**
  9017. * Gets the camera attached to the layer.
  9018. */
  9019. readonly camera: Nullable<Camera>;
  9020. /**
  9021. * An event triggered when the effect layer has been disposed.
  9022. */
  9023. onDisposeObservable: Observable<EffectLayer>;
  9024. /**
  9025. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  9026. */
  9027. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  9028. /**
  9029. * An event triggered when the generated texture is being merged in the scene.
  9030. */
  9031. onBeforeComposeObservable: Observable<EffectLayer>;
  9032. /**
  9033. * An event triggered when the generated texture has been merged in the scene.
  9034. */
  9035. onAfterComposeObservable: Observable<EffectLayer>;
  9036. /**
  9037. * An event triggered when the efffect layer changes its size.
  9038. */
  9039. onSizeChangedObservable: Observable<EffectLayer>;
  9040. /**
  9041. * Instantiates a new effect Layer and references it in the scene.
  9042. * @param name The name of the layer
  9043. * @param scene The scene to use the layer in
  9044. */
  9045. constructor(
  9046. /** The Friendly of the effect in the scene */
  9047. name: string, scene: Scene);
  9048. /**
  9049. * Get the effect name of the layer.
  9050. * @return The effect name
  9051. */
  9052. abstract getEffectName(): string;
  9053. /**
  9054. * Checks for the readiness of the element composing the layer.
  9055. * @param subMesh the mesh to check for
  9056. * @param useInstances specify wether or not to use instances to render the mesh
  9057. * @return true if ready otherwise, false
  9058. */
  9059. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9060. /**
  9061. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  9062. * @returns true if the effect requires stencil during the main canvas render pass.
  9063. */
  9064. abstract needStencil(): boolean;
  9065. /**
  9066. * Create the merge effect. This is the shader use to blit the information back
  9067. * to the main canvas at the end of the scene rendering.
  9068. * @returns The effect containing the shader used to merge the effect on the main canvas
  9069. */
  9070. protected abstract _createMergeEffect(): Effect;
  9071. /**
  9072. * Creates the render target textures and post processes used in the effect layer.
  9073. */
  9074. protected abstract _createTextureAndPostProcesses(): void;
  9075. /**
  9076. * Implementation specific of rendering the generating effect on the main canvas.
  9077. * @param effect The effect used to render through
  9078. */
  9079. protected abstract _internalRender(effect: Effect): void;
  9080. /**
  9081. * Sets the required values for both the emissive texture and and the main color.
  9082. */
  9083. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  9084. /**
  9085. * Free any resources and references associated to a mesh.
  9086. * Internal use
  9087. * @param mesh The mesh to free.
  9088. */
  9089. abstract _disposeMesh(mesh: Mesh): void;
  9090. /**
  9091. * Serializes this layer (Glow or Highlight for example)
  9092. * @returns a serialized layer object
  9093. */
  9094. abstract serialize?(): any;
  9095. /**
  9096. * Initializes the effect layer with the required options.
  9097. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  9098. */
  9099. protected _init(options: Partial<IEffectLayerOptions>): void;
  9100. /**
  9101. * Generates the index buffer of the full screen quad blending to the main canvas.
  9102. */
  9103. private _generateIndexBuffer();
  9104. /**
  9105. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  9106. */
  9107. private _genrateVertexBuffer();
  9108. /**
  9109. * Sets the main texture desired size which is the closest power of two
  9110. * of the engine canvas size.
  9111. */
  9112. private _setMainTextureSize();
  9113. /**
  9114. * Creates the main texture for the effect layer.
  9115. */
  9116. protected _createMainTexture(): void;
  9117. /**
  9118. * Checks for the readiness of the element composing the layer.
  9119. * @param subMesh the mesh to check for
  9120. * @param useInstances specify wether or not to use instances to render the mesh
  9121. * @param emissiveTexture the associated emissive texture used to generate the glow
  9122. * @return true if ready otherwise, false
  9123. */
  9124. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  9125. /**
  9126. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  9127. */
  9128. render(): void;
  9129. /**
  9130. * Determine if a given mesh will be used in the current effect.
  9131. * @param mesh mesh to test
  9132. * @returns true if the mesh will be used
  9133. */
  9134. hasMesh(mesh: AbstractMesh): boolean;
  9135. /**
  9136. * Returns true if the layer contains information to display, otherwise false.
  9137. * @returns true if the glow layer should be rendered
  9138. */
  9139. shouldRender(): boolean;
  9140. /**
  9141. * Returns true if the mesh should render, otherwise false.
  9142. * @param mesh The mesh to render
  9143. * @returns true if it should render otherwise false
  9144. */
  9145. protected _shouldRenderMesh(mesh: Mesh): boolean;
  9146. /**
  9147. * Returns true if the mesh should render, otherwise false.
  9148. * @param mesh The mesh to render
  9149. * @returns true if it should render otherwise false
  9150. */
  9151. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  9152. /**
  9153. * Renders the submesh passed in parameter to the generation map.
  9154. */
  9155. protected _renderSubMesh(subMesh: SubMesh): void;
  9156. /**
  9157. * Rebuild the required buffers.
  9158. * @ignore Internal use only.
  9159. */
  9160. _rebuild(): void;
  9161. /**
  9162. * Dispose only the render target textures and post process.
  9163. */
  9164. private _disposeTextureAndPostProcesses();
  9165. /**
  9166. * Dispose the highlight layer and free resources.
  9167. */
  9168. dispose(): void;
  9169. /**
  9170. * Gets the class name of the effect layer
  9171. * @returns the string with the class name of the effect layer
  9172. */
  9173. getClassName(): string;
  9174. /**
  9175. * Creates an effect layer from parsed effect layer data
  9176. * @param parsedEffectLayer defines effect layer data
  9177. * @param scene defines the current scene
  9178. * @param rootUrl defines the root URL containing the effect layer information
  9179. * @returns a parsed effect Layer
  9180. */
  9181. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  9182. }
  9183. }
  9184. declare module BABYLON {
  9185. /**
  9186. * Glow layer options. This helps customizing the behaviour
  9187. * of the glow layer.
  9188. */
  9189. interface IGlowLayerOptions {
  9190. /**
  9191. * Multiplication factor apply to the canvas size to compute the render target size
  9192. * used to generated the glowing objects (the smaller the faster).
  9193. */
  9194. mainTextureRatio: number;
  9195. /**
  9196. * Enforces a fixed size texture to ensure resize independant blur.
  9197. */
  9198. mainTextureFixedSize?: number;
  9199. /**
  9200. * How big is the kernel of the blur texture.
  9201. */
  9202. blurKernelSize: number;
  9203. /**
  9204. * The camera attached to the layer.
  9205. */
  9206. camera: Nullable<Camera>;
  9207. /**
  9208. * Enable MSAA by chosing the number of samples.
  9209. */
  9210. mainTextureSamples?: number;
  9211. }
  9212. /**
  9213. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  9214. *
  9215. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  9216. * glowy meshes to your scene.
  9217. *
  9218. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  9219. */
  9220. class GlowLayer extends EffectLayer {
  9221. /**
  9222. * Effect Name of the layer.
  9223. */
  9224. static readonly EffectName: string;
  9225. /**
  9226. * The default blur kernel size used for the glow.
  9227. */
  9228. static DefaultBlurKernelSize: number;
  9229. /**
  9230. * The default texture size ratio used for the glow.
  9231. */
  9232. static DefaultTextureRatio: number;
  9233. /**
  9234. * Gets the kernel size of the blur.
  9235. */
  9236. /**
  9237. * Sets the kernel size of the blur.
  9238. */
  9239. blurKernelSize: number;
  9240. /**
  9241. * Gets the glow intensity.
  9242. */
  9243. /**
  9244. * Sets the glow intensity.
  9245. */
  9246. intensity: number;
  9247. private _options;
  9248. private _intensity;
  9249. private _horizontalBlurPostprocess1;
  9250. private _verticalBlurPostprocess1;
  9251. private _horizontalBlurPostprocess2;
  9252. private _verticalBlurPostprocess2;
  9253. private _blurTexture1;
  9254. private _blurTexture2;
  9255. private _postProcesses1;
  9256. private _postProcesses2;
  9257. private _includedOnlyMeshes;
  9258. private _excludedMeshes;
  9259. /**
  9260. * Callback used to let the user override the color selection on a per mesh basis
  9261. */
  9262. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  9263. /**
  9264. * Callback used to let the user override the texture selection on a per mesh basis
  9265. */
  9266. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  9267. /**
  9268. * Instantiates a new glow Layer and references it to the scene.
  9269. * @param name The name of the layer
  9270. * @param scene The scene to use the layer in
  9271. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  9272. */
  9273. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  9274. /**
  9275. * Get the effect name of the layer.
  9276. * @return The effect name
  9277. */
  9278. getEffectName(): string;
  9279. /**
  9280. * Create the merge effect. This is the shader use to blit the information back
  9281. * to the main canvas at the end of the scene rendering.
  9282. */
  9283. protected _createMergeEffect(): Effect;
  9284. /**
  9285. * Creates the render target textures and post processes used in the glow layer.
  9286. */
  9287. protected _createTextureAndPostProcesses(): void;
  9288. /**
  9289. * Checks for the readiness of the element composing the layer.
  9290. * @param subMesh the mesh to check for
  9291. * @param useInstances specify wether or not to use instances to render the mesh
  9292. * @param emissiveTexture the associated emissive texture used to generate the glow
  9293. * @return true if ready otherwise, false
  9294. */
  9295. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9296. /**
  9297. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  9298. */
  9299. needStencil(): boolean;
  9300. /**
  9301. * Implementation specific of rendering the generating effect on the main canvas.
  9302. * @param effect The effect used to render through
  9303. */
  9304. protected _internalRender(effect: Effect): void;
  9305. /**
  9306. * Sets the required values for both the emissive texture and and the main color.
  9307. */
  9308. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  9309. /**
  9310. * Returns true if the mesh should render, otherwise false.
  9311. * @param mesh The mesh to render
  9312. * @returns true if it should render otherwise false
  9313. */
  9314. protected _shouldRenderMesh(mesh: Mesh): boolean;
  9315. /**
  9316. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  9317. * @param mesh The mesh to exclude from the glow layer
  9318. */
  9319. addExcludedMesh(mesh: Mesh): void;
  9320. /**
  9321. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  9322. * @param mesh The mesh to remove
  9323. */
  9324. removeExcludedMesh(mesh: Mesh): void;
  9325. /**
  9326. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  9327. * @param mesh The mesh to include in the glow layer
  9328. */
  9329. addIncludedOnlyMesh(mesh: Mesh): void;
  9330. /**
  9331. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  9332. * @param mesh The mesh to remove
  9333. */
  9334. removeIncludedOnlyMesh(mesh: Mesh): void;
  9335. /**
  9336. * Determine if a given mesh will be used in the glow layer
  9337. * @param mesh The mesh to test
  9338. * @returns true if the mesh will be highlighted by the current glow layer
  9339. */
  9340. hasMesh(mesh: AbstractMesh): boolean;
  9341. /**
  9342. * Free any resources and references associated to a mesh.
  9343. * Internal use
  9344. * @param mesh The mesh to free.
  9345. */
  9346. _disposeMesh(mesh: Mesh): void;
  9347. /**
  9348. * Gets the class name of the effect layer
  9349. * @returns the string with the class name of the effect layer
  9350. */
  9351. getClassName(): string;
  9352. /**
  9353. * Serializes this glow layer
  9354. * @returns a serialized glow layer object
  9355. */
  9356. serialize(): any;
  9357. /**
  9358. * Creates a Glow Layer from parsed glow layer data
  9359. * @param parsedGlowLayer defines glow layer data
  9360. * @param scene defines the current scene
  9361. * @param rootUrl defines the root URL containing the glow layer information
  9362. * @returns a parsed Glow Layer
  9363. */
  9364. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  9365. }
  9366. }
  9367. declare module BABYLON {
  9368. /**
  9369. * Highlight layer options. This helps customizing the behaviour
  9370. * of the highlight layer.
  9371. */
  9372. interface IHighlightLayerOptions {
  9373. /**
  9374. * Multiplication factor apply to the canvas size to compute the render target size
  9375. * used to generated the glowing objects (the smaller the faster).
  9376. */
  9377. mainTextureRatio: number;
  9378. /**
  9379. * Enforces a fixed size texture to ensure resize independant blur.
  9380. */
  9381. mainTextureFixedSize?: number;
  9382. /**
  9383. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  9384. * of the picture to blur (the smaller the faster).
  9385. */
  9386. blurTextureSizeRatio: number;
  9387. /**
  9388. * How big in texel of the blur texture is the vertical blur.
  9389. */
  9390. blurVerticalSize: number;
  9391. /**
  9392. * How big in texel of the blur texture is the horizontal blur.
  9393. */
  9394. blurHorizontalSize: number;
  9395. /**
  9396. * Alpha blending mode used to apply the blur. Default is combine.
  9397. */
  9398. alphaBlendingMode: number;
  9399. /**
  9400. * The camera attached to the layer.
  9401. */
  9402. camera: Nullable<Camera>;
  9403. /**
  9404. * Should we display highlight as a solid stroke?
  9405. */
  9406. isStroke?: boolean;
  9407. }
  9408. /**
  9409. * The highlight layer Helps adding a glow effect around a mesh.
  9410. *
  9411. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  9412. * glowy meshes to your scene.
  9413. *
  9414. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  9415. */
  9416. class HighlightLayer extends EffectLayer {
  9417. name: string;
  9418. /**
  9419. * Effect Name of the highlight layer.
  9420. */
  9421. static readonly EffectName: string;
  9422. /**
  9423. * The neutral color used during the preparation of the glow effect.
  9424. * This is black by default as the blend operation is a blend operation.
  9425. */
  9426. static NeutralColor: Color4;
  9427. /**
  9428. * Stencil value used for glowing meshes.
  9429. */
  9430. static GlowingMeshStencilReference: number;
  9431. /**
  9432. * Stencil value used for the other meshes in the scene.
  9433. */
  9434. static NormalMeshStencilReference: number;
  9435. /**
  9436. * Specifies whether or not the inner glow is ACTIVE in the layer.
  9437. */
  9438. innerGlow: boolean;
  9439. /**
  9440. * Specifies whether or not the outer glow is ACTIVE in the layer.
  9441. */
  9442. outerGlow: boolean;
  9443. /**
  9444. * Gets the horizontal size of the blur.
  9445. */
  9446. /**
  9447. * Specifies the horizontal size of the blur.
  9448. */
  9449. blurHorizontalSize: number;
  9450. /**
  9451. * Gets the vertical size of the blur.
  9452. */
  9453. /**
  9454. * Specifies the vertical size of the blur.
  9455. */
  9456. blurVerticalSize: number;
  9457. /**
  9458. * An event triggered when the highlight layer is being blurred.
  9459. */
  9460. onBeforeBlurObservable: Observable<HighlightLayer>;
  9461. /**
  9462. * An event triggered when the highlight layer has been blurred.
  9463. */
  9464. onAfterBlurObservable: Observable<HighlightLayer>;
  9465. private _instanceGlowingMeshStencilReference;
  9466. private _options;
  9467. private _downSamplePostprocess;
  9468. private _horizontalBlurPostprocess;
  9469. private _verticalBlurPostprocess;
  9470. private _blurTexture;
  9471. private _meshes;
  9472. private _excludedMeshes;
  9473. /**
  9474. * Instantiates a new highlight Layer and references it to the scene..
  9475. * @param name The name of the layer
  9476. * @param scene The scene to use the layer in
  9477. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  9478. */
  9479. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  9480. /**
  9481. * Get the effect name of the layer.
  9482. * @return The effect name
  9483. */
  9484. getEffectName(): string;
  9485. /**
  9486. * Create the merge effect. This is the shader use to blit the information back
  9487. * to the main canvas at the end of the scene rendering.
  9488. */
  9489. protected _createMergeEffect(): Effect;
  9490. /**
  9491. * Creates the render target textures and post processes used in the highlight layer.
  9492. */
  9493. protected _createTextureAndPostProcesses(): void;
  9494. /**
  9495. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  9496. */
  9497. needStencil(): boolean;
  9498. /**
  9499. * Checks for the readiness of the element composing the layer.
  9500. * @param subMesh the mesh to check for
  9501. * @param useInstances specify wether or not to use instances to render the mesh
  9502. * @param emissiveTexture the associated emissive texture used to generate the glow
  9503. * @return true if ready otherwise, false
  9504. */
  9505. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9506. /**
  9507. * Implementation specific of rendering the generating effect on the main canvas.
  9508. * @param effect The effect used to render through
  9509. */
  9510. protected _internalRender(effect: Effect): void;
  9511. /**
  9512. * Returns true if the layer contains information to display, otherwise false.
  9513. */
  9514. shouldRender(): boolean;
  9515. /**
  9516. * Returns true if the mesh should render, otherwise false.
  9517. * @param mesh The mesh to render
  9518. * @returns true if it should render otherwise false
  9519. */
  9520. protected _shouldRenderMesh(mesh: Mesh): boolean;
  9521. /**
  9522. * Sets the required values for both the emissive texture and and the main color.
  9523. */
  9524. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  9525. /**
  9526. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  9527. * @param mesh The mesh to exclude from the highlight layer
  9528. */
  9529. addExcludedMesh(mesh: Mesh): void;
  9530. /**
  9531. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  9532. * @param mesh The mesh to highlight
  9533. */
  9534. removeExcludedMesh(mesh: Mesh): void;
  9535. /**
  9536. * Determine if a given mesh will be highlighted by the current HighlightLayer
  9537. * @param mesh mesh to test
  9538. * @returns true if the mesh will be highlighted by the current HighlightLayer
  9539. */
  9540. hasMesh(mesh: AbstractMesh): boolean;
  9541. /**
  9542. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  9543. * @param mesh The mesh to highlight
  9544. * @param color The color of the highlight
  9545. * @param glowEmissiveOnly Extract the glow from the emissive texture
  9546. */
  9547. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  9548. /**
  9549. * Remove a mesh from the highlight layer in order to make it stop glowing.
  9550. * @param mesh The mesh to highlight
  9551. */
  9552. removeMesh(mesh: Mesh): void;
  9553. /**
  9554. * Force the stencil to the normal expected value for none glowing parts
  9555. */
  9556. private _defaultStencilReference(mesh);
  9557. /**
  9558. * Free any resources and references associated to a mesh.
  9559. * Internal use
  9560. * @param mesh The mesh to free.
  9561. */
  9562. _disposeMesh(mesh: Mesh): void;
  9563. /**
  9564. * Dispose the highlight layer and free resources.
  9565. */
  9566. dispose(): void;
  9567. /**
  9568. * Gets the class name of the effect layer
  9569. * @returns the string with the class name of the effect layer
  9570. */
  9571. getClassName(): string;
  9572. /**
  9573. * Serializes this Highlight layer
  9574. * @returns a serialized Highlight layer object
  9575. */
  9576. serialize(): any;
  9577. /**
  9578. * Creates a Highlight layer from parsed Highlight layer data
  9579. * @param parsedHightlightLayer defines the Highlight layer data
  9580. * @param scene defines the current scene
  9581. * @param rootUrl defines the root URL containing the Highlight layer information
  9582. * @returns a parsed Highlight layer
  9583. */
  9584. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  9585. }
  9586. }
  9587. declare module BABYLON {
  9588. class Layer {
  9589. name: string;
  9590. texture: Nullable<Texture>;
  9591. isBackground: boolean;
  9592. color: Color4;
  9593. scale: Vector2;
  9594. offset: Vector2;
  9595. alphaBlendingMode: number;
  9596. alphaTest: boolean;
  9597. layerMask: number;
  9598. private _scene;
  9599. private _vertexBuffers;
  9600. private _indexBuffer;
  9601. private _effect;
  9602. private _alphaTestEffect;
  9603. /**
  9604. * An event triggered when the layer is disposed.
  9605. */
  9606. onDisposeObservable: Observable<Layer>;
  9607. private _onDisposeObserver;
  9608. onDispose: () => void;
  9609. /**
  9610. * An event triggered before rendering the scene
  9611. */
  9612. onBeforeRenderObservable: Observable<Layer>;
  9613. private _onBeforeRenderObserver;
  9614. onBeforeRender: () => void;
  9615. /**
  9616. * An event triggered after rendering the scene
  9617. */
  9618. onAfterRenderObservable: Observable<Layer>;
  9619. private _onAfterRenderObserver;
  9620. onAfterRender: () => void;
  9621. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  9622. private _createIndexBuffer();
  9623. _rebuild(): void;
  9624. render(): void;
  9625. dispose(): void;
  9626. }
  9627. }
  9628. declare module BABYLON {
  9629. interface ILoadingScreen {
  9630. displayLoadingUI: () => void;
  9631. hideLoadingUI: () => void;
  9632. loadingUIBackgroundColor: string;
  9633. loadingUIText: string;
  9634. }
  9635. class DefaultLoadingScreen implements ILoadingScreen {
  9636. private _renderingCanvas;
  9637. private _loadingText;
  9638. private _loadingDivBackgroundColor;
  9639. private _loadingDiv;
  9640. private _loadingTextDiv;
  9641. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  9642. displayLoadingUI(): void;
  9643. hideLoadingUI(): void;
  9644. loadingUIText: string;
  9645. loadingUIBackgroundColor: string;
  9646. private _resizeLoadingUI;
  9647. }
  9648. }
  9649. declare module BABYLON {
  9650. class SceneLoaderProgressEvent {
  9651. readonly lengthComputable: boolean;
  9652. readonly loaded: number;
  9653. readonly total: number;
  9654. constructor(lengthComputable: boolean, loaded: number, total: number);
  9655. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  9656. }
  9657. interface ISceneLoaderPluginExtensions {
  9658. [extension: string]: {
  9659. isBinary: boolean;
  9660. };
  9661. }
  9662. interface ISceneLoaderPluginFactory {
  9663. name: string;
  9664. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  9665. canDirectLoad?: (data: string) => boolean;
  9666. }
  9667. interface ISceneLoaderPlugin {
  9668. /**
  9669. * The friendly name of this plugin.
  9670. */
  9671. name: string;
  9672. /**
  9673. * The file extensions supported by this plugin.
  9674. */
  9675. extensions: string | ISceneLoaderPluginExtensions;
  9676. /**
  9677. * Import meshes into a scene.
  9678. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  9679. * @param scene The scene to import into
  9680. * @param data The data to import
  9681. * @param rootUrl The root url for scene and resources
  9682. * @param meshes The meshes array to import into
  9683. * @param particleSystems The particle systems array to import into
  9684. * @param skeletons The skeletons array to import into
  9685. * @param onError The callback when import fails
  9686. * @returns True if successful or false otherwise
  9687. */
  9688. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  9689. /**
  9690. * Load into a scene.
  9691. * @param scene The scene to load into
  9692. * @param data The data to import
  9693. * @param rootUrl The root url for scene and resources
  9694. * @param onError The callback when import fails
  9695. * @returns true if successful or false otherwise
  9696. */
  9697. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  9698. /**
  9699. * The callback that returns true if the data can be directly loaded.
  9700. */
  9701. canDirectLoad?: (data: string) => boolean;
  9702. /**
  9703. * The callback that allows custom handling of the root url based on the response url.
  9704. */
  9705. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  9706. /**
  9707. * Load into an asset container.
  9708. * @param scene The scene to load into
  9709. * @param data The data to import
  9710. * @param rootUrl The root url for scene and resources
  9711. * @param onError The callback when import fails
  9712. * @returns The loaded asset container
  9713. */
  9714. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  9715. }
  9716. interface ISceneLoaderPluginAsync {
  9717. /**
  9718. * The friendly name of this plugin.
  9719. */
  9720. name: string;
  9721. /**
  9722. * The file extensions supported by this plugin.
  9723. */
  9724. extensions: string | ISceneLoaderPluginExtensions;
  9725. /**
  9726. * Import meshes into a scene.
  9727. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  9728. * @param scene The scene to import into
  9729. * @param data The data to import
  9730. * @param rootUrl The root url for scene and resources
  9731. * @param onProgress The callback when the load progresses
  9732. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  9733. */
  9734. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  9735. meshes: AbstractMesh[];
  9736. particleSystems: ParticleSystem[];
  9737. skeletons: Skeleton[];
  9738. animationGroups: AnimationGroup[];
  9739. }>;
  9740. /**
  9741. * Load into a scene.
  9742. * @param scene The scene to load into
  9743. * @param data The data to import
  9744. * @param rootUrl The root url for scene and resources
  9745. * @param onProgress The callback when the load progresses
  9746. * @returns Nothing
  9747. */
  9748. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  9749. /**
  9750. * The callback that returns true if the data can be directly loaded.
  9751. */
  9752. canDirectLoad?: (data: string) => boolean;
  9753. /**
  9754. * The callback that allows custom handling of the root url based on the response url.
  9755. */
  9756. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  9757. /**
  9758. * Load into an asset container.
  9759. * @param scene The scene to load into
  9760. * @param data The data to import
  9761. * @param rootUrl The root url for scene and resources
  9762. * @param onProgress The callback when the load progresses
  9763. * @returns The loaded asset container
  9764. */
  9765. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  9766. }
  9767. class SceneLoader {
  9768. private static _ForceFullSceneLoadingForIncremental;
  9769. private static _ShowLoadingScreen;
  9770. private static _CleanBoneMatrixWeights;
  9771. static readonly NO_LOGGING: number;
  9772. static readonly MINIMAL_LOGGING: number;
  9773. static readonly SUMMARY_LOGGING: number;
  9774. static readonly DETAILED_LOGGING: number;
  9775. private static _loggingLevel;
  9776. static ForceFullSceneLoadingForIncremental: boolean;
  9777. static ShowLoadingScreen: boolean;
  9778. static loggingLevel: number;
  9779. static CleanBoneMatrixWeights: boolean;
  9780. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  9781. private static _registeredPlugins;
  9782. private static _getDefaultPlugin();
  9783. private static _getPluginForExtension(extension);
  9784. private static _getPluginForDirectLoad(data);
  9785. private static _getPluginForFilename(sceneFilename);
  9786. private static _getDirectLoad(sceneFilename);
  9787. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  9788. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  9789. static IsPluginForExtensionAvailable(extension: string): boolean;
  9790. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  9791. /**
  9792. * Import meshes into a scene
  9793. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  9794. * @param rootUrl a string that defines the root url for scene and resources
  9795. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  9796. * @param scene the instance of BABYLON.Scene to append to
  9797. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  9798. * @param onProgress a callback with a progress event for each file being loaded
  9799. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  9800. * @param pluginExtension the extension used to determine the plugin
  9801. * @returns The loaded plugin
  9802. */
  9803. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: ParticleSystem[], 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>;
  9804. /**
  9805. * Import meshes into a scene
  9806. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  9807. * @param rootUrl a string that defines the root url for scene and resources
  9808. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  9809. * @param scene the instance of BABYLON.Scene to append to
  9810. * @param onProgress a callback with a progress event for each file being loaded
  9811. * @param pluginExtension the extension used to determine the plugin
  9812. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  9813. */
  9814. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  9815. meshes: AbstractMesh[];
  9816. particleSystems: ParticleSystem[];
  9817. skeletons: Skeleton[];
  9818. animationGroups: AnimationGroup[];
  9819. }>;
  9820. /**
  9821. * Load a scene
  9822. * @param rootUrl a string that defines the root url for scene and resources
  9823. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  9824. * @param engine is the instance of BABYLON.Engine to use to create the scene
  9825. * @param onSuccess a callback with the scene when import succeeds
  9826. * @param onProgress a callback with a progress event for each file being loaded
  9827. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  9828. * @param pluginExtension the extension used to determine the plugin
  9829. * @returns The loaded plugin
  9830. */
  9831. static Load(rootUrl: string, sceneFilename: any, engine: Engine, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  9832. /**
  9833. * Load a scene
  9834. * @param rootUrl a string that defines the root url for scene and resources
  9835. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  9836. * @param engine is the instance of BABYLON.Engine to use to create the scene
  9837. * @param onProgress a callback with a progress event for each file being loaded
  9838. * @param pluginExtension the extension used to determine the plugin
  9839. * @returns The loaded scene
  9840. */
  9841. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  9842. /**
  9843. * Append a scene
  9844. * @param rootUrl a string that defines the root url for scene and resources
  9845. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  9846. * @param scene is the instance of BABYLON.Scene to append to
  9847. * @param onSuccess a callback with the scene when import succeeds
  9848. * @param onProgress a callback with a progress event for each file being loaded
  9849. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  9850. * @param pluginExtension the extension used to determine the plugin
  9851. * @returns The loaded plugin
  9852. */
  9853. static Append(rootUrl: string, sceneFilename: any, scene: 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>;
  9854. /**
  9855. * Append a scene
  9856. * @param rootUrl a string that defines the root url for scene and resources
  9857. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  9858. * @param scene is the instance of BABYLON.Scene to append to
  9859. * @param onProgress a callback with a progress event for each file being loaded
  9860. * @param pluginExtension the extension used to determine the plugin
  9861. * @returns The given scene
  9862. */
  9863. static AppendAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  9864. /**
  9865. * Load a scene into an asset container
  9866. * @param rootUrl a string that defines the root url for scene and resources
  9867. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  9868. * @param scene is the instance of BABYLON.Scene to append to
  9869. * @param onSuccess a callback with the scene when import succeeds
  9870. * @param onProgress a callback with a progress event for each file being loaded
  9871. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  9872. * @param pluginExtension the extension used to determine the plugin
  9873. * @returns The loaded plugin
  9874. */
  9875. static LoadAssetContainer(rootUrl: string, sceneFilename: any, scene: 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>;
  9876. /**
  9877. * Load a scene into an asset container
  9878. * @param rootUrl a string that defines the root url for scene and resources
  9879. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  9880. * @param scene is the instance of BABYLON.Scene to append to
  9881. * @param onProgress a callback with a progress event for each file being loaded
  9882. * @param pluginExtension the extension used to determine the plugin
  9883. * @returns The loaded asset container
  9884. */
  9885. static LoadAssetContainerAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  9886. }
  9887. }
  9888. declare module BABYLON {
  9889. class LensFlare {
  9890. size: number;
  9891. position: number;
  9892. color: Color3;
  9893. texture: Nullable<Texture>;
  9894. alphaMode: number;
  9895. private _system;
  9896. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  9897. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  9898. dispose(): void;
  9899. }
  9900. }
  9901. declare module BABYLON {
  9902. class LensFlareSystem {
  9903. name: string;
  9904. lensFlares: LensFlare[];
  9905. borderLimit: number;
  9906. viewportBorder: number;
  9907. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  9908. layerMask: number;
  9909. id: string;
  9910. private _scene;
  9911. private _emitter;
  9912. private _vertexBuffers;
  9913. private _indexBuffer;
  9914. private _effect;
  9915. private _positionX;
  9916. private _positionY;
  9917. private _isEnabled;
  9918. constructor(name: string, emitter: any, scene: Scene);
  9919. isEnabled: boolean;
  9920. getScene(): Scene;
  9921. getEmitter(): any;
  9922. setEmitter(newEmitter: any): void;
  9923. getEmitterPosition(): Vector3;
  9924. computeEffectivePosition(globalViewport: Viewport): boolean;
  9925. _isVisible(): boolean;
  9926. render(): boolean;
  9927. dispose(): void;
  9928. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  9929. serialize(): any;
  9930. }
  9931. }
  9932. declare module BABYLON {
  9933. /**
  9934. * A directional light is defined by a direction (what a surprise!).
  9935. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  9936. * 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.
  9937. * Documentation: https://doc.babylonjs.com/babylon101/lights
  9938. */
  9939. class DirectionalLight extends ShadowLight {
  9940. private _shadowFrustumSize;
  9941. /**
  9942. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  9943. */
  9944. /**
  9945. * Specifies a fix frustum size for the shadow generation.
  9946. */
  9947. shadowFrustumSize: number;
  9948. private _shadowOrthoScale;
  9949. /**
  9950. * Gets the shadow projection scale against the optimal computed one.
  9951. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  9952. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  9953. */
  9954. /**
  9955. * Sets the shadow projection scale against the optimal computed one.
  9956. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  9957. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  9958. */
  9959. shadowOrthoScale: number;
  9960. /**
  9961. * Automatically compute the projection matrix to best fit (including all the casters)
  9962. * on each frame.
  9963. */
  9964. autoUpdateExtends: boolean;
  9965. private _orthoLeft;
  9966. private _orthoRight;
  9967. private _orthoTop;
  9968. private _orthoBottom;
  9969. /**
  9970. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  9971. * The directional light is emitted from everywhere in the given direction.
  9972. * It can cast shawdows.
  9973. * Documentation : http://doc.babylonjs.com/tutorials/lights
  9974. * @param name The friendly name of the light
  9975. * @param direction The direction of the light
  9976. * @param scene The scene the light belongs to
  9977. */
  9978. constructor(name: string, direction: Vector3, scene: Scene);
  9979. /**
  9980. * Returns the string "DirectionalLight".
  9981. * @return The class name
  9982. */
  9983. getClassName(): string;
  9984. /**
  9985. * Returns the integer 1.
  9986. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9987. */
  9988. getTypeID(): number;
  9989. /**
  9990. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  9991. * Returns the DirectionalLight Shadow projection matrix.
  9992. */
  9993. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9994. /**
  9995. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  9996. * Returns the DirectionalLight Shadow projection matrix.
  9997. */
  9998. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  9999. /**
  10000. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  10001. * Returns the DirectionalLight Shadow projection matrix.
  10002. */
  10003. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10004. protected _buildUniformLayout(): void;
  10005. /**
  10006. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  10007. * @param effect The effect to update
  10008. * @param lightIndex The index of the light in the effect to update
  10009. * @returns The directional light
  10010. */
  10011. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  10012. /**
  10013. * Gets the minZ used for shadow according to both the scene and the light.
  10014. *
  10015. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  10016. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  10017. * @param activeCamera The camera we are returning the min for
  10018. * @returns the depth min z
  10019. */
  10020. getDepthMinZ(activeCamera: Camera): number;
  10021. /**
  10022. * Gets the maxZ used for shadow according to both the scene and the light.
  10023. *
  10024. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  10025. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  10026. * @param activeCamera The camera we are returning the max for
  10027. * @returns the depth max z
  10028. */
  10029. getDepthMaxZ(activeCamera: Camera): number;
  10030. }
  10031. }
  10032. declare module BABYLON {
  10033. /**
  10034. * The HemisphericLight simulates the ambient environment light,
  10035. * so the passed direction is the light reflection direction, not the incoming direction.
  10036. */
  10037. class HemisphericLight extends Light {
  10038. /**
  10039. * The groundColor is the light in the opposite direction to the one specified during creation.
  10040. * 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.
  10041. */
  10042. groundColor: Color3;
  10043. /**
  10044. * The light reflection direction, not the incoming direction.
  10045. */
  10046. direction: Vector3;
  10047. private _worldMatrix;
  10048. /**
  10049. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  10050. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  10051. * The HemisphericLight can't cast shadows.
  10052. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10053. * @param name The friendly name of the light
  10054. * @param direction The direction of the light reflection
  10055. * @param scene The scene the light belongs to
  10056. */
  10057. constructor(name: string, direction: Vector3, scene: Scene);
  10058. protected _buildUniformLayout(): void;
  10059. /**
  10060. * Returns the string "HemisphericLight".
  10061. * @return The class name
  10062. */
  10063. getClassName(): string;
  10064. /**
  10065. * Sets the HemisphericLight direction towards the passed target (Vector3).
  10066. * Returns the updated direction.
  10067. * @param target The target the direction should point to
  10068. * @return The computed direction
  10069. */
  10070. setDirectionToTarget(target: Vector3): Vector3;
  10071. /**
  10072. * Returns the shadow generator associated to the light.
  10073. * @returns Always null for hemispheric lights because it does not support shadows.
  10074. */
  10075. getShadowGenerator(): Nullable<ShadowGenerator>;
  10076. /**
  10077. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  10078. * @param effect The effect to update
  10079. * @param lightIndex The index of the light in the effect to update
  10080. * @returns The hemispheric light
  10081. */
  10082. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  10083. /**
  10084. * @ignore internal use only.
  10085. */
  10086. _getWorldMatrix(): Matrix;
  10087. /**
  10088. * Returns the integer 3.
  10089. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10090. */
  10091. getTypeID(): number;
  10092. }
  10093. }
  10094. declare module BABYLON {
  10095. /**
  10096. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10097. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10098. * 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.
  10099. */
  10100. abstract class Light extends Node {
  10101. private static _LIGHTMAP_DEFAULT;
  10102. private static _LIGHTMAP_SPECULAR;
  10103. private static _LIGHTMAP_SHADOWSONLY;
  10104. /**
  10105. * If every light affecting the material is in this lightmapMode,
  10106. * material.lightmapTexture adds or multiplies
  10107. * (depends on material.useLightmapAsShadowmap)
  10108. * after every other light calculations.
  10109. */
  10110. static readonly LIGHTMAP_DEFAULT: number;
  10111. /**
  10112. * material.lightmapTexture as only diffuse lighting from this light
  10113. * adds only specular lighting from this light
  10114. * adds dynamic shadows
  10115. */
  10116. static readonly LIGHTMAP_SPECULAR: number;
  10117. /**
  10118. * material.lightmapTexture as only lighting
  10119. * no light calculation from this light
  10120. * only adds dynamic shadows from this light
  10121. */
  10122. static readonly LIGHTMAP_SHADOWSONLY: number;
  10123. private static _INTENSITYMODE_AUTOMATIC;
  10124. private static _INTENSITYMODE_LUMINOUSPOWER;
  10125. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  10126. private static _INTENSITYMODE_ILLUMINANCE;
  10127. private static _INTENSITYMODE_LUMINANCE;
  10128. /**
  10129. * Each light type uses the default quantity according to its type:
  10130. * point/spot lights use luminous intensity
  10131. * directional lights use illuminance
  10132. */
  10133. static readonly INTENSITYMODE_AUTOMATIC: number;
  10134. /**
  10135. * lumen (lm)
  10136. */
  10137. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10138. /**
  10139. * candela (lm/sr)
  10140. */
  10141. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10142. /**
  10143. * lux (lm/m^2)
  10144. */
  10145. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10146. /**
  10147. * nit (cd/m^2)
  10148. */
  10149. static readonly INTENSITYMODE_LUMINANCE: number;
  10150. private static _LIGHTTYPEID_POINTLIGHT;
  10151. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  10152. private static _LIGHTTYPEID_SPOTLIGHT;
  10153. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  10154. /**
  10155. * Light type const id of the point light.
  10156. */
  10157. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10158. /**
  10159. * Light type const id of the directional light.
  10160. */
  10161. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10162. /**
  10163. * Light type const id of the spot light.
  10164. */
  10165. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10166. /**
  10167. * Light type const id of the hemispheric light.
  10168. */
  10169. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10170. /**
  10171. * Diffuse gives the basic color to an object.
  10172. */
  10173. diffuse: Color3;
  10174. /**
  10175. * Specular produces a highlight color on an object.
  10176. * Note: This is note affecting PBR materials.
  10177. */
  10178. specular: Color3;
  10179. /**
  10180. * Strength of the light.
  10181. * Note: By default it is define in the framework own unit.
  10182. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10183. */
  10184. intensity: number;
  10185. /**
  10186. * Defines how far from the source the light is impacting in scene units.
  10187. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10188. */
  10189. range: number;
  10190. /**
  10191. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10192. * of light.
  10193. */
  10194. private _photometricScale;
  10195. private _intensityMode;
  10196. /**
  10197. * Gets the photometric scale used to interpret the intensity.
  10198. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10199. */
  10200. /**
  10201. * Sets the photometric scale used to interpret the intensity.
  10202. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10203. */
  10204. intensityMode: number;
  10205. private _radius;
  10206. /**
  10207. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10208. */
  10209. /**
  10210. * sets the light radius used by PBR Materials to simulate soft area lights.
  10211. */
  10212. radius: number;
  10213. private _renderPriority;
  10214. /**
  10215. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10216. * exceeding the number allowed of the materials.
  10217. */
  10218. renderPriority: number;
  10219. /**
  10220. * Defines wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10221. * the current shadow generator.
  10222. */
  10223. shadowEnabled: boolean;
  10224. private _includedOnlyMeshes;
  10225. /**
  10226. * Gets the only meshes impacted by this light.
  10227. */
  10228. /**
  10229. * Sets the only meshes impacted by this light.
  10230. */
  10231. includedOnlyMeshes: AbstractMesh[];
  10232. private _excludedMeshes;
  10233. /**
  10234. * Gets the meshes not impacted by this light.
  10235. */
  10236. /**
  10237. * Sets the meshes not impacted by this light.
  10238. */
  10239. excludedMeshes: AbstractMesh[];
  10240. private _excludeWithLayerMask;
  10241. /**
  10242. * Gets the layer id use to find what meshes are not impacted by the light.
  10243. * Inactive if 0
  10244. */
  10245. /**
  10246. * Sets the layer id use to find what meshes are not impacted by the light.
  10247. * Inactive if 0
  10248. */
  10249. excludeWithLayerMask: number;
  10250. private _includeOnlyWithLayerMask;
  10251. /**
  10252. * Gets the layer id use to find what meshes are impacted by the light.
  10253. * Inactive if 0
  10254. */
  10255. /**
  10256. * Sets the layer id use to find what meshes are impacted by the light.
  10257. * Inactive if 0
  10258. */
  10259. includeOnlyWithLayerMask: number;
  10260. private _lightmapMode;
  10261. /**
  10262. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10263. */
  10264. /**
  10265. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10266. */
  10267. lightmapMode: number;
  10268. private _parentedWorldMatrix;
  10269. /**
  10270. * Shadow generator associted to the light.
  10271. * Internal use only.
  10272. */
  10273. _shadowGenerator: Nullable<IShadowGenerator>;
  10274. /**
  10275. * @ignore Internal use only.
  10276. */
  10277. _excludedMeshesIds: string[];
  10278. /**
  10279. * @ignore Internal use only.
  10280. */
  10281. _includedOnlyMeshesIds: string[];
  10282. /**
  10283. * The current light unifom buffer.
  10284. * @ignore Internal use only.
  10285. */
  10286. _uniformBuffer: UniformBuffer;
  10287. /**
  10288. * Creates a Light object in the scene.
  10289. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10290. * @param name The firendly name of the light
  10291. * @param scene The scene the light belongs too
  10292. */
  10293. constructor(name: string, scene: Scene);
  10294. protected abstract _buildUniformLayout(): void;
  10295. /**
  10296. * Sets the passed Effect "effect" with the Light information.
  10297. * @param effect The effect to update
  10298. * @param lightIndex The index of the light in the effect to update
  10299. * @returns The light
  10300. */
  10301. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10302. /**
  10303. * @ignore internal use only.
  10304. */
  10305. abstract _getWorldMatrix(): Matrix;
  10306. /**
  10307. * Returns the string "Light".
  10308. * @returns the class name
  10309. */
  10310. getClassName(): string;
  10311. /**
  10312. * Converts the light information to a readable string for debug purpose.
  10313. * @param fullDetails Supports for multiple levels of logging within scene loading
  10314. * @returns the human readable light info
  10315. */
  10316. toString(fullDetails?: boolean): string;
  10317. /**
  10318. * Set the enabled state of this node.
  10319. * @param value - the new enabled state
  10320. */
  10321. setEnabled(value: boolean): void;
  10322. /**
  10323. * Returns the Light associated shadow generator if any.
  10324. * @return the associated shadow generator.
  10325. */
  10326. getShadowGenerator(): Nullable<IShadowGenerator>;
  10327. /**
  10328. * Returns a Vector3, the absolute light position in the World.
  10329. * @returns the world space position of the light
  10330. */
  10331. getAbsolutePosition(): Vector3;
  10332. /**
  10333. * Specifies if the light will affect the passed mesh.
  10334. * @param mesh The mesh to test against the light
  10335. * @return true the mesh is affected otherwise, false.
  10336. */
  10337. canAffectMesh(mesh: AbstractMesh): boolean;
  10338. /**
  10339. * Computes and Returns the light World matrix.
  10340. * @returns the world matrix
  10341. */
  10342. getWorldMatrix(): Matrix;
  10343. /**
  10344. * Sort function to order lights for rendering.
  10345. * @param a First Light object to compare to second.
  10346. * @param b Second Light object to compare first.
  10347. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10348. */
  10349. static CompareLightsPriority(a: Light, b: Light): number;
  10350. /**
  10351. * Releases resources associated with this node.
  10352. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10353. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10354. */
  10355. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10356. /**
  10357. * Returns the light type ID (integer).
  10358. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10359. */
  10360. getTypeID(): number;
  10361. /**
  10362. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10363. * @returns the scaled intensity in intensity mode unit
  10364. */
  10365. getScaledIntensity(): number;
  10366. /**
  10367. * Returns a new Light object, named "name", from the current one.
  10368. * @param name The name of the cloned light
  10369. * @returns the new created light
  10370. */
  10371. clone(name: string): Nullable<Light>;
  10372. /**
  10373. * Serializes the current light into a Serialization object.
  10374. * @returns the serialized object.
  10375. */
  10376. serialize(): any;
  10377. /**
  10378. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10379. * This new light is named "name" and added to the passed scene.
  10380. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10381. * @param name The friendly name of the light
  10382. * @param scene The scene the new light will belong to
  10383. * @returns the constructor function
  10384. */
  10385. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10386. /**
  10387. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10388. * @param parsedLight The JSON representation of the light
  10389. * @param scene The scene to create the parsed light in
  10390. * @returns the created light after parsing
  10391. */
  10392. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10393. private _hookArrayForExcluded(array);
  10394. private _hookArrayForIncludedOnly(array);
  10395. private _resyncMeshes();
  10396. /**
  10397. * Forces the meshes to update their light related information in their rendering used effects
  10398. * @ignore Internal Use Only
  10399. */
  10400. _markMeshesAsLightDirty(): void;
  10401. /**
  10402. * Recomputes the cached photometric scale if needed.
  10403. */
  10404. private _computePhotometricScale();
  10405. /**
  10406. * Returns the Photometric Scale according to the light type and intensity mode.
  10407. */
  10408. private _getPhotometricScale();
  10409. /**
  10410. * Reorder the light in the scene according to their defined priority.
  10411. * @ignore Internal Use Only
  10412. */
  10413. _reorderLightsInScene(): void;
  10414. }
  10415. }
  10416. declare module BABYLON {
  10417. /**
  10418. * A point light is a light defined by an unique point in world space.
  10419. * The light is emitted in every direction from this point.
  10420. * A good example of a point light is a standard light bulb.
  10421. * Documentation: https://doc.babylonjs.com/babylon101/lights
  10422. */
  10423. class PointLight extends ShadowLight {
  10424. private _shadowAngle;
  10425. /**
  10426. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  10427. * This specifies what angle the shadow will use to be created.
  10428. *
  10429. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  10430. */
  10431. /**
  10432. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  10433. * This specifies what angle the shadow will use to be created.
  10434. *
  10435. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  10436. */
  10437. shadowAngle: number;
  10438. /**
  10439. * Gets the direction if it has been set.
  10440. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  10441. */
  10442. /**
  10443. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  10444. */
  10445. direction: Vector3;
  10446. /**
  10447. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  10448. * A PointLight emits the light in every direction.
  10449. * It can cast shadows.
  10450. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  10451. * ```javascript
  10452. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  10453. * ```
  10454. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10455. * @param name The light friendly name
  10456. * @param position The position of the point light in the scene
  10457. * @param scene The scene the lights belongs to
  10458. */
  10459. constructor(name: string, position: Vector3, scene: Scene);
  10460. /**
  10461. * Returns the string "PointLight"
  10462. * @returns the class name
  10463. */
  10464. getClassName(): string;
  10465. /**
  10466. * Returns the integer 0.
  10467. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10468. */
  10469. getTypeID(): number;
  10470. /**
  10471. * Specifies wether or not the shadowmap should be a cube texture.
  10472. * @returns true if the shadowmap needs to be a cube texture.
  10473. */
  10474. needCube(): boolean;
  10475. /**
  10476. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  10477. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10478. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10479. */
  10480. getShadowDirection(faceIndex?: number): Vector3;
  10481. /**
  10482. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  10483. * - fov = PI / 2
  10484. * - aspect ratio : 1.0
  10485. * - z-near and far equal to the active camera minZ and maxZ.
  10486. * Returns the PointLight.
  10487. */
  10488. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10489. protected _buildUniformLayout(): void;
  10490. /**
  10491. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  10492. * @param effect The effect to update
  10493. * @param lightIndex The index of the light in the effect to update
  10494. * @returns The point light
  10495. */
  10496. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  10497. }
  10498. }
  10499. declare module BABYLON {
  10500. /**
  10501. * Interface describing all the common properties and methods a shadow light needs to implement.
  10502. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10503. * as well as binding the different shadow properties to the effects.
  10504. */
  10505. interface IShadowLight extends Light {
  10506. /**
  10507. * The light id in the scene (used in scene.findLighById for instance)
  10508. */
  10509. id: string;
  10510. /**
  10511. * The position the shdow will be casted from.
  10512. */
  10513. position: Vector3;
  10514. /**
  10515. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10516. */
  10517. direction: Vector3;
  10518. /**
  10519. * The transformed position. Position of the light in world space taking parenting in account.
  10520. */
  10521. transformedPosition: Vector3;
  10522. /**
  10523. * The transformed direction. Direction of the light in world space taking parenting in account.
  10524. */
  10525. transformedDirection: Vector3;
  10526. /**
  10527. * The friendly name of the light in the scene.
  10528. */
  10529. name: string;
  10530. /**
  10531. * Defines the shadow projection clipping minimum z value.
  10532. */
  10533. shadowMinZ: number;
  10534. /**
  10535. * Defines the shadow projection clipping maximum z value.
  10536. */
  10537. shadowMaxZ: number;
  10538. /**
  10539. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10540. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10541. */
  10542. computeTransformedInformation(): boolean;
  10543. /**
  10544. * Gets the scene the light belongs to.
  10545. * @returns The scene
  10546. */
  10547. getScene(): Scene;
  10548. /**
  10549. * Callback defining a custom Projection Matrix Builder.
  10550. * This can be used to override the default projection matrix computation.
  10551. */
  10552. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10553. /**
  10554. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10555. * @param matrix The materix to updated with the projection information
  10556. * @param viewMatrix The transform matrix of the light
  10557. * @param renderList The list of mesh to render in the map
  10558. * @returns The current light
  10559. */
  10560. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10561. /**
  10562. * Gets the current depth scale used in ESM.
  10563. * @returns The scale
  10564. */
  10565. getDepthScale(): number;
  10566. /**
  10567. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10568. * @returns true if a cube texture needs to be use
  10569. */
  10570. needCube(): boolean;
  10571. /**
  10572. * Detects if the projection matrix requires to be recomputed this frame.
  10573. * @returns true if it requires to be recomputed otherwise, false.
  10574. */
  10575. needProjectionMatrixCompute(): boolean;
  10576. /**
  10577. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10578. */
  10579. forceProjectionMatrixCompute(): void;
  10580. /**
  10581. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10582. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10583. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10584. */
  10585. getShadowDirection(faceIndex?: number): Vector3;
  10586. /**
  10587. * Gets the minZ used for shadow according to both the scene and the light.
  10588. * @param activeCamera The camera we are returning the min for
  10589. * @returns the depth min z
  10590. */
  10591. getDepthMinZ(activeCamera: Camera): number;
  10592. /**
  10593. * Gets the maxZ used for shadow according to both the scene and the light.
  10594. * @param activeCamera The camera we are returning the max for
  10595. * @returns the depth max z
  10596. */
  10597. getDepthMaxZ(activeCamera: Camera): number;
  10598. }
  10599. /**
  10600. * Base implementation IShadowLight
  10601. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10602. */
  10603. abstract class ShadowLight extends Light implements IShadowLight {
  10604. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10605. protected _position: Vector3;
  10606. protected _setPosition(value: Vector3): void;
  10607. /**
  10608. * Sets the position the shadow will be casted from. Also use as the light position for both
  10609. * point and spot lights.
  10610. */
  10611. /**
  10612. * Sets the position the shadow will be casted from. Also use as the light position for both
  10613. * point and spot lights.
  10614. */
  10615. position: Vector3;
  10616. protected _direction: Vector3;
  10617. protected _setDirection(value: Vector3): void;
  10618. /**
  10619. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10620. * Also use as the light direction on spot and directional lights.
  10621. */
  10622. /**
  10623. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10624. * Also use as the light direction on spot and directional lights.
  10625. */
  10626. direction: Vector3;
  10627. private _shadowMinZ;
  10628. /**
  10629. * Gets the shadow projection clipping minimum z value.
  10630. */
  10631. /**
  10632. * Sets the shadow projection clipping minimum z value.
  10633. */
  10634. shadowMinZ: number;
  10635. private _shadowMaxZ;
  10636. /**
  10637. * Sets the shadow projection clipping maximum z value.
  10638. */
  10639. /**
  10640. * Gets the shadow projection clipping maximum z value.
  10641. */
  10642. shadowMaxZ: number;
  10643. /**
  10644. * Callback defining a custom Projection Matrix Builder.
  10645. * This can be used to override the default projection matrix computation.
  10646. */
  10647. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10648. /**
  10649. * The transformed position. Position of the light in world space taking parenting in account.
  10650. */
  10651. transformedPosition: Vector3;
  10652. /**
  10653. * The transformed direction. Direction of the light in world space taking parenting in account.
  10654. */
  10655. transformedDirection: Vector3;
  10656. private _worldMatrix;
  10657. private _needProjectionMatrixCompute;
  10658. /**
  10659. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10660. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10661. */
  10662. computeTransformedInformation(): boolean;
  10663. /**
  10664. * Return the depth scale used for the shadow map.
  10665. * @returns the depth scale.
  10666. */
  10667. getDepthScale(): number;
  10668. /**
  10669. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10670. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10671. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10672. */
  10673. getShadowDirection(faceIndex?: number): Vector3;
  10674. /**
  10675. * Returns the ShadowLight absolute position in the World.
  10676. * @returns the position vector in world space
  10677. */
  10678. getAbsolutePosition(): Vector3;
  10679. /**
  10680. * Sets the ShadowLight direction toward the passed target.
  10681. * @param target The point tot target in local space
  10682. * @returns the updated ShadowLight direction
  10683. */
  10684. setDirectionToTarget(target: Vector3): Vector3;
  10685. /**
  10686. * Returns the light rotation in euler definition.
  10687. * @returns the x y z rotation in local space.
  10688. */
  10689. getRotation(): Vector3;
  10690. /**
  10691. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10692. * @returns true if a cube texture needs to be use
  10693. */
  10694. needCube(): boolean;
  10695. /**
  10696. * Detects if the projection matrix requires to be recomputed this frame.
  10697. * @returns true if it requires to be recomputed otherwise, false.
  10698. */
  10699. needProjectionMatrixCompute(): boolean;
  10700. /**
  10701. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10702. */
  10703. forceProjectionMatrixCompute(): void;
  10704. /**
  10705. * Get the world matrix of the sahdow lights.
  10706. * @ignore Internal Use Only
  10707. */
  10708. _getWorldMatrix(): Matrix;
  10709. /**
  10710. * Gets the minZ used for shadow according to both the scene and the light.
  10711. * @param activeCamera The camera we are returning the min for
  10712. * @returns the depth min z
  10713. */
  10714. getDepthMinZ(activeCamera: Camera): number;
  10715. /**
  10716. * Gets the maxZ used for shadow according to both the scene and the light.
  10717. * @param activeCamera The camera we are returning the max for
  10718. * @returns the depth max z
  10719. */
  10720. getDepthMaxZ(activeCamera: Camera): number;
  10721. /**
  10722. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10723. * @param matrix The materix to updated with the projection information
  10724. * @param viewMatrix The transform matrix of the light
  10725. * @param renderList The list of mesh to render in the map
  10726. * @returns The current light
  10727. */
  10728. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10729. }
  10730. }
  10731. declare module BABYLON {
  10732. /**
  10733. * A spot light is defined by a position, a direction, an angle, and an exponent.
  10734. * These values define a cone of light starting from the position, emitting toward the direction.
  10735. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  10736. * and the exponent defines the speed of the decay of the light with distance (reach).
  10737. * Documentation: https://doc.babylonjs.com/babylon101/lights
  10738. */
  10739. class SpotLight extends ShadowLight {
  10740. private _angle;
  10741. /**
  10742. * Gets the cone angle of the spot light in Radians.
  10743. */
  10744. /**
  10745. * Sets the cone angle of the spot light in Radians.
  10746. */
  10747. angle: number;
  10748. private _shadowAngleScale;
  10749. /**
  10750. * Allows scaling the angle of the light for shadow generation only.
  10751. */
  10752. /**
  10753. * Allows scaling the angle of the light for shadow generation only.
  10754. */
  10755. shadowAngleScale: number;
  10756. /**
  10757. * The light decay speed with the distance from the emission spot.
  10758. */
  10759. exponent: number;
  10760. private _projectionTextureMatrix;
  10761. /**
  10762. * Allows reading the projecton texture
  10763. */
  10764. readonly projectionTextureMatrix: Matrix;
  10765. protected _projectionTextureLightNear: number;
  10766. /**
  10767. * Gets the near clip of the Spotlight for texture projection.
  10768. */
  10769. /**
  10770. * Sets the near clip of the Spotlight for texture projection.
  10771. */
  10772. projectionTextureLightNear: number;
  10773. protected _projectionTextureLightFar: number;
  10774. /**
  10775. * Gets the far clip of the Spotlight for texture projection.
  10776. */
  10777. /**
  10778. * Sets the far clip of the Spotlight for texture projection.
  10779. */
  10780. projectionTextureLightFar: number;
  10781. protected _projectionTextureUpDirection: Vector3;
  10782. /**
  10783. * Gets the Up vector of the Spotlight for texture projection.
  10784. */
  10785. /**
  10786. * Sets the Up vector of the Spotlight for texture projection.
  10787. */
  10788. projectionTextureUpDirection: Vector3;
  10789. private _projectionTexture;
  10790. /**
  10791. * Gets the projection texture of the light.
  10792. */
  10793. /**
  10794. * Sets the projection texture of the light.
  10795. */
  10796. projectionTexture: Nullable<BaseTexture>;
  10797. private _projectionTextureViewLightDirty;
  10798. private _projectionTextureProjectionLightDirty;
  10799. private _projectionTextureDirty;
  10800. private _projectionTextureViewTargetVector;
  10801. private _projectionTextureViewLightMatrix;
  10802. private _projectionTextureProjectionLightMatrix;
  10803. private _projectionTextureScalingMatrix;
  10804. /**
  10805. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  10806. * It can cast shadows.
  10807. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10808. * @param name The light friendly name
  10809. * @param position The position of the spot light in the scene
  10810. * @param direction The direction of the light in the scene
  10811. * @param angle The cone angle of the light in Radians
  10812. * @param exponent The light decay speed with the distance from the emission spot
  10813. * @param scene The scene the lights belongs to
  10814. */
  10815. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  10816. /**
  10817. * Returns the string "SpotLight".
  10818. * @returns the class name
  10819. */
  10820. getClassName(): string;
  10821. /**
  10822. * Returns the integer 2.
  10823. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10824. */
  10825. getTypeID(): number;
  10826. /**
  10827. * Overrides the direction setter to recompute the projection texture view light Matrix.
  10828. */
  10829. protected _setDirection(value: Vector3): void;
  10830. /**
  10831. * Overrides the position setter to recompute the projection texture view light Matrix.
  10832. */
  10833. protected _setPosition(value: Vector3): void;
  10834. /**
  10835. * 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.
  10836. * Returns the SpotLight.
  10837. */
  10838. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10839. protected _computeProjectionTextureViewLightMatrix(): void;
  10840. protected _computeProjectionTextureProjectionLightMatrix(): void;
  10841. /**
  10842. * Main function for light texture projection matrix computing.
  10843. */
  10844. protected _computeProjectionTextureMatrix(): void;
  10845. protected _buildUniformLayout(): void;
  10846. /**
  10847. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  10848. * @param effect The effect to update
  10849. * @param lightIndex The index of the light in the effect to update
  10850. * @returns The spot light
  10851. */
  10852. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  10853. /**
  10854. * Disposes the light and the associated resources.
  10855. */
  10856. dispose(): void;
  10857. }
  10858. }
  10859. declare module BABYLON {
  10860. /**
  10861. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  10862. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  10863. * 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;
  10864. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  10865. */
  10866. class ColorCurves {
  10867. private _dirty;
  10868. private _tempColor;
  10869. private _globalCurve;
  10870. private _highlightsCurve;
  10871. private _midtonesCurve;
  10872. private _shadowsCurve;
  10873. private _positiveCurve;
  10874. private _negativeCurve;
  10875. private _globalHue;
  10876. private _globalDensity;
  10877. private _globalSaturation;
  10878. private _globalExposure;
  10879. /**
  10880. * Gets the global Hue value.
  10881. * 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).
  10882. */
  10883. /**
  10884. * Sets the global Hue value.
  10885. * 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).
  10886. */
  10887. globalHue: number;
  10888. /**
  10889. * Gets the global Density value.
  10890. * 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.
  10891. * Values less than zero provide a filter of opposite hue.
  10892. */
  10893. /**
  10894. * Sets the global Density value.
  10895. * 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.
  10896. * Values less than zero provide a filter of opposite hue.
  10897. */
  10898. globalDensity: number;
  10899. /**
  10900. * Gets the global Saturation value.
  10901. * 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.
  10902. */
  10903. /**
  10904. * Sets the global Saturation value.
  10905. * 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.
  10906. */
  10907. globalSaturation: number;
  10908. private _highlightsHue;
  10909. private _highlightsDensity;
  10910. private _highlightsSaturation;
  10911. private _highlightsExposure;
  10912. /**
  10913. * Gets the highlights Hue value.
  10914. * 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).
  10915. */
  10916. /**
  10917. * Sets the highlights Hue value.
  10918. * 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).
  10919. */
  10920. highlightsHue: number;
  10921. /**
  10922. * Gets the highlights Density value.
  10923. * 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.
  10924. * Values less than zero provide a filter of opposite hue.
  10925. */
  10926. /**
  10927. * Sets the highlights Density value.
  10928. * 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.
  10929. * Values less than zero provide a filter of opposite hue.
  10930. */
  10931. highlightsDensity: number;
  10932. /**
  10933. * Gets the highlights Saturation value.
  10934. * 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.
  10935. */
  10936. /**
  10937. * Sets the highlights Saturation value.
  10938. * 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.
  10939. */
  10940. highlightsSaturation: number;
  10941. /**
  10942. * Gets the highlights Exposure value.
  10943. * 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.
  10944. */
  10945. /**
  10946. * Sets the highlights Exposure value.
  10947. * 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.
  10948. */
  10949. highlightsExposure: number;
  10950. private _midtonesHue;
  10951. private _midtonesDensity;
  10952. private _midtonesSaturation;
  10953. private _midtonesExposure;
  10954. /**
  10955. * Gets the midtones Hue value.
  10956. * 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).
  10957. */
  10958. /**
  10959. * Sets the midtones Hue value.
  10960. * 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).
  10961. */
  10962. midtonesHue: number;
  10963. /**
  10964. * Gets the midtones Density value.
  10965. * 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.
  10966. * Values less than zero provide a filter of opposite hue.
  10967. */
  10968. /**
  10969. * Sets the midtones Density value.
  10970. * 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.
  10971. * Values less than zero provide a filter of opposite hue.
  10972. */
  10973. midtonesDensity: number;
  10974. /**
  10975. * Gets the midtones Saturation value.
  10976. * 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.
  10977. */
  10978. /**
  10979. * Sets the midtones Saturation value.
  10980. * 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.
  10981. */
  10982. midtonesSaturation: number;
  10983. /**
  10984. * Gets the midtones Exposure value.
  10985. * 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.
  10986. */
  10987. /**
  10988. * Sets the midtones Exposure value.
  10989. * 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.
  10990. */
  10991. midtonesExposure: number;
  10992. private _shadowsHue;
  10993. private _shadowsDensity;
  10994. private _shadowsSaturation;
  10995. private _shadowsExposure;
  10996. /**
  10997. * Gets the shadows Hue value.
  10998. * 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).
  10999. */
  11000. /**
  11001. * Sets the shadows Hue value.
  11002. * 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).
  11003. */
  11004. shadowsHue: number;
  11005. /**
  11006. * Gets the shadows Density value.
  11007. * 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.
  11008. * Values less than zero provide a filter of opposite hue.
  11009. */
  11010. /**
  11011. * Sets the shadows Density value.
  11012. * 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.
  11013. * Values less than zero provide a filter of opposite hue.
  11014. */
  11015. shadowsDensity: number;
  11016. /**
  11017. * Gets the shadows Saturation value.
  11018. * 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.
  11019. */
  11020. /**
  11021. * Sets the shadows Saturation value.
  11022. * 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.
  11023. */
  11024. shadowsSaturation: number;
  11025. /**
  11026. * Gets the shadows Exposure value.
  11027. * 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.
  11028. */
  11029. /**
  11030. * Sets the shadows Exposure value.
  11031. * 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.
  11032. */
  11033. shadowsExposure: number;
  11034. getClassName(): string;
  11035. /**
  11036. * Binds the color curves to the shader.
  11037. * @param colorCurves The color curve to bind
  11038. * @param effect The effect to bind to
  11039. */
  11040. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11041. /**
  11042. * Prepare the list of uniforms associated with the ColorCurves effects.
  11043. * @param uniformsList The list of uniforms used in the effect
  11044. */
  11045. static PrepareUniforms(uniformsList: string[]): void;
  11046. /**
  11047. * Returns color grading data based on a hue, density, saturation and exposure value.
  11048. * @param filterHue The hue of the color filter.
  11049. * @param filterDensity The density of the color filter.
  11050. * @param saturation The saturation.
  11051. * @param exposure The exposure.
  11052. * @param result The result data container.
  11053. */
  11054. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  11055. /**
  11056. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11057. * @param value The input slider value in range [-100,100].
  11058. * @returns Adjusted value.
  11059. */
  11060. private static applyColorGradingSliderNonlinear(value);
  11061. /**
  11062. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11063. * @param hue The hue (H) input.
  11064. * @param saturation The saturation (S) input.
  11065. * @param brightness The brightness (B) input.
  11066. * @result An RGBA color represented as Vector4.
  11067. */
  11068. private static fromHSBToRef(hue, saturation, brightness, result);
  11069. /**
  11070. * Returns a value clamped between min and max
  11071. * @param value The value to clamp
  11072. * @param min The minimum of value
  11073. * @param max The maximum of value
  11074. * @returns The clamped value.
  11075. */
  11076. private static clamp(value, min, max);
  11077. /**
  11078. * Clones the current color curve instance.
  11079. * @return The cloned curves
  11080. */
  11081. clone(): ColorCurves;
  11082. /**
  11083. * Serializes the current color curve instance to a json representation.
  11084. * @return a JSON representation
  11085. */
  11086. serialize(): any;
  11087. /**
  11088. * Parses the color curve from a json representation.
  11089. * @param source the JSON source to parse
  11090. * @return The parsed curves
  11091. */
  11092. static Parse(source: any): ColorCurves;
  11093. }
  11094. }
  11095. declare module BABYLON {
  11096. /**
  11097. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  11098. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  11099. */
  11100. class EffectFallbacks {
  11101. private _defines;
  11102. private _currentRank;
  11103. private _maxRank;
  11104. private _mesh;
  11105. /**
  11106. * Removes the fallback from the bound mesh.
  11107. */
  11108. unBindMesh(): void;
  11109. /**
  11110. * Adds a fallback on the specified property.
  11111. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  11112. * @param define The name of the define in the shader
  11113. */
  11114. addFallback(rank: number, define: string): void;
  11115. /**
  11116. * Sets the mesh to use CPU skinning when needing to fallback.
  11117. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  11118. * @param mesh The mesh to use the fallbacks.
  11119. */
  11120. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  11121. /**
  11122. * Checks to see if more fallbacks are still availible.
  11123. */
  11124. readonly isMoreFallbacks: boolean;
  11125. /**
  11126. * Removes the defines that shoould be removed when falling back.
  11127. * @param currentDefines defines the current define statements for the shader.
  11128. * @param effect defines the current effect we try to compile
  11129. * @returns The resulting defines with defines of the current rank removed.
  11130. */
  11131. reduce(currentDefines: string, effect: Effect): string;
  11132. }
  11133. /**
  11134. * Options to be used when creating an effect.
  11135. */
  11136. class EffectCreationOptions {
  11137. /**
  11138. * Atrributes that will be used in the shader.
  11139. */
  11140. attributes: string[];
  11141. /**
  11142. * Uniform varible names that will be set in the shader.
  11143. */
  11144. uniformsNames: string[];
  11145. /**
  11146. * Uniform buffer varible names that will be set in the shader.
  11147. */
  11148. uniformBuffersNames: string[];
  11149. /**
  11150. * Sampler texture variable names that will be set in the shader.
  11151. */
  11152. samplers: string[];
  11153. /**
  11154. * Define statements that will be set in the shader.
  11155. */
  11156. defines: any;
  11157. /**
  11158. * Possible fallbacks for this effect to improve performance when needed.
  11159. */
  11160. fallbacks: Nullable<EffectFallbacks>;
  11161. /**
  11162. * Callback that will be called when the shader is compiled.
  11163. */
  11164. onCompiled: Nullable<(effect: Effect) => void>;
  11165. /**
  11166. * Callback that will be called if an error occurs during shader compilation.
  11167. */
  11168. onError: Nullable<(effect: Effect, errors: string) => void>;
  11169. /**
  11170. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  11171. */
  11172. indexParameters: any;
  11173. /**
  11174. * Max number of lights that can be used in the shader.
  11175. */
  11176. maxSimultaneousLights: number;
  11177. /**
  11178. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  11179. */
  11180. transformFeedbackVaryings: Nullable<string[]>;
  11181. }
  11182. /**
  11183. * Effect containing vertex and fragment shader that can be executed on an object.
  11184. */
  11185. class Effect {
  11186. /**
  11187. * Name of the effect.
  11188. */
  11189. name: any;
  11190. /**
  11191. * String container all the define statements that should be set on the shader.
  11192. */
  11193. defines: string;
  11194. /**
  11195. * Callback that will be called when the shader is compiled.
  11196. */
  11197. onCompiled: Nullable<(effect: Effect) => void>;
  11198. /**
  11199. * Callback that will be called if an error occurs during shader compilation.
  11200. */
  11201. onError: Nullable<(effect: Effect, errors: string) => void>;
  11202. /**
  11203. * Callback that will be called when effect is bound.
  11204. */
  11205. onBind: Nullable<(effect: Effect) => void>;
  11206. /**
  11207. * Unique ID of the effect.
  11208. */
  11209. uniqueId: number;
  11210. /**
  11211. * Observable that will be called when the shader is compiled.
  11212. */
  11213. onCompileObservable: Observable<Effect>;
  11214. /**
  11215. * Observable that will be called if an error occurs during shader compilation.
  11216. */
  11217. onErrorObservable: Observable<Effect>;
  11218. /**
  11219. * Observable that will be called when effect is bound.
  11220. */
  11221. onBindObservable: Observable<Effect>;
  11222. private static _uniqueIdSeed;
  11223. private _engine;
  11224. private _uniformBuffersNames;
  11225. private _uniformsNames;
  11226. private _samplers;
  11227. private _isReady;
  11228. private _compilationError;
  11229. private _attributesNames;
  11230. private _attributes;
  11231. private _uniforms;
  11232. /**
  11233. * Key for the effect.
  11234. */
  11235. _key: string;
  11236. private _indexParameters;
  11237. private _fallbacks;
  11238. private _vertexSourceCode;
  11239. private _fragmentSourceCode;
  11240. private _vertexSourceCodeOverride;
  11241. private _fragmentSourceCodeOverride;
  11242. private _transformFeedbackVaryings;
  11243. /**
  11244. * Compiled shader to webGL program.
  11245. */
  11246. _program: WebGLProgram;
  11247. private _valueCache;
  11248. private static _baseCache;
  11249. /**
  11250. * Instantiates an effect.
  11251. * An effect can be used to create/manage/execute vertex and fragment shaders.
  11252. * @param baseName Name of the effect.
  11253. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  11254. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  11255. * @param samplers List of sampler variables that will be passed to the shader.
  11256. * @param engine Engine to be used to render the effect
  11257. * @param defines Define statements to be added to the shader.
  11258. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  11259. * @param onCompiled Callback that will be called when the shader is compiled.
  11260. * @param onError Callback that will be called if an error occurs during shader compilation.
  11261. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  11262. */
  11263. 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);
  11264. /**
  11265. * Unique key for this effect
  11266. */
  11267. readonly key: string;
  11268. /**
  11269. * If the effect has been compiled and prepared.
  11270. * @returns if the effect is compiled and prepared.
  11271. */
  11272. isReady(): boolean;
  11273. /**
  11274. * The engine the effect was initialized with.
  11275. * @returns the engine.
  11276. */
  11277. getEngine(): Engine;
  11278. /**
  11279. * The compiled webGL program for the effect
  11280. * @returns the webGL program.
  11281. */
  11282. getProgram(): WebGLProgram;
  11283. /**
  11284. * The set of names of attribute variables for the shader.
  11285. * @returns An array of attribute names.
  11286. */
  11287. getAttributesNames(): string[];
  11288. /**
  11289. * Returns the attribute at the given index.
  11290. * @param index The index of the attribute.
  11291. * @returns The location of the attribute.
  11292. */
  11293. getAttributeLocation(index: number): number;
  11294. /**
  11295. * Returns the attribute based on the name of the variable.
  11296. * @param name of the attribute to look up.
  11297. * @returns the attribute location.
  11298. */
  11299. getAttributeLocationByName(name: string): number;
  11300. /**
  11301. * The number of attributes.
  11302. * @returns the numnber of attributes.
  11303. */
  11304. getAttributesCount(): number;
  11305. /**
  11306. * Gets the index of a uniform variable.
  11307. * @param uniformName of the uniform to look up.
  11308. * @returns the index.
  11309. */
  11310. getUniformIndex(uniformName: string): number;
  11311. /**
  11312. * Returns the attribute based on the name of the variable.
  11313. * @param uniformName of the uniform to look up.
  11314. * @returns the location of the uniform.
  11315. */
  11316. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  11317. /**
  11318. * Returns an array of sampler variable names
  11319. * @returns The array of sampler variable neames.
  11320. */
  11321. getSamplers(): string[];
  11322. /**
  11323. * The error from the last compilation.
  11324. * @returns the error string.
  11325. */
  11326. getCompilationError(): string;
  11327. /**
  11328. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  11329. * @param func The callback to be used.
  11330. */
  11331. executeWhenCompiled(func: (effect: Effect) => void): void;
  11332. /** @ignore */
  11333. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  11334. /** @ignore */
  11335. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  11336. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  11337. private _processShaderConversion(sourceCode, isFragment, callback);
  11338. private _processIncludes(sourceCode, callback);
  11339. private _processPrecision(source);
  11340. /**
  11341. * Recompiles the webGL program
  11342. * @param vertexSourceCode The source code for the vertex shader.
  11343. * @param fragmentSourceCode The source code for the fragment shader.
  11344. * @param onCompiled Callback called when completed.
  11345. * @param onError Callback called on error.
  11346. */
  11347. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  11348. /**
  11349. * Gets the uniform locations of the the specified variable names
  11350. * @param names THe names of the variables to lookup.
  11351. * @returns Array of locations in the same order as variable names.
  11352. */
  11353. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  11354. /**
  11355. * Prepares the effect
  11356. */
  11357. _prepareEffect(): void;
  11358. /**
  11359. * Checks if the effect is supported. (Must be called after compilation)
  11360. */
  11361. readonly isSupported: boolean;
  11362. /**
  11363. * Binds a texture to the engine to be used as output of the shader.
  11364. * @param channel Name of the output variable.
  11365. * @param texture Texture to bind.
  11366. */
  11367. _bindTexture(channel: string, texture: InternalTexture): void;
  11368. /**
  11369. * Sets a texture on the engine to be used in the shader.
  11370. * @param channel Name of the sampler variable.
  11371. * @param texture Texture to set.
  11372. */
  11373. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  11374. /**
  11375. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  11376. * @param channel Name of the sampler variable.
  11377. * @param texture Texture to set.
  11378. */
  11379. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  11380. /**
  11381. * Sets an array of textures on the engine to be used in the shader.
  11382. * @param channel Name of the variable.
  11383. * @param textures Textures to set.
  11384. */
  11385. setTextureArray(channel: string, textures: BaseTexture[]): void;
  11386. /**
  11387. * 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)
  11388. * @param channel Name of the sampler variable.
  11389. * @param postProcess Post process to get the input texture from.
  11390. */
  11391. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  11392. /**
  11393. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  11394. * 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)
  11395. * @param channel Name of the sampler variable.
  11396. * @param postProcess Post process to get the output texture from.
  11397. */
  11398. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  11399. /** @ignore */
  11400. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  11401. /** @ignore */
  11402. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  11403. /** @ignore */
  11404. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  11405. /** @ignore */
  11406. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  11407. /**
  11408. * Binds a buffer to a uniform.
  11409. * @param buffer Buffer to bind.
  11410. * @param name Name of the uniform variable to bind to.
  11411. */
  11412. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  11413. /**
  11414. * Binds block to a uniform.
  11415. * @param blockName Name of the block to bind.
  11416. * @param index Index to bind.
  11417. */
  11418. bindUniformBlock(blockName: string, index: number): void;
  11419. /**
  11420. * Sets an interger value on a uniform variable.
  11421. * @param uniformName Name of the variable.
  11422. * @param value Value to be set.
  11423. * @returns this effect.
  11424. */
  11425. setInt(uniformName: string, value: number): Effect;
  11426. /**
  11427. * Sets an int array on a uniform variable.
  11428. * @param uniformName Name of the variable.
  11429. * @param array array to be set.
  11430. * @returns this effect.
  11431. */
  11432. setIntArray(uniformName: string, array: Int32Array): Effect;
  11433. /**
  11434. * 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)
  11435. * @param uniformName Name of the variable.
  11436. * @param array array to be set.
  11437. * @returns this effect.
  11438. */
  11439. setIntArray2(uniformName: string, array: Int32Array): Effect;
  11440. /**
  11441. * 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)
  11442. * @param uniformName Name of the variable.
  11443. * @param array array to be set.
  11444. * @returns this effect.
  11445. */
  11446. setIntArray3(uniformName: string, array: Int32Array): Effect;
  11447. /**
  11448. * 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)
  11449. * @param uniformName Name of the variable.
  11450. * @param array array to be set.
  11451. * @returns this effect.
  11452. */
  11453. setIntArray4(uniformName: string, array: Int32Array): Effect;
  11454. /**
  11455. * Sets an float array on a uniform variable.
  11456. * @param uniformName Name of the variable.
  11457. * @param array array to be set.
  11458. * @returns this effect.
  11459. */
  11460. setFloatArray(uniformName: string, array: Float32Array): Effect;
  11461. /**
  11462. * 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)
  11463. * @param uniformName Name of the variable.
  11464. * @param array array to be set.
  11465. * @returns this effect.
  11466. */
  11467. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  11468. /**
  11469. * 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)
  11470. * @param uniformName Name of the variable.
  11471. * @param array array to be set.
  11472. * @returns this effect.
  11473. */
  11474. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  11475. /**
  11476. * 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)
  11477. * @param uniformName Name of the variable.
  11478. * @param array array to be set.
  11479. * @returns this effect.
  11480. */
  11481. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  11482. /**
  11483. * Sets an array on a uniform variable.
  11484. * @param uniformName Name of the variable.
  11485. * @param array array to be set.
  11486. * @returns this effect.
  11487. */
  11488. setArray(uniformName: string, array: number[]): Effect;
  11489. /**
  11490. * 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)
  11491. * @param uniformName Name of the variable.
  11492. * @param array array to be set.
  11493. * @returns this effect.
  11494. */
  11495. setArray2(uniformName: string, array: number[]): Effect;
  11496. /**
  11497. * 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)
  11498. * @param uniformName Name of the variable.
  11499. * @param array array to be set.
  11500. * @returns this effect.
  11501. */
  11502. setArray3(uniformName: string, array: number[]): Effect;
  11503. /**
  11504. * 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)
  11505. * @param uniformName Name of the variable.
  11506. * @param array array to be set.
  11507. * @returns this effect.
  11508. */
  11509. setArray4(uniformName: string, array: number[]): Effect;
  11510. /**
  11511. * Sets matrices on a uniform variable.
  11512. * @param uniformName Name of the variable.
  11513. * @param matrices matrices to be set.
  11514. * @returns this effect.
  11515. */
  11516. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  11517. /**
  11518. * Sets matrix on a uniform variable.
  11519. * @param uniformName Name of the variable.
  11520. * @param matrix matrix to be set.
  11521. * @returns this effect.
  11522. */
  11523. setMatrix(uniformName: string, matrix: Matrix): Effect;
  11524. /**
  11525. * 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)
  11526. * @param uniformName Name of the variable.
  11527. * @param matrix matrix to be set.
  11528. * @returns this effect.
  11529. */
  11530. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  11531. /**
  11532. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  11533. * @param uniformName Name of the variable.
  11534. * @param matrix matrix to be set.
  11535. * @returns this effect.
  11536. */
  11537. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  11538. /**
  11539. * Sets a float on a uniform variable.
  11540. * @param uniformName Name of the variable.
  11541. * @param value value to be set.
  11542. * @returns this effect.
  11543. */
  11544. setFloat(uniformName: string, value: number): Effect;
  11545. /**
  11546. * Sets a boolean on a uniform variable.
  11547. * @param uniformName Name of the variable.
  11548. * @param bool value to be set.
  11549. * @returns this effect.
  11550. */
  11551. setBool(uniformName: string, bool: boolean): Effect;
  11552. /**
  11553. * Sets a Vector2 on a uniform variable.
  11554. * @param uniformName Name of the variable.
  11555. * @param vector2 vector2 to be set.
  11556. * @returns this effect.
  11557. */
  11558. setVector2(uniformName: string, vector2: Vector2): Effect;
  11559. /**
  11560. * Sets a float2 on a uniform variable.
  11561. * @param uniformName Name of the variable.
  11562. * @param x First float in float2.
  11563. * @param y Second float in float2.
  11564. * @returns this effect.
  11565. */
  11566. setFloat2(uniformName: string, x: number, y: number): Effect;
  11567. /**
  11568. * Sets a Vector3 on a uniform variable.
  11569. * @param uniformName Name of the variable.
  11570. * @param vector3 Value to be set.
  11571. * @returns this effect.
  11572. */
  11573. setVector3(uniformName: string, vector3: Vector3): Effect;
  11574. /**
  11575. * Sets a float3 on a uniform variable.
  11576. * @param uniformName Name of the variable.
  11577. * @param x First float in float3.
  11578. * @param y Second float in float3.
  11579. * @param z Third float in float3.
  11580. * @returns this effect.
  11581. */
  11582. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  11583. /**
  11584. * Sets a Vector4 on a uniform variable.
  11585. * @param uniformName Name of the variable.
  11586. * @param vector4 Value to be set.
  11587. * @returns this effect.
  11588. */
  11589. setVector4(uniformName: string, vector4: Vector4): Effect;
  11590. /**
  11591. * Sets a float4 on a uniform variable.
  11592. * @param uniformName Name of the variable.
  11593. * @param x First float in float4.
  11594. * @param y Second float in float4.
  11595. * @param z Third float in float4.
  11596. * @param w Fourth float in float4.
  11597. * @returns this effect.
  11598. */
  11599. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  11600. /**
  11601. * Sets a Color3 on a uniform variable.
  11602. * @param uniformName Name of the variable.
  11603. * @param color3 Value to be set.
  11604. * @returns this effect.
  11605. */
  11606. setColor3(uniformName: string, color3: Color3): Effect;
  11607. /**
  11608. * Sets a Color4 on a uniform variable.
  11609. * @param uniformName Name of the variable.
  11610. * @param color3 Value to be set.
  11611. * @param alpha Alpha value to be set.
  11612. * @returns this effect.
  11613. */
  11614. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  11615. /**
  11616. * Sets a Color4 on a uniform variable
  11617. * @param uniformName defines the name of the variable
  11618. * @param color4 defines the value to be set
  11619. * @returns this effect.
  11620. */
  11621. setDirectColor4(uniformName: string, color4: Color4): Effect;
  11622. /**
  11623. * Store of each shader (The can be looked up using effect.key)
  11624. */
  11625. static ShadersStore: {
  11626. [key: string]: string;
  11627. };
  11628. /**
  11629. * Store of each included file for a shader (The can be looked up using effect.key)
  11630. */
  11631. static IncludesShadersStore: {
  11632. [key: string]: string;
  11633. };
  11634. /**
  11635. * Resets the cache of effects.
  11636. */
  11637. static ResetCache(): void;
  11638. }
  11639. }
  11640. declare module BABYLON {
  11641. class FresnelParameters {
  11642. private _isEnabled;
  11643. isEnabled: boolean;
  11644. leftColor: Color3;
  11645. rightColor: Color3;
  11646. bias: number;
  11647. power: number;
  11648. clone(): FresnelParameters;
  11649. serialize(): any;
  11650. static Parse(parsedFresnelParameters: any): FresnelParameters;
  11651. }
  11652. }
  11653. declare module BABYLON {
  11654. /**
  11655. * Interface to follow in your material defines to integrate easily the
  11656. * Image proccessing functions.
  11657. * @ignore
  11658. */
  11659. interface IImageProcessingConfigurationDefines {
  11660. IMAGEPROCESSING: boolean;
  11661. VIGNETTE: boolean;
  11662. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11663. VIGNETTEBLENDMODEOPAQUE: boolean;
  11664. TONEMAPPING: boolean;
  11665. CONTRAST: boolean;
  11666. EXPOSURE: boolean;
  11667. COLORCURVES: boolean;
  11668. COLORGRADING: boolean;
  11669. COLORGRADING3D: boolean;
  11670. SAMPLER3DGREENDEPTH: boolean;
  11671. SAMPLER3DBGRMAP: boolean;
  11672. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11673. }
  11674. /**
  11675. * This groups together the common properties used for image processing either in direct forward pass
  11676. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11677. * or not.
  11678. */
  11679. class ImageProcessingConfiguration {
  11680. /**
  11681. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11682. */
  11683. colorCurves: Nullable<ColorCurves>;
  11684. private _colorCurvesEnabled;
  11685. /**
  11686. * Gets wether the color curves effect is enabled.
  11687. */
  11688. /**
  11689. * Sets wether the color curves effect is enabled.
  11690. */
  11691. colorCurvesEnabled: boolean;
  11692. /**
  11693. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11694. */
  11695. colorGradingTexture: Nullable<BaseTexture>;
  11696. private _colorGradingEnabled;
  11697. /**
  11698. * Gets wether the color grading effect is enabled.
  11699. */
  11700. /**
  11701. * Sets wether the color grading effect is enabled.
  11702. */
  11703. colorGradingEnabled: boolean;
  11704. private _colorGradingWithGreenDepth;
  11705. /**
  11706. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11707. */
  11708. /**
  11709. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11710. */
  11711. colorGradingWithGreenDepth: boolean;
  11712. private _colorGradingBGR;
  11713. /**
  11714. * Gets wether the color grading texture contains BGR values.
  11715. */
  11716. /**
  11717. * Sets wether the color grading texture contains BGR values.
  11718. */
  11719. colorGradingBGR: boolean;
  11720. _exposure: number;
  11721. /**
  11722. * Gets the Exposure used in the effect.
  11723. */
  11724. /**
  11725. * Sets the Exposure used in the effect.
  11726. */
  11727. exposure: number;
  11728. private _toneMappingEnabled;
  11729. /**
  11730. * Gets wether the tone mapping effect is enabled.
  11731. */
  11732. /**
  11733. * Sets wether the tone mapping effect is enabled.
  11734. */
  11735. toneMappingEnabled: boolean;
  11736. protected _contrast: number;
  11737. /**
  11738. * Gets the contrast used in the effect.
  11739. */
  11740. /**
  11741. * Sets the contrast used in the effect.
  11742. */
  11743. contrast: number;
  11744. /**
  11745. * Vignette stretch size.
  11746. */
  11747. vignetteStretch: number;
  11748. /**
  11749. * Vignette centre X Offset.
  11750. */
  11751. vignetteCentreX: number;
  11752. /**
  11753. * Vignette centre Y Offset.
  11754. */
  11755. vignetteCentreY: number;
  11756. /**
  11757. * Vignette weight or intensity of the vignette effect.
  11758. */
  11759. vignetteWeight: number;
  11760. /**
  11761. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  11762. * if vignetteEnabled is set to true.
  11763. */
  11764. vignetteColor: Color4;
  11765. /**
  11766. * Camera field of view used by the Vignette effect.
  11767. */
  11768. vignetteCameraFov: number;
  11769. private _vignetteBlendMode;
  11770. /**
  11771. * Gets the vignette blend mode allowing different kind of effect.
  11772. */
  11773. /**
  11774. * Sets the vignette blend mode allowing different kind of effect.
  11775. */
  11776. vignetteBlendMode: number;
  11777. private _vignetteEnabled;
  11778. /**
  11779. * Gets wether the vignette effect is enabled.
  11780. */
  11781. /**
  11782. * Sets wether the vignette effect is enabled.
  11783. */
  11784. vignetteEnabled: boolean;
  11785. private _applyByPostProcess;
  11786. /**
  11787. * Gets wether the image processing is applied through a post process or not.
  11788. */
  11789. /**
  11790. * Sets wether the image processing is applied through a post process or not.
  11791. */
  11792. applyByPostProcess: boolean;
  11793. private _isEnabled;
  11794. /**
  11795. * Gets wether the image processing is enabled or not.
  11796. */
  11797. /**
  11798. * Sets wether the image processing is enabled or not.
  11799. */
  11800. isEnabled: boolean;
  11801. /**
  11802. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  11803. */
  11804. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  11805. /**
  11806. * Method called each time the image processing information changes requires to recompile the effect.
  11807. */
  11808. protected _updateParameters(): void;
  11809. getClassName(): string;
  11810. /**
  11811. * Prepare the list of uniforms associated with the Image Processing effects.
  11812. * @param uniformsList The list of uniforms used in the effect
  11813. * @param defines the list of defines currently in use
  11814. */
  11815. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  11816. /**
  11817. * Prepare the list of samplers associated with the Image Processing effects.
  11818. * @param uniformsList The list of uniforms used in the effect
  11819. * @param defines the list of defines currently in use
  11820. */
  11821. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  11822. /**
  11823. * Prepare the list of defines associated to the shader.
  11824. * @param defines the list of defines to complete
  11825. */
  11826. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  11827. /**
  11828. * Returns true if all the image processing information are ready.
  11829. */
  11830. isReady(): boolean;
  11831. /**
  11832. * Binds the image processing to the shader.
  11833. * @param effect The effect to bind to
  11834. */
  11835. bind(effect: Effect, aspectRatio?: number): void;
  11836. /**
  11837. * Clones the current image processing instance.
  11838. * @return The cloned image processing
  11839. */
  11840. clone(): ImageProcessingConfiguration;
  11841. /**
  11842. * Serializes the current image processing instance to a json representation.
  11843. * @return a JSON representation
  11844. */
  11845. serialize(): any;
  11846. /**
  11847. * Parses the image processing from a json representation.
  11848. * @param source the JSON source to parse
  11849. * @return The parsed image processing
  11850. */
  11851. static Parse(source: any): ImageProcessingConfiguration;
  11852. private static _VIGNETTEMODE_MULTIPLY;
  11853. private static _VIGNETTEMODE_OPAQUE;
  11854. /**
  11855. * Used to apply the vignette as a mix with the pixel color.
  11856. */
  11857. static readonly VIGNETTEMODE_MULTIPLY: number;
  11858. /**
  11859. * Used to apply the vignette as a replacement of the pixel color.
  11860. */
  11861. static readonly VIGNETTEMODE_OPAQUE: number;
  11862. }
  11863. }
  11864. declare module BABYLON {
  11865. /**
  11866. * Manages the defines for the Material
  11867. */
  11868. class MaterialDefines {
  11869. private _keys;
  11870. private _isDirty;
  11871. /** @ignore */
  11872. _renderId: number;
  11873. /** @ignore */
  11874. _areLightsDirty: boolean;
  11875. /** @ignore */
  11876. _areAttributesDirty: boolean;
  11877. /** @ignore */
  11878. _areTexturesDirty: boolean;
  11879. /** @ignore */
  11880. _areFresnelDirty: boolean;
  11881. /** @ignore */
  11882. _areMiscDirty: boolean;
  11883. /** @ignore */
  11884. _areImageProcessingDirty: boolean;
  11885. /** @ignore */
  11886. _normals: boolean;
  11887. /** @ignore */
  11888. _uvs: boolean;
  11889. /** @ignore */
  11890. _needNormals: boolean;
  11891. /** @ignore */
  11892. _needUVs: boolean;
  11893. /**
  11894. * Specifies if the material needs to be re-calculated
  11895. */
  11896. readonly isDirty: boolean;
  11897. /**
  11898. * Marks the material to indicate that it has been re-calculated
  11899. */
  11900. markAsProcessed(): void;
  11901. /**
  11902. * Marks the material to indicate that it needs to be re-calculated
  11903. */
  11904. markAsUnprocessed(): void;
  11905. /**
  11906. * Marks the material to indicate all of its defines need to be re-calculated
  11907. */
  11908. markAllAsDirty(): void;
  11909. /**
  11910. * Marks the material to indicate that image processing needs to be re-calculated
  11911. */
  11912. markAsImageProcessingDirty(): void;
  11913. /**
  11914. * Marks the material to indicate the lights need to be re-calculated
  11915. */
  11916. markAsLightDirty(): void;
  11917. /**
  11918. * Marks the attribute state as changed
  11919. */
  11920. markAsAttributesDirty(): void;
  11921. /**
  11922. * Marks the texture state as changed
  11923. */
  11924. markAsTexturesDirty(): void;
  11925. /**
  11926. * Marks the fresnel state as changed
  11927. */
  11928. markAsFresnelDirty(): void;
  11929. /**
  11930. * Marks the misc state as changed
  11931. */
  11932. markAsMiscDirty(): void;
  11933. /**
  11934. * Rebuilds the material defines
  11935. */
  11936. rebuild(): void;
  11937. /**
  11938. * Specifies if two material defines are equal
  11939. * @param other - A material define instance to compare to
  11940. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  11941. */
  11942. isEqual(other: MaterialDefines): boolean;
  11943. /**
  11944. * Clones this instance's defines to another instance
  11945. * @param other - material defines to clone values to
  11946. */
  11947. cloneTo(other: MaterialDefines): void;
  11948. /**
  11949. * Resets the material define values
  11950. */
  11951. reset(): void;
  11952. /**
  11953. * Converts the material define values to a string
  11954. * @returns - String of material define information
  11955. */
  11956. toString(): string;
  11957. }
  11958. /**
  11959. * Base class for the main features of a material in Babylon.js
  11960. */
  11961. class Material implements IAnimatable {
  11962. private static _TriangleFillMode;
  11963. private static _WireFrameFillMode;
  11964. private static _PointFillMode;
  11965. private static _PointListDrawMode;
  11966. private static _LineListDrawMode;
  11967. private static _LineLoopDrawMode;
  11968. private static _LineStripDrawMode;
  11969. private static _TriangleStripDrawMode;
  11970. private static _TriangleFanDrawMode;
  11971. /**
  11972. * Returns the triangle fill mode
  11973. */
  11974. static readonly TriangleFillMode: number;
  11975. /**
  11976. * Returns the wireframe mode
  11977. */
  11978. static readonly WireFrameFillMode: number;
  11979. /**
  11980. * Returns the point fill mode
  11981. */
  11982. static readonly PointFillMode: number;
  11983. /**
  11984. * Returns the point list draw mode
  11985. */
  11986. static readonly PointListDrawMode: number;
  11987. /**
  11988. * Returns the line list draw mode
  11989. */
  11990. static readonly LineListDrawMode: number;
  11991. /**
  11992. * Returns the line loop draw mode
  11993. */
  11994. static readonly LineLoopDrawMode: number;
  11995. /**
  11996. * Returns the line strip draw mode
  11997. */
  11998. static readonly LineStripDrawMode: number;
  11999. /**
  12000. * Returns the triangle strip draw mode
  12001. */
  12002. static readonly TriangleStripDrawMode: number;
  12003. /**
  12004. * Returns the triangle fan draw mode
  12005. */
  12006. static readonly TriangleFanDrawMode: number;
  12007. /**
  12008. * Stores the clock-wise side orientation
  12009. */
  12010. private static _ClockWiseSideOrientation;
  12011. /**
  12012. * Stores the counter clock-wise side orientation
  12013. */
  12014. private static _CounterClockWiseSideOrientation;
  12015. /**
  12016. * Returns the clock-wise side orientation
  12017. */
  12018. static readonly ClockWiseSideOrientation: number;
  12019. /**
  12020. * Returns the counter clock-wise side orientation
  12021. */
  12022. static readonly CounterClockWiseSideOrientation: number;
  12023. /**
  12024. * The dirty texture flag value
  12025. */
  12026. private static _TextureDirtyFlag;
  12027. /**
  12028. * The dirty light flag value
  12029. */
  12030. private static _LightDirtyFlag;
  12031. /**
  12032. * The dirty fresnel flag value
  12033. */
  12034. private static _FresnelDirtyFlag;
  12035. /**
  12036. * The dirty attribute flag value
  12037. */
  12038. private static _AttributesDirtyFlag;
  12039. /**
  12040. * The dirty misc flag value
  12041. */
  12042. private static _MiscDirtyFlag;
  12043. /**
  12044. * Returns the dirty texture flag value
  12045. */
  12046. static readonly TextureDirtyFlag: number;
  12047. /**
  12048. * Returns the dirty light flag value
  12049. */
  12050. static readonly LightDirtyFlag: number;
  12051. /**
  12052. * Returns the dirty fresnel flag value
  12053. */
  12054. static readonly FresnelDirtyFlag: number;
  12055. /**
  12056. * Returns the dirty attributes flag value
  12057. */
  12058. static readonly AttributesDirtyFlag: number;
  12059. /**
  12060. * Returns the dirty misc flag value
  12061. */
  12062. static readonly MiscDirtyFlag: number;
  12063. /**
  12064. * The ID of the material
  12065. */
  12066. id: string;
  12067. /**
  12068. * The name of the material
  12069. */
  12070. name: string;
  12071. /**
  12072. * Specifies if the ready state should be checked on each call
  12073. */
  12074. checkReadyOnEveryCall: boolean;
  12075. /**
  12076. * Specifies if the ready state should be checked once
  12077. */
  12078. checkReadyOnlyOnce: boolean;
  12079. /**
  12080. * The state of the material
  12081. */
  12082. state: string;
  12083. /**
  12084. * The alpha value of the material
  12085. */
  12086. protected _alpha: number;
  12087. /**
  12088. * Gets the alpha value of the material
  12089. */
  12090. /**
  12091. * Sets the alpha value of the material
  12092. */
  12093. alpha: number;
  12094. /**
  12095. * Specifies if back face culling is enabled
  12096. */
  12097. protected _backFaceCulling: boolean;
  12098. /**
  12099. * Gets the back-face culling state
  12100. */
  12101. /**
  12102. * Sets the back-face culling state
  12103. */
  12104. backFaceCulling: boolean;
  12105. /**
  12106. * Stores the value for side orientation
  12107. */
  12108. sideOrientation: number;
  12109. /**
  12110. * Callback triggered when the material is compiled
  12111. */
  12112. onCompiled: (effect: Effect) => void;
  12113. /**
  12114. * Callback triggered when an error occurs
  12115. */
  12116. onError: (effect: Effect, errors: string) => void;
  12117. /**
  12118. * Callback triggered to get the render target textures
  12119. */
  12120. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  12121. /**
  12122. * Specifies if the material should be serialized
  12123. */
  12124. doNotSerialize: boolean;
  12125. /**
  12126. * Specifies if the effect should be stored on sub meshes
  12127. */
  12128. storeEffectOnSubMeshes: boolean;
  12129. /**
  12130. * Stores the animations for the material
  12131. */
  12132. animations: Array<Animation>;
  12133. /**
  12134. * An event triggered when the material is disposed
  12135. */
  12136. onDisposeObservable: Observable<Material>;
  12137. /**
  12138. * An observer which watches for dispose events
  12139. */
  12140. private _onDisposeObserver;
  12141. /**
  12142. * Called during a dispose event
  12143. */
  12144. onDispose: () => void;
  12145. /**
  12146. * An event triggered when the material is bound
  12147. */
  12148. onBindObservable: Observable<AbstractMesh>;
  12149. /**
  12150. * An observer which watches for bind events
  12151. */
  12152. private _onBindObserver;
  12153. /**
  12154. * Called during a bind event
  12155. */
  12156. onBind: (Mesh: AbstractMesh) => void;
  12157. /**
  12158. * An event triggered when the material is unbound
  12159. */
  12160. onUnBindObservable: Observable<Material>;
  12161. /**
  12162. * Stores the value of the alpha mode
  12163. */
  12164. private _alphaMode;
  12165. /**
  12166. * Gets the value of the alpha mode
  12167. */
  12168. /**
  12169. * Sets the value of the alpha mode.
  12170. *
  12171. * | Value | Type | Description |
  12172. * | --- | --- | --- |
  12173. * | 0 | ALPHA_DISABLE | |
  12174. * | 1 | ALPHA_ADD | |
  12175. * | 2 | ALPHA_COMBINE | |
  12176. * | 3 | ALPHA_SUBTRACT | |
  12177. * | 4 | ALPHA_MULTIPLY | |
  12178. * | 5 | ALPHA_MAXIMIZED | |
  12179. * | 6 | ALPHA_ONEONE | |
  12180. * | 7 | ALPHA_PREMULTIPLIED | |
  12181. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  12182. * | 9 | ALPHA_INTERPOLATE | |
  12183. * | 10 | ALPHA_SCREENMODE | |
  12184. *
  12185. */
  12186. alphaMode: number;
  12187. /**
  12188. * Stores the state of the need depth pre-pass value
  12189. */
  12190. private _needDepthPrePass;
  12191. /**
  12192. * Gets the depth pre-pass value
  12193. */
  12194. /**
  12195. * Sets the need depth pre-pass value
  12196. */
  12197. needDepthPrePass: boolean;
  12198. /**
  12199. * Specifies if depth writing should be disabled
  12200. */
  12201. disableDepthWrite: boolean;
  12202. /**
  12203. * Specifies if depth writing should be forced
  12204. */
  12205. forceDepthWrite: boolean;
  12206. /**
  12207. * Specifies if there should be a separate pass for culling
  12208. */
  12209. separateCullingPass: boolean;
  12210. /**
  12211. * Stores the state specifing if fog should be enabled
  12212. */
  12213. private _fogEnabled;
  12214. /**
  12215. * Gets the value of the fog enabled state
  12216. */
  12217. /**
  12218. * Sets the state for enabling fog
  12219. */
  12220. fogEnabled: boolean;
  12221. /**
  12222. * Stores the size of points
  12223. */
  12224. pointSize: number;
  12225. /**
  12226. * Stores the z offset value
  12227. */
  12228. zOffset: number;
  12229. /**
  12230. * Gets a value specifying if wireframe mode is enabled
  12231. */
  12232. /**
  12233. * Sets the state of wireframe mode
  12234. */
  12235. wireframe: boolean;
  12236. /**
  12237. * Gets the value specifying if point clouds are enabled
  12238. */
  12239. /**
  12240. * Sets the state of point cloud mode
  12241. */
  12242. pointsCloud: boolean;
  12243. /**
  12244. * Gets the material fill mode
  12245. */
  12246. /**
  12247. * Sets the material fill mode
  12248. */
  12249. fillMode: number;
  12250. /**
  12251. * Stores the effects for the material
  12252. */
  12253. _effect: Nullable<Effect>;
  12254. /**
  12255. * Specifies if the material was previously ready
  12256. */
  12257. _wasPreviouslyReady: boolean;
  12258. /**
  12259. * Specifies if uniform buffers should be used
  12260. */
  12261. private _useUBO;
  12262. /**
  12263. * Stores a reference to the scene
  12264. */
  12265. private _scene;
  12266. /**
  12267. * Stores the fill mode state
  12268. */
  12269. private _fillMode;
  12270. /**
  12271. * Specifies if the depth write state should be cached
  12272. */
  12273. private _cachedDepthWriteState;
  12274. /**
  12275. * Stores the uniform buffer
  12276. */
  12277. protected _uniformBuffer: UniformBuffer;
  12278. /**
  12279. * Creates a material instance
  12280. * @param name defines the name of the material
  12281. * @param scene defines the scene to reference
  12282. * @param doNotAdd specifies if the material should be added to the scene
  12283. */
  12284. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  12285. /**
  12286. * Returns a string representation of the current material
  12287. * @param fullDetails defines a boolean indicating which levels of logging is desired
  12288. * @returns a string with material information
  12289. */
  12290. toString(fullDetails?: boolean): string;
  12291. /**
  12292. * Gets the class name of the material
  12293. * @returns a string with the class name of the material
  12294. */
  12295. getClassName(): string;
  12296. /**
  12297. * Specifies if updates for the material been locked
  12298. */
  12299. readonly isFrozen: boolean;
  12300. /**
  12301. * Locks updates for the material
  12302. */
  12303. freeze(): void;
  12304. /**
  12305. * Unlocks updates for the material
  12306. */
  12307. unfreeze(): void;
  12308. /**
  12309. * Specifies if the material is ready to be used
  12310. * @param mesh defines the mesh to check
  12311. * @param useInstances specifies if instances should be used
  12312. * @returns a boolean indicating if the material is ready to be used
  12313. */
  12314. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12315. /**
  12316. * Specifies that the submesh is ready to be used
  12317. * @param mesh defines the mesh to check
  12318. * @param subMesh defines which submesh to check
  12319. * @param useInstances specifies that instances should be used
  12320. * @returns a boolean indicating that the submesh is ready or not
  12321. */
  12322. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12323. /**
  12324. * Returns the material effect
  12325. * @returns the effect associated with the material
  12326. */
  12327. getEffect(): Nullable<Effect>;
  12328. /**
  12329. * Returns the current scene
  12330. * @returns a Scene
  12331. */
  12332. getScene(): Scene;
  12333. /**
  12334. * Specifies if the material will require alpha blending
  12335. * @returns a boolean specifying if alpha blending is needed
  12336. */
  12337. needAlphaBlending(): boolean;
  12338. /**
  12339. * Specifies if the mesh will require alpha blending
  12340. * @param mesh defines the mesh to check
  12341. * @returns a boolean specifying if alpha blending is needed for the mesh
  12342. */
  12343. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  12344. /**
  12345. * Specifies if this material should be rendered in alpha test mode
  12346. * @returns a boolean specifying if an alpha test is needed.
  12347. */
  12348. needAlphaTesting(): boolean;
  12349. /**
  12350. * Gets the texture used for the alpha test
  12351. * @returns the texture to use for alpha testing
  12352. */
  12353. getAlphaTestTexture(): Nullable<BaseTexture>;
  12354. /**
  12355. * Marks the material to indicate that it needs to be re-calculated
  12356. */
  12357. markDirty(): void;
  12358. /** @ignore */
  12359. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  12360. /**
  12361. * Binds the material to the mesh
  12362. * @param world defines the world transformation matrix
  12363. * @param mesh defines the mesh to bind the material to
  12364. */
  12365. bind(world: Matrix, mesh?: Mesh): void;
  12366. /**
  12367. * Binds the submesh to the material
  12368. * @param world defines the world transformation matrix
  12369. * @param mesh defines the mesh containing the submesh
  12370. * @param subMesh defines the submesh to bind the material to
  12371. */
  12372. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  12373. /**
  12374. * Binds the world matrix to the material
  12375. * @param world defines the world transformation matrix
  12376. */
  12377. bindOnlyWorldMatrix(world: Matrix): void;
  12378. /**
  12379. * Binds the scene's uniform buffer to the effect.
  12380. * @param effect defines the effect to bind to the scene uniform buffer
  12381. * @param sceneUbo defines the uniform buffer storing scene data
  12382. */
  12383. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  12384. /**
  12385. * Binds the view matrix to the effect
  12386. * @param effect defines the effect to bind the view matrix to
  12387. */
  12388. bindView(effect: Effect): void;
  12389. /**
  12390. * Binds the view projection matrix to the effect
  12391. * @param effect defines the effect to bind the view projection matrix to
  12392. */
  12393. bindViewProjection(effect: Effect): void;
  12394. /**
  12395. * Specifies if material alpha testing should be turned on for the mesh
  12396. * @param mesh defines the mesh to check
  12397. */
  12398. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  12399. /**
  12400. * Processes to execute after binding the material to a mesh
  12401. * @param mesh defines the rendered mesh
  12402. */
  12403. protected _afterBind(mesh?: Mesh): void;
  12404. /**
  12405. * Unbinds the material from the mesh
  12406. */
  12407. unbind(): void;
  12408. /**
  12409. * Gets the active textures from the material
  12410. * @returns an array of textures
  12411. */
  12412. getActiveTextures(): BaseTexture[];
  12413. /**
  12414. * Specifies if the material uses a texture
  12415. * @param texture defines the texture to check against the material
  12416. * @returns a boolean specifying if the material uses the texture
  12417. */
  12418. hasTexture(texture: BaseTexture): boolean;
  12419. /**
  12420. * Makes a duplicate of the material, and gives it a new name
  12421. * @param name defines the new name for the duplicated material
  12422. * @returns the cloned material
  12423. */
  12424. clone(name: string): Nullable<Material>;
  12425. /**
  12426. * Gets the meshes bound to the material
  12427. * @returns an array of meshes bound to the material
  12428. */
  12429. getBindedMeshes(): AbstractMesh[];
  12430. /**
  12431. * Force shader compilation
  12432. * @param mesh defines the mesh associated with this material
  12433. * @param onCompiled defines a function to execute once the material is compiled
  12434. * @param options defines the options to configure the compilation
  12435. */
  12436. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  12437. clipPlane: boolean;
  12438. }>): void;
  12439. /**
  12440. * Force shader compilation
  12441. * @param mesh defines the mesh that will use this material
  12442. * @param options defines additional options for compiling the shaders
  12443. * @returns a promise that resolves when the compilation completes
  12444. */
  12445. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  12446. clipPlane: boolean;
  12447. }>): Promise<void>;
  12448. /**
  12449. * Marks a define in the material to indicate that it needs to be re-computed
  12450. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  12451. */
  12452. markAsDirty(flag: number): void;
  12453. /**
  12454. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  12455. * @param func defines a function which checks material defines against the submeshes
  12456. */
  12457. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  12458. /**
  12459. * Indicates that image processing needs to be re-calculated for all submeshes
  12460. */
  12461. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  12462. /**
  12463. * Indicates that textures need to be re-calculated for all submeshes
  12464. */
  12465. protected _markAllSubMeshesAsTexturesDirty(): void;
  12466. /**
  12467. * Indicates that fresnel needs to be re-calculated for all submeshes
  12468. */
  12469. protected _markAllSubMeshesAsFresnelDirty(): void;
  12470. /**
  12471. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  12472. */
  12473. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  12474. /**
  12475. * Indicates that lights need to be re-calculated for all submeshes
  12476. */
  12477. protected _markAllSubMeshesAsLightsDirty(): void;
  12478. /**
  12479. * Indicates that attributes need to be re-calculated for all submeshes
  12480. */
  12481. protected _markAllSubMeshesAsAttributesDirty(): void;
  12482. /**
  12483. * Indicates that misc needs to be re-calculated for all submeshes
  12484. */
  12485. protected _markAllSubMeshesAsMiscDirty(): void;
  12486. /**
  12487. * Indicates that textures and misc need to be re-calculated for all submeshes
  12488. */
  12489. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  12490. /**
  12491. * Disposes the material
  12492. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12493. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12494. */
  12495. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  12496. /**
  12497. * Serializes this material
  12498. * @returns the serialized material object
  12499. */
  12500. serialize(): any;
  12501. /**
  12502. * Creates a MultiMaterial from parsed MultiMaterial data.
  12503. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  12504. * @param scene defines the hosting scene
  12505. * @returns a new MultiMaterial
  12506. */
  12507. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  12508. /**
  12509. * Creates a material from parsed material data
  12510. * @param parsedMaterial defines parsed material data
  12511. * @param scene defines the hosting scene
  12512. * @param rootUrl defines the root URL to use to load textures
  12513. * @returns a new material
  12514. */
  12515. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  12516. }
  12517. }
  12518. declare module BABYLON {
  12519. /**
  12520. * "Static Class" containing the most commonly used helper while dealing with material for
  12521. * rendering purpose.
  12522. *
  12523. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  12524. *
  12525. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12526. */
  12527. class MaterialHelper {
  12528. /**
  12529. * Bind the current view position to an effect.
  12530. * @param effect The effect to be bound
  12531. * @param scene The scene the eyes position is used from
  12532. */
  12533. static BindEyePosition(effect: Effect, scene: Scene): void;
  12534. /**
  12535. * Helps preparing the defines values about the UVs in used in the effect.
  12536. * UVs are shared as much as we can accross chanels in the shaders.
  12537. * @param texture The texture we are preparing the UVs for
  12538. * @param defines The defines to update
  12539. * @param key The chanel key "diffuse", "specular"... used in the shader
  12540. */
  12541. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  12542. /**
  12543. * Binds a texture matrix value to its corrsponding uniform
  12544. * @param texture The texture to bind the matrix for
  12545. * @param uniformBuffer The uniform buffer receivin the data
  12546. * @param key The chanel key "diffuse", "specular"... used in the shader
  12547. */
  12548. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  12549. /**
  12550. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  12551. * @param mesh defines the current mesh
  12552. * @param scene defines the current scene
  12553. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  12554. * @param pointsCloud defines if point cloud rendering has to be turned on
  12555. * @param fogEnabled defines if fog has to be turned on
  12556. * @param alphaTest defines if alpha testing has to be turned on
  12557. * @param defines defines the current list of defines
  12558. */
  12559. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  12560. /**
  12561. * Helper used to prepare the list of defines associated with frame values for shader compilation
  12562. * @param scene defines the current scene
  12563. * @param engine defines the current engine
  12564. * @param defines specifies the list of active defines
  12565. * @param useInstances defines if instances have to be turned on
  12566. * @param useClipPlane defines if clip plane have to be turned on
  12567. */
  12568. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  12569. /**
  12570. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  12571. * @param mesh The mesh containing the geometry data we will draw
  12572. * @param defines The defines to update
  12573. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  12574. * @param useBones Precise whether bones should be used or not (override mesh info)
  12575. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  12576. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  12577. * @returns false if defines are considered not dirty and have not been checked
  12578. */
  12579. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  12580. /**
  12581. * Prepares the defines related to the light information passed in parameter
  12582. * @param scene The scene we are intending to draw
  12583. * @param mesh The mesh the effect is compiling for
  12584. * @param defines The defines to update
  12585. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  12586. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  12587. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  12588. * @returns true if normals will be required for the rest of the effect
  12589. */
  12590. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  12591. /**
  12592. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  12593. * that won t be acctive due to defines being turned off.
  12594. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  12595. * @param samplersList The samplers list
  12596. * @param defines The defines helping in the list generation
  12597. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  12598. */
  12599. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  12600. /**
  12601. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  12602. * @param defines The defines to update while falling back
  12603. * @param fallbacks The authorized effect fallbacks
  12604. * @param maxSimultaneousLights The maximum number of lights allowed
  12605. * @param rank the current rank of the Effect
  12606. * @returns The newly affected rank
  12607. */
  12608. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  12609. /**
  12610. * Prepares the list of attributes required for morph targets according to the effect defines.
  12611. * @param attribs The current list of supported attribs
  12612. * @param mesh The mesh to prepare the morph targets attributes for
  12613. * @param defines The current Defines of the effect
  12614. */
  12615. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  12616. /**
  12617. * Prepares the list of attributes required for bones according to the effect defines.
  12618. * @param attribs The current list of supported attribs
  12619. * @param mesh The mesh to prepare the bones attributes for
  12620. * @param defines The current Defines of the effect
  12621. * @param fallbacks The current efffect fallback strategy
  12622. */
  12623. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  12624. /**
  12625. * Prepares the list of attributes required for instances according to the effect defines.
  12626. * @param attribs The current list of supported attribs
  12627. * @param defines The current Defines of the effect
  12628. */
  12629. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  12630. /**
  12631. * Binds the light shadow information to the effect for the given mesh.
  12632. * @param light The light containing the generator
  12633. * @param scene The scene the lights belongs to
  12634. * @param mesh The mesh we are binding the information to render
  12635. * @param lightIndex The light index in the effect used to render the mesh
  12636. * @param effect The effect we are binding the data to
  12637. */
  12638. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  12639. /**
  12640. * Binds the light information to the effect.
  12641. * @param light The light containing the generator
  12642. * @param effect The effect we are binding the data to
  12643. * @param lightIndex The light index in the effect used to render
  12644. */
  12645. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  12646. /**
  12647. * Binds the lights information from the scene to the effect for the given mesh.
  12648. * @param scene The scene the lights belongs to
  12649. * @param mesh The mesh we are binding the information to render
  12650. * @param effect The effect we are binding the data to
  12651. * @param defines The generated defines for the effect
  12652. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  12653. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  12654. */
  12655. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  12656. /**
  12657. * Binds the fog information from the scene to the effect for the given mesh.
  12658. * @param scene The scene the lights belongs to
  12659. * @param mesh The mesh we are binding the information to render
  12660. * @param effect The effect we are binding the data to
  12661. */
  12662. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  12663. /**
  12664. * Binds the bones information from the mesh to the effect.
  12665. * @param mesh The mesh we are binding the information to render
  12666. * @param effect The effect we are binding the data to
  12667. */
  12668. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  12669. /**
  12670. * Binds the morph targets information from the mesh to the effect.
  12671. * @param abstractMesh The mesh we are binding the information to render
  12672. * @param effect The effect we are binding the data to
  12673. */
  12674. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  12675. /**
  12676. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  12677. * @param defines The generated defines used in the effect
  12678. * @param effect The effect we are binding the data to
  12679. * @param scene The scene we are willing to render with logarithmic scale for
  12680. */
  12681. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  12682. /**
  12683. * Binds the clip plane information from the scene to the effect.
  12684. * @param scene The scene the clip plane information are extracted from
  12685. * @param effect The effect we are binding the data to
  12686. */
  12687. static BindClipPlane(effect: Effect, scene: Scene): void;
  12688. }
  12689. }
  12690. declare module BABYLON {
  12691. class MultiMaterial extends Material {
  12692. private _subMaterials;
  12693. subMaterials: Nullable<Material>[];
  12694. constructor(name: string, scene: Scene);
  12695. private _hookArray(array);
  12696. getSubMaterial(index: number): Nullable<Material>;
  12697. getActiveTextures(): BaseTexture[];
  12698. getClassName(): string;
  12699. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12700. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  12701. serialize(): any;
  12702. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  12703. }
  12704. }
  12705. declare module BABYLON {
  12706. class PushMaterial extends Material {
  12707. protected _activeEffect: Effect;
  12708. protected _normalMatrix: Matrix;
  12709. constructor(name: string, scene: Scene);
  12710. getEffect(): Effect;
  12711. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12712. /**
  12713. * Binds the given world matrix to the active effect
  12714. *
  12715. * @param world the matrix to bind
  12716. */
  12717. bindOnlyWorldMatrix(world: Matrix): void;
  12718. /**
  12719. * Binds the given normal matrix to the active effect
  12720. *
  12721. * @param normalMatrix the matrix to bind
  12722. */
  12723. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  12724. bind(world: Matrix, mesh?: Mesh): void;
  12725. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  12726. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  12727. }
  12728. }
  12729. declare module BABYLON {
  12730. class ShaderMaterial extends Material {
  12731. private _shaderPath;
  12732. private _options;
  12733. private _textures;
  12734. private _textureArrays;
  12735. private _floats;
  12736. private _ints;
  12737. private _floatsArrays;
  12738. private _colors3;
  12739. private _colors3Arrays;
  12740. private _colors4;
  12741. private _vectors2;
  12742. private _vectors3;
  12743. private _vectors4;
  12744. private _matrices;
  12745. private _matrices3x3;
  12746. private _matrices2x2;
  12747. private _vectors2Arrays;
  12748. private _vectors3Arrays;
  12749. private _cachedWorldViewMatrix;
  12750. private _renderId;
  12751. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  12752. getClassName(): string;
  12753. needAlphaBlending(): boolean;
  12754. needAlphaTesting(): boolean;
  12755. private _checkUniform(uniformName);
  12756. setTexture(name: string, texture: Texture): ShaderMaterial;
  12757. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12758. setFloat(name: string, value: number): ShaderMaterial;
  12759. setInt(name: string, value: number): ShaderMaterial;
  12760. setFloats(name: string, value: number[]): ShaderMaterial;
  12761. setColor3(name: string, value: Color3): ShaderMaterial;
  12762. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12763. setColor4(name: string, value: Color4): ShaderMaterial;
  12764. setVector2(name: string, value: Vector2): ShaderMaterial;
  12765. setVector3(name: string, value: Vector3): ShaderMaterial;
  12766. setVector4(name: string, value: Vector4): ShaderMaterial;
  12767. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12768. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12769. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12770. setArray2(name: string, value: number[]): ShaderMaterial;
  12771. setArray3(name: string, value: number[]): ShaderMaterial;
  12772. private _checkCache(scene, mesh?, useInstances?);
  12773. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12774. bindOnlyWorldMatrix(world: Matrix): void;
  12775. bind(world: Matrix, mesh?: Mesh): void;
  12776. getActiveTextures(): BaseTexture[];
  12777. hasTexture(texture: BaseTexture): boolean;
  12778. clone(name: string): ShaderMaterial;
  12779. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  12780. serialize(): any;
  12781. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12782. }
  12783. }
  12784. declare module BABYLON {
  12785. /** @ignore */
  12786. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  12787. MAINUV1: boolean;
  12788. MAINUV2: boolean;
  12789. DIFFUSE: boolean;
  12790. DIFFUSEDIRECTUV: number;
  12791. AMBIENT: boolean;
  12792. AMBIENTDIRECTUV: number;
  12793. OPACITY: boolean;
  12794. OPACITYDIRECTUV: number;
  12795. OPACITYRGB: boolean;
  12796. REFLECTION: boolean;
  12797. EMISSIVE: boolean;
  12798. EMISSIVEDIRECTUV: number;
  12799. SPECULAR: boolean;
  12800. SPECULARDIRECTUV: number;
  12801. BUMP: boolean;
  12802. BUMPDIRECTUV: number;
  12803. PARALLAX: boolean;
  12804. PARALLAXOCCLUSION: boolean;
  12805. SPECULAROVERALPHA: boolean;
  12806. CLIPPLANE: boolean;
  12807. ALPHATEST: boolean;
  12808. DEPTHPREPASS: boolean;
  12809. ALPHAFROMDIFFUSE: boolean;
  12810. POINTSIZE: boolean;
  12811. FOG: boolean;
  12812. SPECULARTERM: boolean;
  12813. DIFFUSEFRESNEL: boolean;
  12814. OPACITYFRESNEL: boolean;
  12815. REFLECTIONFRESNEL: boolean;
  12816. REFRACTIONFRESNEL: boolean;
  12817. EMISSIVEFRESNEL: boolean;
  12818. FRESNEL: boolean;
  12819. NORMAL: boolean;
  12820. UV1: boolean;
  12821. UV2: boolean;
  12822. VERTEXCOLOR: boolean;
  12823. VERTEXALPHA: boolean;
  12824. NUM_BONE_INFLUENCERS: number;
  12825. BonesPerMesh: number;
  12826. INSTANCES: boolean;
  12827. GLOSSINESS: boolean;
  12828. ROUGHNESS: boolean;
  12829. EMISSIVEASILLUMINATION: boolean;
  12830. LINKEMISSIVEWITHDIFFUSE: boolean;
  12831. REFLECTIONFRESNELFROMSPECULAR: boolean;
  12832. LIGHTMAP: boolean;
  12833. LIGHTMAPDIRECTUV: number;
  12834. OBJECTSPACE_NORMALMAP: boolean;
  12835. USELIGHTMAPASSHADOWMAP: boolean;
  12836. REFLECTIONMAP_3D: boolean;
  12837. REFLECTIONMAP_SPHERICAL: boolean;
  12838. REFLECTIONMAP_PLANAR: boolean;
  12839. REFLECTIONMAP_CUBIC: boolean;
  12840. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  12841. REFLECTIONMAP_PROJECTION: boolean;
  12842. REFLECTIONMAP_SKYBOX: boolean;
  12843. REFLECTIONMAP_EXPLICIT: boolean;
  12844. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  12845. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  12846. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  12847. INVERTCUBICMAP: boolean;
  12848. LOGARITHMICDEPTH: boolean;
  12849. REFRACTION: boolean;
  12850. REFRACTIONMAP_3D: boolean;
  12851. REFLECTIONOVERALPHA: boolean;
  12852. TWOSIDEDLIGHTING: boolean;
  12853. SHADOWFLOAT: boolean;
  12854. MORPHTARGETS: boolean;
  12855. MORPHTARGETS_NORMAL: boolean;
  12856. MORPHTARGETS_TANGENT: boolean;
  12857. NUM_MORPH_INFLUENCERS: number;
  12858. NONUNIFORMSCALING: boolean;
  12859. PREMULTIPLYALPHA: boolean;
  12860. IMAGEPROCESSING: boolean;
  12861. VIGNETTE: boolean;
  12862. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12863. VIGNETTEBLENDMODEOPAQUE: boolean;
  12864. TONEMAPPING: boolean;
  12865. CONTRAST: boolean;
  12866. COLORCURVES: boolean;
  12867. COLORGRADING: boolean;
  12868. COLORGRADING3D: boolean;
  12869. SAMPLER3DGREENDEPTH: boolean;
  12870. SAMPLER3DBGRMAP: boolean;
  12871. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12872. /**
  12873. * If the reflection texture on this material is in linear color space
  12874. * @ignore
  12875. */
  12876. IS_REFLECTION_LINEAR: boolean;
  12877. /**
  12878. * If the refraction texture on this material is in linear color space
  12879. * @ignore
  12880. */
  12881. IS_REFRACTION_LINEAR: boolean;
  12882. EXPOSURE: boolean;
  12883. constructor();
  12884. setReflectionMode(modeToEnable: string): void;
  12885. }
  12886. class StandardMaterial extends PushMaterial {
  12887. private _diffuseTexture;
  12888. diffuseTexture: Nullable<BaseTexture>;
  12889. private _ambientTexture;
  12890. ambientTexture: Nullable<BaseTexture>;
  12891. private _opacityTexture;
  12892. opacityTexture: Nullable<BaseTexture>;
  12893. private _reflectionTexture;
  12894. reflectionTexture: Nullable<BaseTexture>;
  12895. private _emissiveTexture;
  12896. emissiveTexture: Nullable<BaseTexture>;
  12897. private _specularTexture;
  12898. specularTexture: Nullable<BaseTexture>;
  12899. private _bumpTexture;
  12900. bumpTexture: Nullable<BaseTexture>;
  12901. private _lightmapTexture;
  12902. lightmapTexture: Nullable<BaseTexture>;
  12903. private _refractionTexture;
  12904. refractionTexture: Nullable<BaseTexture>;
  12905. ambientColor: Color3;
  12906. diffuseColor: Color3;
  12907. specularColor: Color3;
  12908. emissiveColor: Color3;
  12909. specularPower: number;
  12910. private _useAlphaFromDiffuseTexture;
  12911. useAlphaFromDiffuseTexture: boolean;
  12912. private _useEmissiveAsIllumination;
  12913. useEmissiveAsIllumination: boolean;
  12914. private _linkEmissiveWithDiffuse;
  12915. linkEmissiveWithDiffuse: boolean;
  12916. private _useSpecularOverAlpha;
  12917. useSpecularOverAlpha: boolean;
  12918. private _useReflectionOverAlpha;
  12919. useReflectionOverAlpha: boolean;
  12920. private _disableLighting;
  12921. disableLighting: boolean;
  12922. private _useObjectSpaceNormalMap;
  12923. /**
  12924. * Allows using an object space normal map (instead of tangent space).
  12925. */
  12926. useObjectSpaceNormalMap: boolean;
  12927. private _useParallax;
  12928. useParallax: boolean;
  12929. private _useParallaxOcclusion;
  12930. useParallaxOcclusion: boolean;
  12931. parallaxScaleBias: number;
  12932. private _roughness;
  12933. roughness: number;
  12934. indexOfRefraction: number;
  12935. invertRefractionY: boolean;
  12936. private _useLightmapAsShadowmap;
  12937. useLightmapAsShadowmap: boolean;
  12938. private _diffuseFresnelParameters;
  12939. diffuseFresnelParameters: FresnelParameters;
  12940. private _opacityFresnelParameters;
  12941. opacityFresnelParameters: FresnelParameters;
  12942. private _reflectionFresnelParameters;
  12943. reflectionFresnelParameters: FresnelParameters;
  12944. private _refractionFresnelParameters;
  12945. refractionFresnelParameters: FresnelParameters;
  12946. private _emissiveFresnelParameters;
  12947. emissiveFresnelParameters: FresnelParameters;
  12948. private _useReflectionFresnelFromSpecular;
  12949. useReflectionFresnelFromSpecular: boolean;
  12950. private _useGlossinessFromSpecularMapAlpha;
  12951. useGlossinessFromSpecularMapAlpha: boolean;
  12952. private _maxSimultaneousLights;
  12953. maxSimultaneousLights: number;
  12954. /**
  12955. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  12956. */
  12957. private _invertNormalMapX;
  12958. invertNormalMapX: boolean;
  12959. /**
  12960. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  12961. */
  12962. private _invertNormalMapY;
  12963. invertNormalMapY: boolean;
  12964. /**
  12965. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  12966. */
  12967. private _twoSidedLighting;
  12968. twoSidedLighting: boolean;
  12969. /**
  12970. * Default configuration related to image processing available in the standard Material.
  12971. */
  12972. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12973. /**
  12974. * Gets the image processing configuration used either in this material.
  12975. */
  12976. /**
  12977. * Sets the Default image processing configuration used either in the this material.
  12978. *
  12979. * If sets to null, the scene one is in use.
  12980. */
  12981. imageProcessingConfiguration: ImageProcessingConfiguration;
  12982. /**
  12983. * Keep track of the image processing observer to allow dispose and replace.
  12984. */
  12985. private _imageProcessingObserver;
  12986. /**
  12987. * Attaches a new image processing configuration to the Standard Material.
  12988. * @param configuration
  12989. */
  12990. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12991. /**
  12992. * Gets wether the color curves effect is enabled.
  12993. */
  12994. /**
  12995. * Sets wether the color curves effect is enabled.
  12996. */
  12997. cameraColorCurvesEnabled: boolean;
  12998. /**
  12999. * Gets wether the color grading effect is enabled.
  13000. */
  13001. /**
  13002. * Gets wether the color grading effect is enabled.
  13003. */
  13004. cameraColorGradingEnabled: boolean;
  13005. /**
  13006. * Gets wether tonemapping is enabled or not.
  13007. */
  13008. /**
  13009. * Sets wether tonemapping is enabled or not
  13010. */
  13011. cameraToneMappingEnabled: boolean;
  13012. /**
  13013. * The camera exposure used on this material.
  13014. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  13015. * This corresponds to a photographic exposure.
  13016. */
  13017. /**
  13018. * The camera exposure used on this material.
  13019. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  13020. * This corresponds to a photographic exposure.
  13021. */
  13022. cameraExposure: number;
  13023. /**
  13024. * Gets The camera contrast used on this material.
  13025. */
  13026. /**
  13027. * Sets The camera contrast used on this material.
  13028. */
  13029. cameraContrast: number;
  13030. /**
  13031. * Gets the Color Grading 2D Lookup Texture.
  13032. */
  13033. /**
  13034. * Sets the Color Grading 2D Lookup Texture.
  13035. */
  13036. cameraColorGradingTexture: Nullable<BaseTexture>;
  13037. /**
  13038. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  13039. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  13040. * 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;
  13041. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  13042. */
  13043. /**
  13044. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  13045. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  13046. * 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;
  13047. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  13048. */
  13049. cameraColorCurves: Nullable<ColorCurves>;
  13050. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  13051. protected _renderTargets: SmartArray<RenderTargetTexture>;
  13052. protected _worldViewProjectionMatrix: Matrix;
  13053. protected _globalAmbientColor: Color3;
  13054. protected _useLogarithmicDepth: boolean;
  13055. constructor(name: string, scene: Scene);
  13056. getClassName(): string;
  13057. useLogarithmicDepth: boolean;
  13058. needAlphaBlending(): boolean;
  13059. needAlphaTesting(): boolean;
  13060. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  13061. getAlphaTestTexture(): Nullable<BaseTexture>;
  13062. /**
  13063. * Child classes can use it to update shaders
  13064. */
  13065. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  13066. buildUniformLayout(): void;
  13067. unbind(): void;
  13068. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  13069. getAnimatables(): IAnimatable[];
  13070. getActiveTextures(): BaseTexture[];
  13071. hasTexture(texture: BaseTexture): boolean;
  13072. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13073. clone(name: string): StandardMaterial;
  13074. serialize(): any;
  13075. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  13076. static _DiffuseTextureEnabled: boolean;
  13077. static DiffuseTextureEnabled: boolean;
  13078. static _AmbientTextureEnabled: boolean;
  13079. static AmbientTextureEnabled: boolean;
  13080. static _OpacityTextureEnabled: boolean;
  13081. static OpacityTextureEnabled: boolean;
  13082. static _ReflectionTextureEnabled: boolean;
  13083. static ReflectionTextureEnabled: boolean;
  13084. static _EmissiveTextureEnabled: boolean;
  13085. static EmissiveTextureEnabled: boolean;
  13086. static _SpecularTextureEnabled: boolean;
  13087. static SpecularTextureEnabled: boolean;
  13088. static _BumpTextureEnabled: boolean;
  13089. static BumpTextureEnabled: boolean;
  13090. static _LightmapTextureEnabled: boolean;
  13091. static LightmapTextureEnabled: boolean;
  13092. static _RefractionTextureEnabled: boolean;
  13093. static RefractionTextureEnabled: boolean;
  13094. static _ColorGradingTextureEnabled: boolean;
  13095. static ColorGradingTextureEnabled: boolean;
  13096. static _FresnelEnabled: boolean;
  13097. static FresnelEnabled: boolean;
  13098. }
  13099. }
  13100. declare module BABYLON {
  13101. class UniformBuffer {
  13102. private _engine;
  13103. private _buffer;
  13104. private _data;
  13105. private _bufferData;
  13106. private _dynamic?;
  13107. private _uniformLocations;
  13108. private _uniformSizes;
  13109. private _uniformLocationPointer;
  13110. private _needSync;
  13111. private _noUBO;
  13112. private _currentEffect;
  13113. private static _MAX_UNIFORM_SIZE;
  13114. private static _tempBuffer;
  13115. /**
  13116. * Wrapper for updateUniform.
  13117. * @method updateMatrix3x3
  13118. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13119. * @param {Float32Array} matrix
  13120. */
  13121. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  13122. /**
  13123. * Wrapper for updateUniform.
  13124. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13125. * @param {Float32Array} matrix
  13126. */
  13127. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  13128. /**
  13129. * Wrapper for updateUniform.
  13130. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13131. * @param {number} x
  13132. */
  13133. updateFloat: (name: string, x: number) => void;
  13134. /**
  13135. * Wrapper for updateUniform.
  13136. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13137. * @param {number} x
  13138. * @param {number} y
  13139. * @param {string} [suffix] Suffix to add to the uniform name.
  13140. */
  13141. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  13142. /**
  13143. * Wrapper for updateUniform.
  13144. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13145. * @param {number} x
  13146. * @param {number} y
  13147. * @param {number} z
  13148. * @param {string} [suffix] Suffix to add to the uniform name.
  13149. */
  13150. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  13151. /**
  13152. * Wrapper for updateUniform.
  13153. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13154. * @param {number} x
  13155. * @param {number} y
  13156. * @param {number} z
  13157. * @param {number} w
  13158. * @param {string} [suffix] Suffix to add to the uniform name.
  13159. */
  13160. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  13161. /**
  13162. * Wrapper for updateUniform.
  13163. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13164. * @param {Matrix} A 4x4 matrix.
  13165. */
  13166. updateMatrix: (name: string, mat: Matrix) => void;
  13167. /**
  13168. * Wrapper for updateUniform.
  13169. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13170. * @param {Vector3} vector
  13171. */
  13172. updateVector3: (name: string, vector: Vector3) => void;
  13173. /**
  13174. * Wrapper for updateUniform.
  13175. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13176. * @param {Vector4} vector
  13177. */
  13178. updateVector4: (name: string, vector: Vector4) => void;
  13179. /**
  13180. * Wrapper for updateUniform.
  13181. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13182. * @param {Color3} color
  13183. * @param {string} [suffix] Suffix to add to the uniform name.
  13184. */
  13185. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  13186. /**
  13187. * Wrapper for updateUniform.
  13188. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13189. * @param {Color3} color
  13190. * @param {number} alpha
  13191. * @param {string} [suffix] Suffix to add to the uniform name.
  13192. */
  13193. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  13194. /**
  13195. * Uniform buffer objects.
  13196. *
  13197. * Handles blocks of uniform on the GPU.
  13198. *
  13199. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  13200. *
  13201. * For more information, please refer to :
  13202. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  13203. */
  13204. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  13205. /**
  13206. * Indicates if the buffer is using the WebGL2 UBO implementation,
  13207. * or just falling back on setUniformXXX calls.
  13208. */
  13209. readonly useUbo: boolean;
  13210. /**
  13211. * Indicates if the WebGL underlying uniform buffer is in sync
  13212. * with the javascript cache data.
  13213. */
  13214. readonly isSync: boolean;
  13215. /**
  13216. * Indicates if the WebGL underlying uniform buffer is dynamic.
  13217. * Also, a dynamic UniformBuffer will disable cache verification and always
  13218. * update the underlying WebGL uniform buffer to the GPU.
  13219. */
  13220. isDynamic(): boolean;
  13221. /**
  13222. * The data cache on JS side.
  13223. */
  13224. getData(): Float32Array;
  13225. /**
  13226. * The underlying WebGL Uniform buffer.
  13227. */
  13228. getBuffer(): Nullable<WebGLBuffer>;
  13229. /**
  13230. * std140 layout specifies how to align data within an UBO structure.
  13231. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  13232. * for specs.
  13233. */
  13234. private _fillAlignment(size);
  13235. /**
  13236. * Adds an uniform in the buffer.
  13237. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  13238. * for the layout to be correct !
  13239. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13240. * @param {number|number[]} size Data size, or data directly.
  13241. */
  13242. addUniform(name: string, size: number | number[]): void;
  13243. /**
  13244. * Wrapper for addUniform.
  13245. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13246. * @param {Matrix} mat A 4x4 matrix.
  13247. */
  13248. addMatrix(name: string, mat: Matrix): void;
  13249. /**
  13250. * Wrapper for addUniform.
  13251. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13252. * @param {number} x
  13253. * @param {number} y
  13254. */
  13255. addFloat2(name: string, x: number, y: number): void;
  13256. /**
  13257. * Wrapper for addUniform.
  13258. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13259. * @param {number} x
  13260. * @param {number} y
  13261. * @param {number} z
  13262. */
  13263. addFloat3(name: string, x: number, y: number, z: number): void;
  13264. /**
  13265. * Wrapper for addUniform.
  13266. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13267. * @param {Color3} color
  13268. */
  13269. addColor3(name: string, color: Color3): void;
  13270. /**
  13271. * Wrapper for addUniform.
  13272. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13273. * @param {Color3} color
  13274. * @param {number} alpha
  13275. */
  13276. addColor4(name: string, color: Color3, alpha: number): void;
  13277. /**
  13278. * Wrapper for addUniform.
  13279. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13280. * @param {Vector3} vector
  13281. */
  13282. addVector3(name: string, vector: Vector3): void;
  13283. /**
  13284. * Wrapper for addUniform.
  13285. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13286. */
  13287. addMatrix3x3(name: string): void;
  13288. /**
  13289. * Wrapper for addUniform.
  13290. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13291. */
  13292. addMatrix2x2(name: string): void;
  13293. /**
  13294. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  13295. */
  13296. create(): void;
  13297. _rebuild(): void;
  13298. /**
  13299. * Updates the WebGL Uniform Buffer on the GPU.
  13300. * If the `dynamic` flag is set to true, no cache comparison is done.
  13301. * Otherwise, the buffer will be updated only if the cache differs.
  13302. */
  13303. update(): void;
  13304. /**
  13305. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  13306. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  13307. * @param {number[]|Float32Array} data Flattened data
  13308. * @param {number} size Size of the data.
  13309. */
  13310. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  13311. private _updateMatrix3x3ForUniform(name, matrix);
  13312. private _updateMatrix3x3ForEffect(name, matrix);
  13313. private _updateMatrix2x2ForEffect(name, matrix);
  13314. private _updateMatrix2x2ForUniform(name, matrix);
  13315. private _updateFloatForEffect(name, x);
  13316. private _updateFloatForUniform(name, x);
  13317. private _updateFloat2ForEffect(name, x, y, suffix?);
  13318. private _updateFloat2ForUniform(name, x, y, suffix?);
  13319. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  13320. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  13321. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  13322. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  13323. private _updateMatrixForEffect(name, mat);
  13324. private _updateMatrixForUniform(name, mat);
  13325. private _updateVector3ForEffect(name, vector);
  13326. private _updateVector3ForUniform(name, vector);
  13327. private _updateVector4ForEffect(name, vector);
  13328. private _updateVector4ForUniform(name, vector);
  13329. private _updateColor3ForEffect(name, color, suffix?);
  13330. private _updateColor3ForUniform(name, color, suffix?);
  13331. private _updateColor4ForEffect(name, color, alpha, suffix?);
  13332. private _updateColor4ForUniform(name, color, alpha, suffix?);
  13333. /**
  13334. * Sets a sampler uniform on the effect.
  13335. * @param {string} name Name of the sampler.
  13336. * @param {Texture} texture
  13337. */
  13338. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  13339. /**
  13340. * Directly updates the value of the uniform in the cache AND on the GPU.
  13341. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  13342. * @param {number[]|Float32Array} data Flattened data
  13343. */
  13344. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  13345. /**
  13346. * Binds this uniform buffer to an effect.
  13347. * @param {Effect} effect
  13348. * @param {string} name Name of the uniform block in the shader.
  13349. */
  13350. bindToEffect(effect: Effect, name: string): void;
  13351. /**
  13352. * Disposes the uniform buffer.
  13353. */
  13354. dispose(): void;
  13355. }
  13356. }
  13357. declare module BABYLON {
  13358. class Scalar {
  13359. /**
  13360. * Two pi constants convenient for computation.
  13361. */
  13362. static TwoPi: number;
  13363. /**
  13364. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  13365. */
  13366. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  13367. /**
  13368. * Returns a string : the upper case translation of the number i to hexadecimal.
  13369. */
  13370. static ToHex(i: number): string;
  13371. /**
  13372. * Returns -1 if value is negative and +1 is value is positive.
  13373. * Returns the value itself if it's equal to zero.
  13374. */
  13375. static Sign(value: number): number;
  13376. /**
  13377. * Returns the value itself if it's between min and max.
  13378. * Returns min if the value is lower than min.
  13379. * Returns max if the value is greater than max.
  13380. */
  13381. static Clamp(value: number, min?: number, max?: number): number;
  13382. /**
  13383. * Returns the log2 of value.
  13384. */
  13385. static Log2(value: number): number;
  13386. /**
  13387. * Loops the value, so that it is never larger than length and never smaller than 0.
  13388. *
  13389. * This is similar to the modulo operator but it works with floating point numbers.
  13390. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  13391. * With t = 5 and length = 2.5, the result would be 0.0.
  13392. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  13393. */
  13394. static Repeat(value: number, length: number): number;
  13395. /**
  13396. * Normalize the value between 0.0 and 1.0 using min and max values
  13397. */
  13398. static Normalize(value: number, min: number, max: number): number;
  13399. /**
  13400. * Denormalize the value from 0.0 and 1.0 using min and max values
  13401. */
  13402. static Denormalize(normalized: number, min: number, max: number): number;
  13403. /**
  13404. * Calculates the shortest difference between two given angles given in degrees.
  13405. */
  13406. static DeltaAngle(current: number, target: number): number;
  13407. /**
  13408. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  13409. *
  13410. * The returned value will move back and forth between 0 and length
  13411. */
  13412. static PingPong(tx: number, length: number): number;
  13413. /**
  13414. * Interpolates between min and max with smoothing at the limits.
  13415. *
  13416. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  13417. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  13418. */
  13419. static SmoothStep(from: number, to: number, tx: number): number;
  13420. /**
  13421. * Moves a value current towards target.
  13422. *
  13423. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  13424. * Negative values of maxDelta pushes the value away from target.
  13425. */
  13426. static MoveTowards(current: number, target: number, maxDelta: number): number;
  13427. /**
  13428. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  13429. *
  13430. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  13431. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  13432. */
  13433. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  13434. /**
  13435. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  13436. */
  13437. static Lerp(start: number, end: number, amount: number): number;
  13438. /**
  13439. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  13440. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  13441. */
  13442. static LerpAngle(start: number, end: number, amount: number): number;
  13443. /**
  13444. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  13445. */
  13446. static InverseLerp(a: number, b: number, value: number): number;
  13447. /**
  13448. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  13449. */
  13450. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  13451. /**
  13452. * Returns a random float number between and min and max values
  13453. */
  13454. static RandomRange(min: number, max: number): number;
  13455. /**
  13456. * This function returns percentage of a number in a given range.
  13457. *
  13458. * RangeToPercent(40,20,60) will return 0.5 (50%)
  13459. * RangeToPercent(34,0,100) will return 0.34 (34%)
  13460. */
  13461. static RangeToPercent(number: number, min: number, max: number): number;
  13462. /**
  13463. * This function returns number that corresponds to the percentage in a given range.
  13464. *
  13465. * PercentToRange(0.34,0,100) will return 34.
  13466. */
  13467. static PercentToRange(percent: number, min: number, max: number): number;
  13468. /**
  13469. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  13470. * @param angle The angle to normalize in radian.
  13471. * @return The converted angle.
  13472. */
  13473. static NormalizeRadians(angle: number): number;
  13474. }
  13475. }
  13476. declare module BABYLON {
  13477. const ToGammaSpace: number;
  13478. const ToLinearSpace = 2.2;
  13479. const Epsilon = 0.001;
  13480. /**
  13481. * Class used to hold a RBG color
  13482. */
  13483. class Color3 {
  13484. /**
  13485. * Defines the red component (between 0 and 1, default is 0)
  13486. */
  13487. r: number;
  13488. /**
  13489. * Defines the green component (between 0 and 1, default is 0)
  13490. */
  13491. g: number;
  13492. /**
  13493. * Defines the blue component (between 0 and 1, default is 0)
  13494. */
  13495. b: number;
  13496. /**
  13497. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  13498. * @param r defines the red component (between 0 and 1, default is 0)
  13499. * @param g defines the green component (between 0 and 1, default is 0)
  13500. * @param b defines the blue component (between 0 and 1, default is 0)
  13501. */
  13502. constructor(
  13503. /**
  13504. * Defines the red component (between 0 and 1, default is 0)
  13505. */
  13506. r?: number,
  13507. /**
  13508. * Defines the green component (between 0 and 1, default is 0)
  13509. */
  13510. g?: number,
  13511. /**
  13512. * Defines the blue component (between 0 and 1, default is 0)
  13513. */
  13514. b?: number);
  13515. /**
  13516. * Creates a string with the Color3 current values
  13517. * @returns the string representation of the Color3 object
  13518. */
  13519. toString(): string;
  13520. /**
  13521. * Returns the string "Color3"
  13522. * @returns "Color3"
  13523. */
  13524. getClassName(): string;
  13525. /**
  13526. * Compute the Color3 hash code
  13527. * @returns an unique number that can be used to hash Color3 objects
  13528. */
  13529. getHashCode(): number;
  13530. /**
  13531. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  13532. * @param array defines the array where to store the r,g,b components
  13533. * @param index defines an optional index in the target array to define where to start storing values
  13534. * @returns the current Color3 object
  13535. */
  13536. toArray(array: FloatArray, index?: number): Color3;
  13537. /**
  13538. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  13539. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  13540. * @returns a new {BABYLON.Color4} object
  13541. */
  13542. toColor4(alpha?: number): Color4;
  13543. /**
  13544. * Returns a new array populated with 3 numeric elements : red, green and blue values
  13545. * @returns the new array
  13546. */
  13547. asArray(): number[];
  13548. /**
  13549. * Returns the luminance value
  13550. * @returns a float value
  13551. */
  13552. toLuminance(): number;
  13553. /**
  13554. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  13555. * @param otherColor defines the second operand
  13556. * @returns the new Color3 object
  13557. */
  13558. multiply(otherColor: Color3): Color3;
  13559. /**
  13560. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  13561. * @param otherColor defines the second operand
  13562. * @param result defines the Color3 object where to store the result
  13563. * @returns the current Color3
  13564. */
  13565. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  13566. /**
  13567. * Determines equality between Color3 objects
  13568. * @param otherColor defines the second operand
  13569. * @returns true if the rgb values are equal to the given ones
  13570. */
  13571. equals(otherColor: Color3): boolean;
  13572. /**
  13573. * Determines equality between the current Color3 object and a set of r,b,g values
  13574. * @param r defines the red component to check
  13575. * @param g defines the green component to check
  13576. * @param b defines the blue component to check
  13577. * @returns true if the rgb values are equal to the given ones
  13578. */
  13579. equalsFloats(r: number, g: number, b: number): boolean;
  13580. /**
  13581. * Multiplies in place each rgb value by scale
  13582. * @param scale defines the scaling factor
  13583. * @returns the updated Color3
  13584. */
  13585. scale(scale: number): Color3;
  13586. /**
  13587. * Multiplies the rgb values by scale and stores the result into "result"
  13588. * @param scale defines the scaling factor
  13589. * @param result defines the Color3 object where to store the result
  13590. * @returns the unmodified current Color3
  13591. */
  13592. scaleToRef(scale: number, result: Color3): Color3;
  13593. /**
  13594. * Scale the current Color3 values by a factor and add the result to a given Color3
  13595. * @param scale defines the scale factor
  13596. * @param result defines color to store the result into
  13597. * @returns the unmodified current Color3
  13598. */
  13599. scaleAndAddToRef(scale: number, result: Color3): Color3;
  13600. /**
  13601. * Clamps the rgb values by the min and max values and stores the result into "result"
  13602. * @param min defines minimum clamping value (default is 0)
  13603. * @param max defines maximum clamping value (default is 1)
  13604. * @param result defines color to store the result into
  13605. * @returns the original Color3
  13606. */
  13607. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  13608. /**
  13609. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  13610. * @param otherColor defines the second operand
  13611. * @returns the new Color3
  13612. */
  13613. add(otherColor: Color3): Color3;
  13614. /**
  13615. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  13616. * @param otherColor defines the second operand
  13617. * @param result defines Color3 object to store the result into
  13618. * @returns the unmodified current Color3
  13619. */
  13620. addToRef(otherColor: Color3, result: Color3): Color3;
  13621. /**
  13622. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  13623. * @param otherColor defines the second operand
  13624. * @returns the new Color3
  13625. */
  13626. subtract(otherColor: Color3): Color3;
  13627. /**
  13628. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  13629. * @param otherColor defines the second operand
  13630. * @param result defines Color3 object to store the result into
  13631. * @returns the unmodified current Color3
  13632. */
  13633. subtractToRef(otherColor: Color3, result: Color3): Color3;
  13634. /**
  13635. * Copy the current object
  13636. * @returns a new Color3 copied the current one
  13637. */
  13638. clone(): Color3;
  13639. /**
  13640. * Copies the rgb values from the source in the current Color3
  13641. * @param source defines the source Color3 object
  13642. * @returns the updated Color3 object
  13643. */
  13644. copyFrom(source: Color3): Color3;
  13645. /**
  13646. * Updates the Color3 rgb values from the given floats
  13647. * @param r defines the red component to read from
  13648. * @param g defines the green component to read from
  13649. * @param b defines the blue component to read from
  13650. * @returns the current Color3 object
  13651. */
  13652. copyFromFloats(r: number, g: number, b: number): Color3;
  13653. /**
  13654. * Updates the Color3 rgb values from the given floats
  13655. * @param r defines the red component to read from
  13656. * @param g defines the green component to read from
  13657. * @param b defines the blue component to read from
  13658. * @returns the current Color3 object
  13659. */
  13660. set(r: number, g: number, b: number): Color3;
  13661. /**
  13662. * Compute the Color3 hexadecimal code as a string
  13663. * @returns a string containing the hexadecimal representation of the Color3 object
  13664. */
  13665. toHexString(): string;
  13666. /**
  13667. * Computes a new Color3 converted from the current one to linear space
  13668. * @returns a new Color3 object
  13669. */
  13670. toLinearSpace(): Color3;
  13671. /**
  13672. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  13673. * @param convertedColor defines the Color3 object where to store the linear space version
  13674. * @returns the unmodified Color3
  13675. */
  13676. toLinearSpaceToRef(convertedColor: Color3): Color3;
  13677. /**
  13678. * Computes a new Color3 converted from the current one to gamma space
  13679. * @returns a new Color3 object
  13680. */
  13681. toGammaSpace(): Color3;
  13682. /**
  13683. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  13684. * @param convertedColor defines the Color3 object where to store the gamma space version
  13685. * @returns the unmodified Color3
  13686. */
  13687. toGammaSpaceToRef(convertedColor: Color3): Color3;
  13688. /**
  13689. * Creates a new Color3 from the string containing valid hexadecimal values
  13690. * @param hex defines a string containing valid hexadecimal values
  13691. * @returns a new Color3 object
  13692. */
  13693. static FromHexString(hex: string): Color3;
  13694. /**
  13695. * Creates a new Vector3 from the starting index of the given array
  13696. * @param array defines the source array
  13697. * @param offset defines an offset in the source array
  13698. * @returns a new Color3 object
  13699. */
  13700. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  13701. /**
  13702. * Creates a new Color3 from integer values (< 256)
  13703. * @param r defines the red component to read from (value between 0 and 255)
  13704. * @param g defines the green component to read from (value between 0 and 255)
  13705. * @param b defines the blue component to read from (value between 0 and 255)
  13706. * @returns a new Color3 object
  13707. */
  13708. static FromInts(r: number, g: number, b: number): Color3;
  13709. /**
  13710. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  13711. * @param start defines the start Color3 value
  13712. * @param end defines the end Color3 value
  13713. * @param amount defines the gradient value between start and end
  13714. * @returns a new Color3 object
  13715. */
  13716. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  13717. /**
  13718. * Returns a Color3 value containing a red color
  13719. * @returns a new Color3 object
  13720. */
  13721. static Red(): Color3;
  13722. /**
  13723. * Returns a Color3 value containing a green color
  13724. * @returns a new Color3 object
  13725. */
  13726. static Green(): Color3;
  13727. /**
  13728. * Returns a Color3 value containing a blue color
  13729. * @returns a new Color3 object
  13730. */
  13731. static Blue(): Color3;
  13732. /**
  13733. * Returns a Color3 value containing a black color
  13734. * @returns a new Color3 object
  13735. */
  13736. static Black(): Color3;
  13737. /**
  13738. * Returns a Color3 value containing a white color
  13739. * @returns a new Color3 object
  13740. */
  13741. static White(): Color3;
  13742. /**
  13743. * Returns a Color3 value containing a purple color
  13744. * @returns a new Color3 object
  13745. */
  13746. static Purple(): Color3;
  13747. /**
  13748. * Returns a Color3 value containing a magenta color
  13749. * @returns a new Color3 object
  13750. */
  13751. static Magenta(): Color3;
  13752. /**
  13753. * Returns a Color3 value containing a yellow color
  13754. * @returns a new Color3 object
  13755. */
  13756. static Yellow(): Color3;
  13757. /**
  13758. * Returns a Color3 value containing a gray color
  13759. * @returns a new Color3 object
  13760. */
  13761. static Gray(): Color3;
  13762. /**
  13763. * Returns a Color3 value containing a teal color
  13764. * @returns a new Color3 object
  13765. */
  13766. static Teal(): Color3;
  13767. /**
  13768. * Returns a Color3 value containing a random color
  13769. * @returns a new Color3 object
  13770. */
  13771. static Random(): Color3;
  13772. }
  13773. /**
  13774. * Class used to hold a RBGA color
  13775. */
  13776. class Color4 {
  13777. /**
  13778. * Defines the red component (between 0 and 1, default is 0)
  13779. */
  13780. r: number;
  13781. /**
  13782. * Defines the green component (between 0 and 1, default is 0)
  13783. */
  13784. g: number;
  13785. /**
  13786. * Defines the blue component (between 0 and 1, default is 0)
  13787. */
  13788. b: number;
  13789. /**
  13790. * Defines the alpha component (between 0 and 1, default is 1)
  13791. */
  13792. a: number;
  13793. /**
  13794. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  13795. * @param r defines the red component (between 0 and 1, default is 0)
  13796. * @param g defines the green component (between 0 and 1, default is 0)
  13797. * @param b defines the blue component (between 0 and 1, default is 0)
  13798. * @param a defines the alpha component (between 0 and 1, default is 1)
  13799. */
  13800. constructor(
  13801. /**
  13802. * Defines the red component (between 0 and 1, default is 0)
  13803. */
  13804. r?: number,
  13805. /**
  13806. * Defines the green component (between 0 and 1, default is 0)
  13807. */
  13808. g?: number,
  13809. /**
  13810. * Defines the blue component (between 0 and 1, default is 0)
  13811. */
  13812. b?: number,
  13813. /**
  13814. * Defines the alpha component (between 0 and 1, default is 1)
  13815. */
  13816. a?: number);
  13817. /**
  13818. * Adds in place the given Color4 values to the current Color4 object
  13819. * @param right defines the second operand
  13820. * @returns the current updated Color4 object
  13821. */
  13822. addInPlace(right: Color4): Color4;
  13823. /**
  13824. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  13825. * @returns the new array
  13826. */
  13827. asArray(): number[];
  13828. /**
  13829. * Stores from the starting index in the given array the Color4 successive values
  13830. * @param array defines the array where to store the r,g,b components
  13831. * @param index defines an optional index in the target array to define where to start storing values
  13832. * @returns the current Color4 object
  13833. */
  13834. toArray(array: number[], index?: number): Color4;
  13835. /**
  13836. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  13837. * @param right defines the second operand
  13838. * @returns a new Color4 object
  13839. */
  13840. add(right: Color4): Color4;
  13841. /**
  13842. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  13843. * @param right defines the second operand
  13844. * @returns a new Color4 object
  13845. */
  13846. subtract(right: Color4): Color4;
  13847. /**
  13848. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  13849. * @param right defines the second operand
  13850. * @param result defines the Color4 object where to store the result
  13851. * @returns the current Color4 object
  13852. */
  13853. subtractToRef(right: Color4, result: Color4): Color4;
  13854. /**
  13855. * Creates a new Color4 with the current Color4 values multiplied by scale
  13856. * @param scale defines the scaling factor to apply
  13857. * @returns a new Color4 object
  13858. */
  13859. scale(scale: number): Color4;
  13860. /**
  13861. * Multiplies the current Color4 values by scale and stores the result in "result"
  13862. * @param scale defines the scaling factor to apply
  13863. * @param result defines the Color4 object where to store the result
  13864. * @returns the current unmodified Color4
  13865. */
  13866. scaleToRef(scale: number, result: Color4): Color4;
  13867. /**
  13868. * Scale the current Color4 values by a factor and add the result to a given Color4
  13869. * @param scale defines the scale factor
  13870. * @param result defines the Color4 object where to store the result
  13871. * @returns the unmodified current Color4
  13872. */
  13873. scaleAndAddToRef(scale: number, result: Color4): Color4;
  13874. /**
  13875. * Clamps the rgb values by the min and max values and stores the result into "result"
  13876. * @param min defines minimum clamping value (default is 0)
  13877. * @param max defines maximum clamping value (default is 1)
  13878. * @param result defines color to store the result into.
  13879. * @returns the cuurent Color4
  13880. */
  13881. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  13882. /**
  13883. * Multipy an Color4 value by another and return a new Color4 object
  13884. * @param color defines the Color4 value to multiply by
  13885. * @returns a new Color4 object
  13886. */
  13887. multiply(color: Color4): Color4;
  13888. /**
  13889. * Multipy a Color4 value by another and push the result in a reference value
  13890. * @param color defines the Color4 value to multiply by
  13891. * @param result defines the Color4 to fill the result in
  13892. * @returns the result Color4
  13893. */
  13894. multiplyToRef(color: Color4, result: Color4): Color4;
  13895. /**
  13896. * Creates a string with the Color4 current values
  13897. * @returns the string representation of the Color4 object
  13898. */
  13899. toString(): string;
  13900. /**
  13901. * Returns the string "Color4"
  13902. * @returns "Color4"
  13903. */
  13904. getClassName(): string;
  13905. /**
  13906. * Compute the Color4 hash code
  13907. * @returns an unique number that can be used to hash Color4 objects
  13908. */
  13909. getHashCode(): number;
  13910. /**
  13911. * Creates a new Color4 copied from the current one
  13912. * @returns a new Color4 object
  13913. */
  13914. clone(): Color4;
  13915. /**
  13916. * Copies the given Color4 values into the current one
  13917. * @param source defines the source Color4 object
  13918. * @returns the current updated Color4 object
  13919. */
  13920. copyFrom(source: Color4): Color4;
  13921. /**
  13922. * Copies the given float values into the current one
  13923. * @param r defines the red component to read from
  13924. * @param g defines the green component to read from
  13925. * @param b defines the blue component to read from
  13926. * @param a defines the alpha component to read from
  13927. * @returns the current updated Color4 object
  13928. */
  13929. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  13930. /**
  13931. * Copies the given float values into the current one
  13932. * @param r defines the red component to read from
  13933. * @param g defines the green component to read from
  13934. * @param b defines the blue component to read from
  13935. * @param a defines the alpha component to read from
  13936. * @returns the current updated Color4 object
  13937. */
  13938. set(r: number, g: number, b: number, a: number): Color4;
  13939. /**
  13940. * Compute the Color4 hexadecimal code as a string
  13941. * @returns a string containing the hexadecimal representation of the Color4 object
  13942. */
  13943. toHexString(): string;
  13944. /**
  13945. * Computes a new Color4 converted from the current one to linear space
  13946. * @returns a new Color4 object
  13947. */
  13948. toLinearSpace(): Color4;
  13949. /**
  13950. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  13951. * @param convertedColor defines the Color4 object where to store the linear space version
  13952. * @returns the unmodified Color4
  13953. */
  13954. toLinearSpaceToRef(convertedColor: Color4): Color4;
  13955. /**
  13956. * Computes a new Color4 converted from the current one to gamma space
  13957. * @returns a new Color4 object
  13958. */
  13959. toGammaSpace(): Color4;
  13960. /**
  13961. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  13962. * @param convertedColor defines the Color4 object where to store the gamma space version
  13963. * @returns the unmodified Color4
  13964. */
  13965. toGammaSpaceToRef(convertedColor: Color4): Color4;
  13966. /**
  13967. * Creates a new Color4 from the string containing valid hexadecimal values
  13968. * @param hex defines a string containing valid hexadecimal values
  13969. * @returns a new Color4 object
  13970. */
  13971. static FromHexString(hex: string): Color4;
  13972. /**
  13973. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  13974. * @param left defines the start value
  13975. * @param right defines the end value
  13976. * @param amount defines the gradient factor
  13977. * @returns a new Color4 object
  13978. */
  13979. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  13980. /**
  13981. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  13982. * @param left defines the start value
  13983. * @param right defines the end value
  13984. * @param amount defines the gradient factor
  13985. * @param result defines the Color4 object where to store data
  13986. */
  13987. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  13988. /**
  13989. * Creates a new Color4 from the starting index element of the given array
  13990. * @param array defines the source array to read from
  13991. * @param offset defines the offset in the source array
  13992. * @returns a new Color4 object
  13993. */
  13994. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  13995. /**
  13996. * Creates a new Color3 from integer values (< 256)
  13997. * @param r defines the red component to read from (value between 0 and 255)
  13998. * @param g defines the green component to read from (value between 0 and 255)
  13999. * @param b defines the blue component to read from (value between 0 and 255)
  14000. * @param a defines the alpha component to read from (value between 0 and 255)
  14001. * @returns a new Color3 object
  14002. */
  14003. static FromInts(r: number, g: number, b: number, a: number): Color4;
  14004. /**
  14005. * Check the content of a given array and convert it to an array containing RGBA data
  14006. * If the original array was already containing count * 4 values then it is returned directly
  14007. * @param colors defines the array to check
  14008. * @param count defines the number of RGBA data to expect
  14009. * @returns an array containing count * 4 values (RGBA)
  14010. */
  14011. static CheckColors4(colors: number[], count: number): number[];
  14012. }
  14013. class Vector2 {
  14014. x: number;
  14015. y: number;
  14016. /**
  14017. * Creates a new Vector2 from the given x and y coordinates.
  14018. */
  14019. constructor(x: number, y: number);
  14020. /**
  14021. * Returns a string with the Vector2 coordinates.
  14022. */
  14023. toString(): string;
  14024. /**
  14025. * Returns the string "Vector2"
  14026. */
  14027. getClassName(): string;
  14028. /**
  14029. * Returns the Vector2 hash code as a number.
  14030. */
  14031. getHashCode(): number;
  14032. /**
  14033. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  14034. * Returns the Vector2.
  14035. */
  14036. toArray(array: FloatArray, index?: number): Vector2;
  14037. /**
  14038. * Returns a new array with 2 elements : the Vector2 coordinates.
  14039. */
  14040. asArray(): number[];
  14041. /**
  14042. * Sets the Vector2 coordinates with the given Vector2 coordinates.
  14043. * Returns the updated Vector2.
  14044. */
  14045. copyFrom(source: Vector2): Vector2;
  14046. /**
  14047. * Sets the Vector2 coordinates with the given floats.
  14048. * Returns the updated Vector2.
  14049. */
  14050. copyFromFloats(x: number, y: number): Vector2;
  14051. /**
  14052. * Sets the Vector2 coordinates with the given floats.
  14053. * Returns the updated Vector2.
  14054. */
  14055. set(x: number, y: number): Vector2;
  14056. /**
  14057. * Returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates.
  14058. */
  14059. add(otherVector: Vector2): Vector2;
  14060. /**
  14061. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates.
  14062. * Returns the Vector2.
  14063. */
  14064. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  14065. /**
  14066. * Set the Vector2 coordinates by adding the given Vector2 coordinates.
  14067. * Returns the updated Vector2.
  14068. */
  14069. addInPlace(otherVector: Vector2): Vector2;
  14070. /**
  14071. * Returns a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates.
  14072. */
  14073. addVector3(otherVector: Vector3): Vector2;
  14074. /**
  14075. * Returns a new Vector2 set with the subtracted coordinates of the given one from the current Vector2.
  14076. */
  14077. subtract(otherVector: Vector2): Vector2;
  14078. /**
  14079. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  14080. * Returns the Vector2.
  14081. */
  14082. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  14083. /**
  14084. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates.
  14085. * Returns the updated Vector2.
  14086. */
  14087. subtractInPlace(otherVector: Vector2): Vector2;
  14088. /**
  14089. * Multiplies in place the current Vector2 coordinates by the given ones.
  14090. * Returns the updated Vector2.
  14091. */
  14092. multiplyInPlace(otherVector: Vector2): Vector2;
  14093. /**
  14094. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates.
  14095. */
  14096. multiply(otherVector: Vector2): Vector2;
  14097. /**
  14098. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates.
  14099. * Returns the Vector2.
  14100. */
  14101. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  14102. /**
  14103. * Returns a new Vector2 set with the Vector2 coordinates multiplied by the given floats.
  14104. */
  14105. multiplyByFloats(x: number, y: number): Vector2;
  14106. /**
  14107. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates.
  14108. */
  14109. divide(otherVector: Vector2): Vector2;
  14110. /**
  14111. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates.
  14112. * Returns the Vector2.
  14113. */
  14114. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  14115. /**
  14116. * Divides the current Vector3 coordinates by the given ones.
  14117. * Returns the updated Vector3.
  14118. */
  14119. divideInPlace(otherVector: Vector2): Vector2;
  14120. /**
  14121. * Returns a new Vector2 with current Vector2 negated coordinates.
  14122. */
  14123. negate(): Vector2;
  14124. /**
  14125. * Multiply the Vector2 coordinates by scale.
  14126. * Returns the updated Vector2.
  14127. */
  14128. scaleInPlace(scale: number): Vector2;
  14129. /**
  14130. * Returns a new Vector2 scaled by "scale" from the current Vector2.
  14131. */
  14132. scale(scale: number): Vector2;
  14133. /**
  14134. * Scale the current Vector2 values by a factor to a given Vector2
  14135. * @param scale defines the scale factor
  14136. * @param result defines the Vector2 object where to store the result
  14137. * @returns the unmodified current Vector2
  14138. */
  14139. scaleToRef(scale: number, result: Vector2): Vector2;
  14140. /**
  14141. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  14142. * @param scale defines the scale factor
  14143. * @param result defines the Vector2 object where to store the result
  14144. * @returns the unmodified current Vector2
  14145. */
  14146. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  14147. /**
  14148. * Boolean : True if the given vector coordinates strictly equal the current Vector2 ones.
  14149. */
  14150. equals(otherVector: Vector2): boolean;
  14151. /**
  14152. * Boolean : True if the given vector coordinates are close to the current ones by a distance of epsilon.
  14153. */
  14154. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  14155. /**
  14156. * Returns the vector length (float).
  14157. */
  14158. length(): number;
  14159. /**
  14160. * Returns the vector squared length (float);
  14161. */
  14162. lengthSquared(): number;
  14163. /**
  14164. * Normalize the vector.
  14165. * Returns the updated Vector2.
  14166. */
  14167. normalize(): Vector2;
  14168. /**
  14169. * Returns a new Vector2 copied from the Vector2.
  14170. */
  14171. clone(): Vector2;
  14172. /**
  14173. * Returns a new Vector2(0, 0)
  14174. */
  14175. static Zero(): Vector2;
  14176. /**
  14177. * Returns a new Vector2(1, 1)
  14178. */
  14179. static One(): Vector2;
  14180. /**
  14181. * Returns a new Vector2 set from the given index element of the given array.
  14182. */
  14183. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  14184. /**
  14185. * Sets "result" from the given index element of the given array.
  14186. */
  14187. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  14188. /**
  14189. * Retuns a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2.
  14190. */
  14191. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  14192. /**
  14193. * 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".
  14194. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  14195. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate.
  14196. */
  14197. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  14198. /**
  14199. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2".
  14200. */
  14201. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  14202. /**
  14203. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  14204. */
  14205. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  14206. /**
  14207. * Returns the dot product (float) of the vector "left" and the vector "right".
  14208. */
  14209. static Dot(left: Vector2, right: Vector2): number;
  14210. /**
  14211. * Returns a new Vector2 equal to the normalized given vector.
  14212. */
  14213. static Normalize(vector: Vector2): Vector2;
  14214. /**
  14215. * Returns a new Vecto2 set with the minimal coordinate values from the "left" and "right" vectors.
  14216. */
  14217. static Minimize(left: Vector2, right: Vector2): Vector2;
  14218. /**
  14219. * Returns a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors.
  14220. */
  14221. static Maximize(left: Vector2, right: Vector2): Vector2;
  14222. /**
  14223. * Returns a new Vecto2 set with the transformed coordinates of the given vector by the given transformation matrix.
  14224. */
  14225. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  14226. /**
  14227. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates.
  14228. */
  14229. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  14230. /**
  14231. * Boolean : True if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  14232. */
  14233. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  14234. /**
  14235. * Returns the distance (float) between the vectors "value1" and "value2".
  14236. */
  14237. static Distance(value1: Vector2, value2: Vector2): number;
  14238. /**
  14239. * Returns the squared distance (float) between the vectors "value1" and "value2".
  14240. */
  14241. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  14242. /**
  14243. * Returns a new Vecto2 located at the center of the vectors "value1" and "value2".
  14244. */
  14245. static Center(value1: Vector2, value2: Vector2): Vector2;
  14246. /**
  14247. * Returns the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  14248. */
  14249. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  14250. }
  14251. /**
  14252. * Classed used to store (x,y,z) vector representation
  14253. * A Vector3 is the main object used in 3D geometry
  14254. * It can represent etiher the coordinates of a point the space, either a direction
  14255. * Reminder: Babylon.js uses a left handed forward facing system
  14256. */
  14257. class Vector3 {
  14258. /**
  14259. * Defines the first coordinates (on X axis)
  14260. */
  14261. x: number;
  14262. /**
  14263. * Defines the second coordinates (on Y axis)
  14264. */
  14265. y: number;
  14266. /**
  14267. * Defines the third coordinates (on Z axis)
  14268. */
  14269. z: number;
  14270. /**
  14271. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  14272. * @param x defines the first coordinates (on X axis)
  14273. * @param y defines the second coordinates (on Y axis)
  14274. * @param z defines the third coordinates (on Z axis)
  14275. */
  14276. constructor(
  14277. /**
  14278. * Defines the first coordinates (on X axis)
  14279. */
  14280. x: number,
  14281. /**
  14282. * Defines the second coordinates (on Y axis)
  14283. */
  14284. y: number,
  14285. /**
  14286. * Defines the third coordinates (on Z axis)
  14287. */
  14288. z: number);
  14289. /**
  14290. * Creates a string representation of the Vector3
  14291. * @returns a string with the Vector3 coordinates.
  14292. */
  14293. toString(): string;
  14294. /**
  14295. * Gets the class name
  14296. * @returns the string "Vector3"
  14297. */
  14298. getClassName(): string;
  14299. /**
  14300. * Creates the Vector3 hash code
  14301. * @returns a number which tends to be unique between Vector3 instances
  14302. */
  14303. getHashCode(): number;
  14304. /**
  14305. * Creates an array containing three elements : the coordinates of the Vector3
  14306. * @returns a new array of numbers
  14307. */
  14308. asArray(): number[];
  14309. /**
  14310. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  14311. * @param array defines the destination array
  14312. * @param index defines the offset in the destination array
  14313. * @returns the current Vector3
  14314. */
  14315. toArray(array: FloatArray, index?: number): Vector3;
  14316. /**
  14317. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  14318. * @returns a new Quaternion object, computed from the Vector3 coordinates
  14319. */
  14320. toQuaternion(): Quaternion;
  14321. /**
  14322. * Adds the given vector to the current Vector3
  14323. * @param otherVector defines the second operand
  14324. * @returns the current updated Vector3
  14325. */
  14326. addInPlace(otherVector: Vector3): Vector3;
  14327. /**
  14328. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  14329. * @param otherVector defines the second operand
  14330. * @returns the resulting Vector3
  14331. */
  14332. add(otherVector: Vector3): Vector3;
  14333. /**
  14334. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  14335. * @param otherVector defines the second operand
  14336. * @param result defines the Vector3 object where to store the result
  14337. * @returns the current Vector3
  14338. */
  14339. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  14340. /**
  14341. * Subtract the given vector from the current Vector3
  14342. * @param otherVector defines the second operand
  14343. * @returns the current updated Vector3
  14344. */
  14345. subtractInPlace(otherVector: Vector3): Vector3;
  14346. /**
  14347. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  14348. * @param otherVector defines the second operand
  14349. * @returns the resulting Vector3
  14350. */
  14351. subtract(otherVector: Vector3): Vector3;
  14352. /**
  14353. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  14354. * @param otherVector defines the second operand
  14355. * @param result defines the Vector3 object where to store the result
  14356. * @returns the current Vector3
  14357. */
  14358. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  14359. /**
  14360. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  14361. * @param x defines the x coordinate of the operand
  14362. * @param y defines the y coordinate of the operand
  14363. * @param z defines the z coordinate of the operand
  14364. * @returns the resulting Vector3
  14365. */
  14366. subtractFromFloats(x: number, y: number, z: number): Vector3;
  14367. /**
  14368. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  14369. * @param x defines the x coordinate of the operand
  14370. * @param y defines the y coordinate of the operand
  14371. * @param z defines the z coordinate of the operand
  14372. * @param result defines the Vector3 object where to store the result
  14373. * @returns the current Vector3
  14374. */
  14375. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  14376. /**
  14377. * Gets a new Vector3 set with the current Vector3 negated coordinates
  14378. * @returns a new Vector3
  14379. */
  14380. negate(): Vector3;
  14381. /**
  14382. * Multiplies the Vector3 coordinates by the float "scale"
  14383. * @param scale defines the multiplier factor
  14384. * @returns the current updated Vector3
  14385. */
  14386. scaleInPlace(scale: number): Vector3;
  14387. /**
  14388. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  14389. * @param scale defines the multiplier factor
  14390. * @returns a new Vector3
  14391. */
  14392. scale(scale: number): Vector3;
  14393. /**
  14394. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  14395. * @param scale defines the multiplier factor
  14396. * @param result defines the Vector3 object where to store the result
  14397. * @returns the current Vector3
  14398. */
  14399. scaleToRef(scale: number, result: Vector3): Vector3;
  14400. /**
  14401. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  14402. * @param scale defines the scale factor
  14403. * @param result defines the Vector3 object where to store the result
  14404. * @returns the unmodified current Vector3
  14405. */
  14406. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  14407. /**
  14408. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  14409. * @param otherVector defines the second operand
  14410. * @returns true if both vectors are equals
  14411. */
  14412. equals(otherVector: Vector3): boolean;
  14413. /**
  14414. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  14415. * @param otherVector defines the second operand
  14416. * @param epsilon defines the minimal distance to define values as equals
  14417. * @returns true if both vectors are distant less than epsilon
  14418. */
  14419. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  14420. /**
  14421. * Returns true if the current Vector3 coordinates equals the given floats
  14422. * @param x defines the x coordinate of the operand
  14423. * @param y defines the y coordinate of the operand
  14424. * @param z defines the z coordinate of the operand
  14425. * @returns true if both vectors are equals
  14426. */
  14427. equalsToFloats(x: number, y: number, z: number): boolean;
  14428. /**
  14429. * Multiplies the current Vector3 coordinates by the given ones
  14430. * @param otherVector defines the second operand
  14431. * @returns the current updated Vector3
  14432. */
  14433. multiplyInPlace(otherVector: Vector3): Vector3;
  14434. /**
  14435. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  14436. * @param otherVector defines the second operand
  14437. * @returns the new Vector3
  14438. */
  14439. multiply(otherVector: Vector3): Vector3;
  14440. /**
  14441. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  14442. * @param otherVector defines the second operand
  14443. * @param result defines the Vector3 object where to store the result
  14444. * @returns the current Vector3
  14445. */
  14446. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  14447. /**
  14448. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  14449. * @param x defines the x coordinate of the operand
  14450. * @param y defines the y coordinate of the operand
  14451. * @param z defines the z coordinate of the operand
  14452. * @returns the new Vector3
  14453. */
  14454. multiplyByFloats(x: number, y: number, z: number): Vector3;
  14455. /**
  14456. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  14457. * @param otherVector defines the second operand
  14458. * @returns the new Vector3
  14459. */
  14460. divide(otherVector: Vector3): Vector3;
  14461. /**
  14462. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  14463. * @param otherVector defines the second operand
  14464. * @param result defines the Vector3 object where to store the result
  14465. * @returns the current Vector3
  14466. */
  14467. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  14468. /**
  14469. * Divides the current Vector3 coordinates by the given ones.
  14470. * @param otherVector defines the second operand
  14471. * @returns the current updated Vector3
  14472. */
  14473. divideInPlace(otherVector: Vector3): Vector3;
  14474. /**
  14475. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  14476. * @param other defines the second operand
  14477. * @returns the current updated Vector3
  14478. */
  14479. minimizeInPlace(other: Vector3): Vector3;
  14480. /**
  14481. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  14482. * @param other defines the second operand
  14483. * @returns the current updated Vector3
  14484. */
  14485. maximizeInPlace(other: Vector3): Vector3;
  14486. /**
  14487. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  14488. */
  14489. readonly isNonUniform: boolean;
  14490. /**
  14491. * Gets the length of the Vector3
  14492. * @returns the length of the Vecto3
  14493. */
  14494. length(): number;
  14495. /**
  14496. * Gets the squared length of the Vector3
  14497. * @returns squared length of the Vector3
  14498. */
  14499. lengthSquared(): number;
  14500. /**
  14501. * Normalize the current Vector3.
  14502. * Please note that this is an in place operation.
  14503. * @returns the current updated Vector3
  14504. */
  14505. normalize(): Vector3;
  14506. /**
  14507. * Normalize the current Vector3 to a new vector
  14508. * @returns the new Vector3
  14509. */
  14510. normalizeToNew(): Vector3;
  14511. /**
  14512. * Normalize the current Vector3 to the reference
  14513. * @param reference define the Vector3 to update
  14514. * @returns the updated Vector3
  14515. */
  14516. normalizeToRef(reference: Vector3): Vector3;
  14517. /**
  14518. * Creates a new Vector3 copied from the current Vector3
  14519. * @returns the new Vector3
  14520. */
  14521. clone(): Vector3;
  14522. /**
  14523. * Copies the given vector coordinates to the current Vector3 ones
  14524. * @param source defines the source Vector3
  14525. * @returns the current updated Vector3
  14526. */
  14527. copyFrom(source: Vector3): Vector3;
  14528. /**
  14529. * Copies the given floats to the current Vector3 coordinates
  14530. * @param x defines the x coordinate of the operand
  14531. * @param y defines the y coordinate of the operand
  14532. * @param z defines the z coordinate of the operand
  14533. * @returns the current updated Vector3
  14534. */
  14535. copyFromFloats(x: number, y: number, z: number): Vector3;
  14536. /**
  14537. * Copies the given floats to the current Vector3 coordinates
  14538. * @param x defines the x coordinate of the operand
  14539. * @param y defines the y coordinate of the operand
  14540. * @param z defines the z coordinate of the operand
  14541. * @returns the current updated Vector3
  14542. */
  14543. set(x: number, y: number, z: number): Vector3;
  14544. /**
  14545. * Get the clip factor between two vectors
  14546. * @param vector0 defines the first operand
  14547. * @param vector1 defines the second operand
  14548. * @param axis defines the axis to use
  14549. * @param size defines the size along the axis
  14550. * @returns the clip factor
  14551. */
  14552. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  14553. /**
  14554. * Get angle between two vectors
  14555. * @param vector0 angle between vector0 and vector1
  14556. * @param vector1 angle between vector0 and vector1
  14557. * @param normal direction of the normal
  14558. * @return the angle between vector0 and vector1
  14559. */
  14560. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  14561. /**
  14562. * Returns a new Vector3 set from the index "offset" of the given array
  14563. * @param array defines the source array
  14564. * @param offset defines the offset in the source array
  14565. * @returns the new Vector3
  14566. */
  14567. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  14568. /**
  14569. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  14570. * This function is deprecated. Use FromArray instead
  14571. * @param array defines the source array
  14572. * @param offset defines the offset in the source array
  14573. * @returns the new Vector3
  14574. */
  14575. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  14576. /**
  14577. * Sets the given vector "result" with the element values from the index "offset" of the given array
  14578. * @param array defines the source array
  14579. * @param offset defines the offset in the source array
  14580. * @param result defines the Vector3 where to store the result
  14581. */
  14582. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  14583. /**
  14584. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  14585. * This function is deprecated. Use FromArrayToRef instead.
  14586. * @param array defines the source array
  14587. * @param offset defines the offset in the source array
  14588. * @param result defines the Vector3 where to store the result
  14589. */
  14590. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  14591. /**
  14592. * Sets the given vector "result" with the given floats.
  14593. * @param x defines the x coordinate of the source
  14594. * @param y defines the y coordinate of the source
  14595. * @param z defines the z coordinate of the source
  14596. * @param result defines the Vector3 where to store the result
  14597. */
  14598. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  14599. /**
  14600. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  14601. * @returns a new empty Vector3
  14602. */
  14603. static Zero(): Vector3;
  14604. /**
  14605. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  14606. * @returns a new unit Vector3
  14607. */
  14608. static One(): Vector3;
  14609. /**
  14610. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  14611. * @returns a new up Vector3
  14612. */
  14613. static Up(): Vector3;
  14614. /**
  14615. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  14616. * @returns a new forward Vector3
  14617. */
  14618. static Forward(): Vector3;
  14619. /**
  14620. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  14621. * @returns a new right Vector3
  14622. */
  14623. static Right(): Vector3;
  14624. /**
  14625. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  14626. * @returns a new left Vector3
  14627. */
  14628. static Left(): Vector3;
  14629. /**
  14630. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  14631. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  14632. * @param vector defines the Vector3 to transform
  14633. * @param transformation defines the transformation matrix
  14634. * @returns the transformed Vector3
  14635. */
  14636. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  14637. /**
  14638. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  14639. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  14640. * @param vector defines the Vector3 to transform
  14641. * @param transformation defines the transformation matrix
  14642. * @param result defines the Vector3 where to store the result
  14643. */
  14644. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  14645. /**
  14646. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  14647. * This method computes tranformed coordinates only, not transformed direction vectors
  14648. * @param x define the x coordinate of the source vector
  14649. * @param y define the y coordinate of the source vector
  14650. * @param z define the z coordinate of the source vector
  14651. * @param transformation defines the transformation matrix
  14652. * @param result defines the Vector3 where to store the result
  14653. */
  14654. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  14655. /**
  14656. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  14657. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  14658. * @param vector defines the Vector3 to transform
  14659. * @param transformation defines the transformation matrix
  14660. * @returns the new Vector3
  14661. */
  14662. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  14663. /**
  14664. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  14665. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  14666. * @param vector defines the Vector3 to transform
  14667. * @param transformation defines the transformation matrix
  14668. * @param result defines the Vector3 where to store the result
  14669. */
  14670. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  14671. /**
  14672. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  14673. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  14674. * @param x define the x coordinate of the source vector
  14675. * @param y define the y coordinate of the source vector
  14676. * @param z define the z coordinate of the source vector
  14677. * @param transformation defines the transformation matrix
  14678. * @param result defines the Vector3 where to store the result
  14679. */
  14680. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  14681. /**
  14682. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  14683. * @param value1 defines the first control point
  14684. * @param value2 defines the second control point
  14685. * @param value3 defines the third control point
  14686. * @param value4 defines the fourth control point
  14687. * @param amount defines the amount on the spline to use
  14688. * @returns the new Vector3
  14689. */
  14690. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  14691. /**
  14692. * 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"
  14693. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  14694. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  14695. * @param value defines the current value
  14696. * @param min defines the lower range value
  14697. * @param max defines the upper range value
  14698. * @returns the new Vector3
  14699. */
  14700. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  14701. /**
  14702. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  14703. * @param value1 defines the first control point
  14704. * @param tangent1 defines the first tangent vector
  14705. * @param value2 defines the second control point
  14706. * @param tangent2 defines the second tangent vector
  14707. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  14708. * @returns the new Vector3
  14709. */
  14710. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  14711. /**
  14712. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  14713. * @param start defines the start value
  14714. * @param end defines the end value
  14715. * @param amount max defines amount between both (between 0 and 1)
  14716. * @returns the new Vector3
  14717. */
  14718. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  14719. /**
  14720. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  14721. * @param start defines the start value
  14722. * @param end defines the end value
  14723. * @param amount max defines amount between both (between 0 and 1)
  14724. * @param result defines the Vector3 where to store the result
  14725. */
  14726. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  14727. /**
  14728. * Returns the dot product (float) between the vectors "left" and "right"
  14729. * @param left defines the left operand
  14730. * @param right defines the right operand
  14731. * @returns the dot product
  14732. */
  14733. static Dot(left: Vector3, right: Vector3): number;
  14734. /**
  14735. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  14736. * The cross product is then orthogonal to both "left" and "right"
  14737. * @param left defines the left operand
  14738. * @param right defines the right operand
  14739. * @returns the cross product
  14740. */
  14741. static Cross(left: Vector3, right: Vector3): Vector3;
  14742. /**
  14743. * Sets the given vector "result" with the cross product of "left" and "right"
  14744. * The cross product is then orthogonal to both "left" and "right"
  14745. * @param left defines the left operand
  14746. * @param right defines the right operand
  14747. * @param result defines the Vector3 where to store the result
  14748. */
  14749. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  14750. /**
  14751. * Returns a new Vector3 as the normalization of the given vector
  14752. * @param vector defines the Vector3 to normalize
  14753. * @returns the new Vector3
  14754. */
  14755. static Normalize(vector: Vector3): Vector3;
  14756. /**
  14757. * Sets the given vector "result" with the normalization of the given first vector
  14758. * @param vector defines the Vector3 to normalize
  14759. * @param result defines the Vector3 where to store the result
  14760. */
  14761. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  14762. private static _viewportMatrixCache;
  14763. /**
  14764. * Project a Vector3 onto screen space
  14765. * @param vector defines the Vector3 to project
  14766. * @param world defines the world matrix to use
  14767. * @param transform defines the transform (view x projection) matrix to use
  14768. * @param viewport defines the screen viewport to use
  14769. * @returns the new Vector3
  14770. */
  14771. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  14772. /**
  14773. * Unproject from screen space to object space
  14774. * @param source defines the screen space Vector3 to use
  14775. * @param viewportWidth defines the current width of the viewport
  14776. * @param viewportHeight defines the current height of the viewport
  14777. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  14778. * @param transform defines the transform (view x projection) matrix to use
  14779. * @returns the new Vector3
  14780. */
  14781. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  14782. /**
  14783. * Unproject from screen space to object space
  14784. * @param source defines the screen space Vector3 to use
  14785. * @param viewportWidth defines the current width of the viewport
  14786. * @param viewportHeight defines the current height of the viewport
  14787. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  14788. * @param view defines the view matrix to use
  14789. * @param projection defines the projection matrix to use
  14790. * @returns the new Vector3
  14791. */
  14792. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  14793. /**
  14794. * Unproject from screen space to object space
  14795. * @param source defines the screen space Vector3 to use
  14796. * @param viewportWidth defines the current width of the viewport
  14797. * @param viewportHeight defines the current height of the viewport
  14798. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  14799. * @param view defines the view matrix to use
  14800. * @param projection defines the projection matrix to use
  14801. * @param result defines the Vector3 where to store the result
  14802. */
  14803. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  14804. /**
  14805. * Unproject from screen space to object space
  14806. * @param sourceX defines the screen space x coordinate to use
  14807. * @param sourceY defines the screen space y coordinate to use
  14808. * @param sourceZ defines the screen space z coordinate to use
  14809. * @param viewportWidth defines the current width of the viewport
  14810. * @param viewportHeight defines the current height of the viewport
  14811. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  14812. * @param view defines the view matrix to use
  14813. * @param projection defines the projection matrix to use
  14814. * @param result defines the Vector3 where to store the result
  14815. */
  14816. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  14817. /**
  14818. * Gets the minimal coordinate values between two Vector3
  14819. * @param left defines the first operand
  14820. * @param right defines the second operand
  14821. * @returns the new Vector3
  14822. */
  14823. static Minimize(left: Vector3, right: Vector3): Vector3;
  14824. /**
  14825. * Gets the maximal coordinate values between two Vector3
  14826. * @param left defines the first operand
  14827. * @param right defines the second operand
  14828. * @returns the new Vector3
  14829. */
  14830. static Maximize(left: Vector3, right: Vector3): Vector3;
  14831. /**
  14832. * Returns the distance between the vectors "value1" and "value2"
  14833. * @param value1 defines the first operand
  14834. * @param value2 defines the second operand
  14835. * @returns the distance
  14836. */
  14837. static Distance(value1: Vector3, value2: Vector3): number;
  14838. /**
  14839. * Returns the squared distance between the vectors "value1" and "value2"
  14840. * @param value1 defines the first operand
  14841. * @param value2 defines the second operand
  14842. * @returns the squared distance
  14843. */
  14844. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  14845. /**
  14846. * Returns a new Vector3 located at the center between "value1" and "value2"
  14847. * @param value1 defines the first operand
  14848. * @param value2 defines the second operand
  14849. * @returns the new Vector3
  14850. */
  14851. static Center(value1: Vector3, value2: Vector3): Vector3;
  14852. /**
  14853. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  14854. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  14855. * to something in order to rotate it from its local system to the given target system
  14856. * Note: axis1, axis2 and axis3 are normalized during this operation
  14857. * @param axis1 defines the first axis
  14858. * @param axis2 defines the second axis
  14859. * @param axis3 defines the third axis
  14860. * @returns a new Vector3
  14861. */
  14862. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  14863. /**
  14864. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  14865. * @param axis1 defines the first axis
  14866. * @param axis2 defines the second axis
  14867. * @param axis3 defines the third axis
  14868. * @param ref defines the Vector3 where to store the result
  14869. */
  14870. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  14871. }
  14872. class Vector4 {
  14873. x: number;
  14874. y: number;
  14875. z: number;
  14876. w: number;
  14877. /**
  14878. * Creates a Vector4 object from the given floats.
  14879. */
  14880. constructor(x: number, y: number, z: number, w: number);
  14881. /**
  14882. * Returns the string with the Vector4 coordinates.
  14883. */
  14884. toString(): string;
  14885. /**
  14886. * Returns the string "Vector4".
  14887. */
  14888. getClassName(): string;
  14889. /**
  14890. * Returns the Vector4 hash code.
  14891. */
  14892. getHashCode(): number;
  14893. /**
  14894. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  14895. */
  14896. asArray(): number[];
  14897. /**
  14898. * Populates the given array from the given index with the Vector4 coordinates.
  14899. * Returns the Vector4.
  14900. */
  14901. toArray(array: FloatArray, index?: number): Vector4;
  14902. /**
  14903. * Adds the given vector to the current Vector4.
  14904. * Returns the updated Vector4.
  14905. */
  14906. addInPlace(otherVector: Vector4): Vector4;
  14907. /**
  14908. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  14909. */
  14910. add(otherVector: Vector4): Vector4;
  14911. /**
  14912. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  14913. * Returns the current Vector4.
  14914. */
  14915. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  14916. /**
  14917. * Subtract in place the given vector from the current Vector4.
  14918. * Returns the updated Vector4.
  14919. */
  14920. subtractInPlace(otherVector: Vector4): Vector4;
  14921. /**
  14922. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  14923. */
  14924. subtract(otherVector: Vector4): Vector4;
  14925. /**
  14926. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  14927. * Returns the current Vector4.
  14928. */
  14929. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  14930. /**
  14931. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  14932. */
  14933. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  14934. /**
  14935. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  14936. * Returns the current Vector4.
  14937. */
  14938. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  14939. /**
  14940. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  14941. */
  14942. negate(): Vector4;
  14943. /**
  14944. * Multiplies the current Vector4 coordinates by scale (float).
  14945. * Returns the updated Vector4.
  14946. */
  14947. scaleInPlace(scale: number): Vector4;
  14948. /**
  14949. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  14950. */
  14951. scale(scale: number): Vector4;
  14952. /**
  14953. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  14954. * Returns the current Vector4.
  14955. */
  14956. scaleToRef(scale: number, result: Vector4): Vector4;
  14957. /**
  14958. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  14959. * @param scale defines the scale factor
  14960. * @param result defines the Vector4 object where to store the result
  14961. * @returns the unmodified current Vector4
  14962. */
  14963. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  14964. /**
  14965. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  14966. */
  14967. equals(otherVector: Vector4): boolean;
  14968. /**
  14969. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  14970. */
  14971. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  14972. /**
  14973. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  14974. */
  14975. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  14976. /**
  14977. * Multiplies in place the current Vector4 by the given one.
  14978. * Returns the updated Vector4.
  14979. */
  14980. multiplyInPlace(otherVector: Vector4): Vector4;
  14981. /**
  14982. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  14983. */
  14984. multiply(otherVector: Vector4): Vector4;
  14985. /**
  14986. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  14987. * Returns the current Vector4.
  14988. */
  14989. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  14990. /**
  14991. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  14992. */
  14993. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  14994. /**
  14995. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  14996. */
  14997. divide(otherVector: Vector4): Vector4;
  14998. /**
  14999. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  15000. * Returns the current Vector4.
  15001. */
  15002. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  15003. /**
  15004. * Divides the current Vector3 coordinates by the given ones.
  15005. * @returns the updated Vector3.
  15006. */
  15007. divideInPlace(otherVector: Vector4): Vector4;
  15008. /**
  15009. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  15010. * @param other defines the second operand
  15011. * @returns the current updated Vector4
  15012. */
  15013. minimizeInPlace(other: Vector4): Vector4;
  15014. /**
  15015. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  15016. * @param other defines the second operand
  15017. * @returns the current updated Vector4
  15018. */
  15019. maximizeInPlace(other: Vector4): Vector4;
  15020. /**
  15021. * Returns the Vector4 length (float).
  15022. */
  15023. length(): number;
  15024. /**
  15025. * Returns the Vector4 squared length (float).
  15026. */
  15027. lengthSquared(): number;
  15028. /**
  15029. * Normalizes in place the Vector4.
  15030. * Returns the updated Vector4.
  15031. */
  15032. normalize(): Vector4;
  15033. /**
  15034. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  15035. */
  15036. toVector3(): Vector3;
  15037. /**
  15038. * Returns a new Vector4 copied from the current one.
  15039. */
  15040. clone(): Vector4;
  15041. /**
  15042. * Updates the current Vector4 with the given one coordinates.
  15043. * Returns the updated Vector4.
  15044. */
  15045. copyFrom(source: Vector4): Vector4;
  15046. /**
  15047. * Updates the current Vector4 coordinates with the given floats.
  15048. * Returns the updated Vector4.
  15049. */
  15050. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  15051. /**
  15052. * Updates the current Vector4 coordinates with the given floats.
  15053. * Returns the updated Vector4.
  15054. */
  15055. set(x: number, y: number, z: number, w: number): Vector4;
  15056. /**
  15057. * Returns a new Vector4 set from the starting index of the given array.
  15058. */
  15059. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  15060. /**
  15061. * Updates the given vector "result" from the starting index of the given array.
  15062. */
  15063. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  15064. /**
  15065. * Updates the given vector "result" from the starting index of the given Float32Array.
  15066. */
  15067. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  15068. /**
  15069. * Updates the given vector "result" coordinates from the given floats.
  15070. */
  15071. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  15072. /**
  15073. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  15074. */
  15075. static Zero(): Vector4;
  15076. /**
  15077. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  15078. */
  15079. static One(): Vector4;
  15080. /**
  15081. * Returns a new normalized Vector4 from the given one.
  15082. */
  15083. static Normalize(vector: Vector4): Vector4;
  15084. /**
  15085. * Updates the given vector "result" from the normalization of the given one.
  15086. */
  15087. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  15088. static Minimize(left: Vector4, right: Vector4): Vector4;
  15089. static Maximize(left: Vector4, right: Vector4): Vector4;
  15090. /**
  15091. * Returns the distance (float) between the vectors "value1" and "value2".
  15092. */
  15093. static Distance(value1: Vector4, value2: Vector4): number;
  15094. /**
  15095. * Returns the squared distance (float) between the vectors "value1" and "value2".
  15096. */
  15097. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  15098. /**
  15099. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  15100. */
  15101. static Center(value1: Vector4, value2: Vector4): Vector4;
  15102. /**
  15103. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  15104. * This methods computes transformed normalized direction vectors only.
  15105. */
  15106. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  15107. /**
  15108. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  15109. * This methods computes transformed normalized direction vectors only.
  15110. */
  15111. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  15112. /**
  15113. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  15114. * This methods computes transformed normalized direction vectors only.
  15115. */
  15116. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  15117. }
  15118. interface ISize {
  15119. width: number;
  15120. height: number;
  15121. }
  15122. class Size implements ISize {
  15123. width: number;
  15124. height: number;
  15125. /**
  15126. * Creates a Size object from the given width and height (floats).
  15127. */
  15128. constructor(width: number, height: number);
  15129. toString(): string;
  15130. /**
  15131. * Returns the string "Size"
  15132. */
  15133. getClassName(): string;
  15134. /**
  15135. * Returns the Size hash code.
  15136. */
  15137. getHashCode(): number;
  15138. /**
  15139. * Updates the current size from the given one.
  15140. * Returns the updated Size.
  15141. */
  15142. copyFrom(src: Size): void;
  15143. /**
  15144. * Updates in place the current Size from the given floats.
  15145. * Returns the updated Size.
  15146. */
  15147. copyFromFloats(width: number, height: number): Size;
  15148. /**
  15149. * Updates in place the current Size from the given floats.
  15150. * Returns the updated Size.
  15151. */
  15152. set(width: number, height: number): Size;
  15153. /**
  15154. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  15155. */
  15156. multiplyByFloats(w: number, h: number): Size;
  15157. /**
  15158. * Returns a new Size copied from the given one.
  15159. */
  15160. clone(): Size;
  15161. /**
  15162. * Boolean : True if the current Size and the given one width and height are strictly equal.
  15163. */
  15164. equals(other: Size): boolean;
  15165. /**
  15166. * Returns the surface of the Size : width * height (float).
  15167. */
  15168. readonly surface: number;
  15169. /**
  15170. * Returns a new Size set to (0.0, 0.0)
  15171. */
  15172. static Zero(): Size;
  15173. /**
  15174. * Returns a new Size set as the addition result of the current Size and the given one.
  15175. */
  15176. add(otherSize: Size): Size;
  15177. /**
  15178. * Returns a new Size set as the subtraction result of the given one from the current Size.
  15179. */
  15180. subtract(otherSize: Size): Size;
  15181. /**
  15182. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  15183. */
  15184. static Lerp(start: Size, end: Size, amount: number): Size;
  15185. }
  15186. /**
  15187. * Class used to store quaternion data
  15188. * @see https://en.wikipedia.org/wiki/Quaternion
  15189. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  15190. */
  15191. class Quaternion {
  15192. /** defines the first component (0 by default) */
  15193. x: number;
  15194. /** defines the second component (0 by default) */
  15195. y: number;
  15196. /** defines the third component (0 by default) */
  15197. z: number;
  15198. /** defines the fourth component (1.0 by default) */
  15199. w: number;
  15200. /**
  15201. * Creates a new Quaternion from the given floats
  15202. * @param x defines the first component (0 by default)
  15203. * @param y defines the second component (0 by default)
  15204. * @param z defines the third component (0 by default)
  15205. * @param w defines the fourth component (1.0 by default)
  15206. */
  15207. constructor(
  15208. /** defines the first component (0 by default) */
  15209. x?: number,
  15210. /** defines the second component (0 by default) */
  15211. y?: number,
  15212. /** defines the third component (0 by default) */
  15213. z?: number,
  15214. /** defines the fourth component (1.0 by default) */
  15215. w?: number);
  15216. /**
  15217. * Gets a string representation for the current quaternion
  15218. * @returns a string with the Quaternion coordinates
  15219. */
  15220. toString(): string;
  15221. /**
  15222. * Gets the class name of the quaternion
  15223. * @returns the string "Quaternion"
  15224. */
  15225. getClassName(): string;
  15226. /**
  15227. * Gets a hash code for this quaternion
  15228. * @returns the quaternion hash code
  15229. */
  15230. getHashCode(): number;
  15231. /**
  15232. * Copy the quaternion to an array
  15233. * @returns a new array populated with 4 elements from the quaternion coordinates
  15234. */
  15235. asArray(): number[];
  15236. /**
  15237. * Check if two quaternions are equals
  15238. * @param otherQuaternion defines the second operand
  15239. * @return true if the current quaternion and the given one coordinates are strictly equals
  15240. */
  15241. equals(otherQuaternion: Quaternion): boolean;
  15242. /**
  15243. * Clone the current quaternion
  15244. * @returns a new quaternion copied from the current one
  15245. */
  15246. clone(): Quaternion;
  15247. /**
  15248. * Copy a quaternion to the current one
  15249. * @param other defines the other quaternion
  15250. * @returns the updated current quaternion
  15251. */
  15252. copyFrom(other: Quaternion): Quaternion;
  15253. /**
  15254. * Updates the current quaternion with the given float coordinates
  15255. * @param x defines the x coordinate
  15256. * @param y defines the y coordinate
  15257. * @param z defines the z coordinate
  15258. * @param w defines the w coordinate
  15259. * @returns the updated current quaternion
  15260. */
  15261. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  15262. /**
  15263. * Updates the current quaternion from the given float coordinates
  15264. * @param x defines the x coordinate
  15265. * @param y defines the y coordinate
  15266. * @param z defines the z coordinate
  15267. * @param w defines the w coordinate
  15268. * @returns the updated current quaternion
  15269. */
  15270. set(x: number, y: number, z: number, w: number): Quaternion;
  15271. /**
  15272. * Adds two quaternions
  15273. * @param other defines the second operand
  15274. * @returns a new quaternion as the addition result of the given one and the current quaternion
  15275. */
  15276. add(other: Quaternion): Quaternion;
  15277. /**
  15278. * Add a quaternion to the current one
  15279. * @param other defines the quaternion to add
  15280. * @returns the current quaternion
  15281. */
  15282. addInPlace(other: Quaternion): Quaternion;
  15283. /**
  15284. * Subtract two quaternions
  15285. * @param other defines the second operand
  15286. * @returns a new quaternion as the subtraction result of the given one from the current one
  15287. */
  15288. subtract(other: Quaternion): Quaternion;
  15289. /**
  15290. * Multiplies the current quaternion by a scale factor
  15291. * @param value defines the scale factor
  15292. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  15293. */
  15294. scale(value: number): Quaternion;
  15295. /**
  15296. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  15297. * @param scale defines the scale factor
  15298. * @param result defines the Quaternion object where to store the result
  15299. * @returns the unmodified current quaternion
  15300. */
  15301. scaleToRef(scale: number, result: Quaternion): Quaternion;
  15302. /**
  15303. * Multiplies in place the current quaternion by a scale factor
  15304. * @param value defines the scale factor
  15305. * @returns the current modified quaternion
  15306. */
  15307. scaleInPlace(value: number): Quaternion;
  15308. /**
  15309. * Scale the current quaternion values by a factor and add the result to a given quaternion
  15310. * @param scale defines the scale factor
  15311. * @param result defines the Quaternion object where to store the result
  15312. * @returns the unmodified current quaternion
  15313. */
  15314. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  15315. /**
  15316. * Multiplies two quaternions
  15317. * @param q1 defines the second operand
  15318. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  15319. */
  15320. multiply(q1: Quaternion): Quaternion;
  15321. /**
  15322. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  15323. * @param q1 defines the second operand
  15324. * @param result defines the target quaternion
  15325. * @returns the current quaternion
  15326. */
  15327. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  15328. /**
  15329. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  15330. * @param q1 defines the second operand
  15331. * @returns the currentupdated quaternion
  15332. */
  15333. multiplyInPlace(q1: Quaternion): Quaternion;
  15334. /**
  15335. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  15336. * @param ref defines the target quaternion
  15337. * @returns the current quaternion
  15338. */
  15339. conjugateToRef(ref: Quaternion): Quaternion;
  15340. /**
  15341. * Conjugates in place (1-q) the current quaternion
  15342. * @returns the current updated quaternion
  15343. */
  15344. conjugateInPlace(): Quaternion;
  15345. /**
  15346. * Conjugates in place (1-q) the current quaternion
  15347. * @returns a new quaternion
  15348. */
  15349. conjugate(): Quaternion;
  15350. /**
  15351. * Gets length of current quaternion
  15352. * @returns the quaternion length (float)
  15353. */
  15354. length(): number;
  15355. /**
  15356. * Normalize in place the current quaternion
  15357. * @returns the current updated quaternion
  15358. */
  15359. normalize(): Quaternion;
  15360. /**
  15361. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  15362. * @param order is a reserved parameter and is ignore for now
  15363. * @returns a new Vector3 containing the Euler angles
  15364. */
  15365. toEulerAngles(order?: string): Vector3;
  15366. /**
  15367. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  15368. * @param result defines the vector which will be filled with the Euler angles
  15369. * @param order is a reserved parameter and is ignore for now
  15370. * @returns the current unchanged quaternion
  15371. */
  15372. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  15373. /**
  15374. * Updates the given rotation matrix with the current quaternion values
  15375. * @param result defines the target matrix
  15376. * @returns the current unchanged quaternion
  15377. */
  15378. toRotationMatrix(result: Matrix): Quaternion;
  15379. /**
  15380. * Updates the current quaternion from the given rotation matrix values
  15381. * @param matrix defines the source matrix
  15382. * @returns the current updated quaternion
  15383. */
  15384. fromRotationMatrix(matrix: Matrix): Quaternion;
  15385. /**
  15386. * Creates a new quaternion from a rotation matrix
  15387. * @param matrix defines the source matrix
  15388. * @returns a new quaternion created from the given rotation matrix values
  15389. */
  15390. static FromRotationMatrix(matrix: Matrix): Quaternion;
  15391. /**
  15392. * Updates the given quaternion with the given rotation matrix values
  15393. * @param matrix defines the source matrix
  15394. * @param result defines the target quaternion
  15395. */
  15396. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  15397. /**
  15398. * Creates an empty quaternion
  15399. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  15400. */
  15401. static Zero(): Quaternion;
  15402. /**
  15403. * Inverse a given quaternion
  15404. * @param q defines the source quaternion
  15405. * @returns a new quaternion as the inverted current quaternion
  15406. */
  15407. static Inverse(q: Quaternion): Quaternion;
  15408. /**
  15409. * Creates an identity quaternion
  15410. * @returns the identity quaternion
  15411. */
  15412. static Identity(): Quaternion;
  15413. /**
  15414. * Gets a boolean indicating if the given quaternion is identity
  15415. * @param quaternion defines the quaternion to check
  15416. * @returns true if the quaternion is identity
  15417. */
  15418. static IsIdentity(quaternion: Quaternion): boolean;
  15419. /**
  15420. * Creates a quaternion from a rotation around an axis
  15421. * @param axis defines the axis to use
  15422. * @param angle defines the angle to use
  15423. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  15424. */
  15425. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  15426. /**
  15427. * Creates a rotation around an axis and stores it into the given quaternion
  15428. * @param axis defines the axis to use
  15429. * @param angle defines the angle to use
  15430. * @param result defines the target quaternion
  15431. * @returns the target quaternion
  15432. */
  15433. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  15434. /**
  15435. * Creates a new quaternion from data stored into an array
  15436. * @param array defines the data source
  15437. * @param offset defines the offset in the source array where the data starts
  15438. * @returns a new quaternion
  15439. */
  15440. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  15441. /**
  15442. * Creates a new quaternion from the given Euler float angles (y, x, z)
  15443. * @param yaw defines the rotation around Y axis
  15444. * @param pitch defines the rotation around X axis
  15445. * @param roll defines the rotation around Z axis
  15446. * @returns the new quaternion
  15447. */
  15448. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  15449. /**
  15450. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  15451. * @param yaw defines the rotation around Y axis
  15452. * @param pitch defines the rotation around X axis
  15453. * @param roll defines the rotation around Z axis
  15454. * @param result defines the target quaternion
  15455. */
  15456. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  15457. /**
  15458. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  15459. * @param alpha defines the rotation around first axis
  15460. * @param beta defines the rotation around second axis
  15461. * @param gamma defines the rotation around third axis
  15462. * @returns the new quaternion
  15463. */
  15464. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  15465. /**
  15466. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  15467. * @param alpha defines the rotation around first axis
  15468. * @param beta defines the rotation around second axis
  15469. * @param gamma defines the rotation around third axis
  15470. * @param result defines the target quaternion
  15471. */
  15472. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  15473. /**
  15474. * 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)
  15475. * @param axis1 defines the first axis
  15476. * @param axis2 defines the second axis
  15477. * @param axis3 defines the third axis
  15478. * @returns the new quaternion
  15479. */
  15480. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  15481. /**
  15482. * 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
  15483. * @param axis1 defines the first axis
  15484. * @param axis2 defines the second axis
  15485. * @param axis3 defines the third axis
  15486. * @param ref defines the target quaternion
  15487. */
  15488. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  15489. /**
  15490. * Interpolates between two quaternions
  15491. * @param left defines first quaternion
  15492. * @param right defines second quaternion
  15493. * @param amount defines the gradient to use
  15494. * @returns the new interpolated quaternion
  15495. */
  15496. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  15497. /**
  15498. * Interpolates between two quaternions and stores it into a target quaternion
  15499. * @param left defines first quaternion
  15500. * @param right defines second quaternion
  15501. * @param amount defines the gradient to use
  15502. * @param result defines the target quaternion
  15503. */
  15504. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  15505. /**
  15506. * Interpolate between two quaternions using Hermite interpolation
  15507. * @param value1 defines first quaternion
  15508. * @param tangent1 defines the incoming tangent
  15509. * @param value2 defines second quaternion
  15510. * @param tangent2 defines the outgoing tangent
  15511. * @param amount defines the target quaternion
  15512. * @returns the new interpolated quaternion
  15513. */
  15514. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  15515. }
  15516. /**
  15517. * Class used to store matrix data (4x4)
  15518. */
  15519. class Matrix {
  15520. private static _tempQuaternion;
  15521. private static _xAxis;
  15522. private static _yAxis;
  15523. private static _zAxis;
  15524. private static _updateFlagSeed;
  15525. private static _identityReadOnly;
  15526. private _isIdentity;
  15527. private _isIdentityDirty;
  15528. /**
  15529. * Gets the update flag of the matrix which is an unique number for the matrix.
  15530. * It will be incremented every time the matrix data change.
  15531. * You can use it to speed the comparison between two versions of the same matrix.
  15532. */
  15533. updateFlag: number;
  15534. /**
  15535. * Gets or sets the internal data of the matrix
  15536. */
  15537. m: Float32Array;
  15538. /** @ignore */
  15539. _markAsUpdated(): void;
  15540. /**
  15541. * Creates an empty matrix (filled with zeros)
  15542. */
  15543. constructor();
  15544. /**
  15545. * Check if the current matrix is indentity
  15546. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  15547. * @returns true is the matrix is the identity matrix
  15548. */
  15549. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  15550. /**
  15551. * Gets the determinant of the matrix
  15552. * @returns the matrix determinant
  15553. */
  15554. determinant(): number;
  15555. /**
  15556. * Returns the matrix as a Float32Array
  15557. * @returns the matrix underlying array
  15558. */
  15559. toArray(): Float32Array;
  15560. /**
  15561. * Returns the matrix as a Float32Array
  15562. * @returns the matrix underlying array.
  15563. */
  15564. asArray(): Float32Array;
  15565. /**
  15566. * Inverts the current matrix in place
  15567. * @returns the current inverted matrix
  15568. */
  15569. invert(): Matrix;
  15570. /**
  15571. * Sets all the matrix elements to zero
  15572. * @returns the current matrix
  15573. */
  15574. reset(): Matrix;
  15575. /**
  15576. * Adds the current matrix with a second one
  15577. * @param other defines the matrix to add
  15578. * @returns a new matrix as the addition of the current matrix and the given one
  15579. */
  15580. add(other: Matrix): Matrix;
  15581. /**
  15582. * Sets the given matrix "result" to the addition of the current matrix and the given one
  15583. * @param other defines the matrix to add
  15584. * @param result defines the target matrix
  15585. * @returns the current matrix
  15586. */
  15587. addToRef(other: Matrix, result: Matrix): Matrix;
  15588. /**
  15589. * Adds in place the given matrix to the current matrix
  15590. * @param other defines the second operand
  15591. * @returns the current updated matrix
  15592. */
  15593. addToSelf(other: Matrix): Matrix;
  15594. /**
  15595. * Sets the given matrix to the current inverted Matrix
  15596. * @param other defines the target matrix
  15597. * @returns the unmodified current matrix
  15598. */
  15599. invertToRef(other: Matrix): Matrix;
  15600. /**
  15601. * Inserts the translation vector (using 3 floats) in the current matrix
  15602. * @param x defines the 1st component of the translation
  15603. * @param y defines the 2nd component of the translation
  15604. * @param z defines the 3rd component of the translation
  15605. * @returns the current updated matrix
  15606. */
  15607. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  15608. /**
  15609. * Inserts the translation vector in the current matrix
  15610. * @param vector3 defines the translation to insert
  15611. * @returns the current updated matrix
  15612. */
  15613. setTranslation(vector3: Vector3): Matrix;
  15614. /**
  15615. * Gets the translation value of the current matrix
  15616. * @returns a new Vector3 as the extracted translation from the matrix
  15617. */
  15618. getTranslation(): Vector3;
  15619. /**
  15620. * Fill a Vector3 with the extracted translation from the matrix
  15621. * @param result defines the Vector3 where to store the translation
  15622. * @returns the current matrix
  15623. */
  15624. getTranslationToRef(result: Vector3): Matrix;
  15625. /**
  15626. * Remove rotation and scaling part from the matrix
  15627. * @returns the updated matrix
  15628. */
  15629. removeRotationAndScaling(): Matrix;
  15630. /**
  15631. * Multiply two matrices
  15632. * @param other defines the second operand
  15633. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  15634. */
  15635. multiply(other: Matrix): Matrix;
  15636. /**
  15637. * Copy the current matrix from the given one
  15638. * @param other defines the source matrix
  15639. * @returns the current updated matrix
  15640. */
  15641. copyFrom(other: Matrix): Matrix;
  15642. /**
  15643. * Populates the given array from the starting index with the current matrix values
  15644. * @param array defines the target array
  15645. * @param offset defines the offset in the target array where to start storing values
  15646. * @returns the current matrix
  15647. */
  15648. copyToArray(array: Float32Array, offset?: number): Matrix;
  15649. /**
  15650. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  15651. * @param other defines the second operand
  15652. * @param result defines the matrix where to store the multiplication
  15653. * @returns the current matrix
  15654. */
  15655. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  15656. /**
  15657. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  15658. * @param other defines the second operand
  15659. * @param result defines the array where to store the multiplication
  15660. * @param offset defines the offset in the target array where to start storing values
  15661. * @returns the current matrix
  15662. */
  15663. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  15664. /**
  15665. * Check equality between this matrix and a second one
  15666. * @param value defines the second matrix to compare
  15667. * @returns true is the current matrix and the given one values are strictly equal
  15668. */
  15669. equals(value: Matrix): boolean;
  15670. /**
  15671. * Clone the current matrix
  15672. * @returns a new matrix from the current matrix
  15673. */
  15674. clone(): Matrix;
  15675. /**
  15676. * Returns the name of the current matrix class
  15677. * @returns the string "Matrix"
  15678. */
  15679. getClassName(): string;
  15680. /**
  15681. * Gets the hash code of the current matrix
  15682. * @returns the hash code
  15683. */
  15684. getHashCode(): number;
  15685. /**
  15686. * Decomposes the current Matrix into a translation, rotation and scaling components
  15687. * @param scale defines the scale vector3 given as a reference to update
  15688. * @param rotation defines the rotation quaternion given as a reference to update
  15689. * @param translation defines the translation vector3 given as a reference to update
  15690. * @returns true if operation was successful
  15691. */
  15692. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  15693. /**
  15694. * Gets specific row of the matrix
  15695. * @param index defines the number of the row to get
  15696. * @returns the index-th row of the current matrix as a new Vector4
  15697. */
  15698. getRow(index: number): Nullable<Vector4>;
  15699. /**
  15700. * Sets the index-th row of the current matrix to the vector4 values
  15701. * @param index defines the number of the row to set
  15702. * @param row defines the target vector4
  15703. * @returns the updated current matrix
  15704. */
  15705. setRow(index: number, row: Vector4): Matrix;
  15706. /**
  15707. * Compute the transpose of the matrix
  15708. * @returns the new transposed matrix
  15709. */
  15710. transpose(): Matrix;
  15711. /**
  15712. * Compute the transpose of the matrix and store it in a given matrix
  15713. * @param result defines the target matrix
  15714. * @returns the current matrix
  15715. */
  15716. transposeToRef(result: Matrix): Matrix;
  15717. /**
  15718. * Sets the index-th row of the current matrix with the given 4 x float values
  15719. * @param index defines the row index
  15720. * @param x defines the x component to set
  15721. * @param y defines the y component to set
  15722. * @param z defines the z component to set
  15723. * @param w defines the w component to set
  15724. * @returns the updated current matrix
  15725. */
  15726. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  15727. /**
  15728. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  15729. * @param scale defines the scale factor
  15730. * @returns a new matrix
  15731. */
  15732. scale(scale: number): Matrix;
  15733. /**
  15734. * Scale the current matrix values by a factor to a given result matrix
  15735. * @param scale defines the scale factor
  15736. * @param result defines the matrix to store the result
  15737. * @returns the current matrix
  15738. */
  15739. scaleToRef(scale: number, result: Matrix): Matrix;
  15740. /**
  15741. * Scale the current matrix values by a factor and add the result to a given matrix
  15742. * @param scale defines the scale factor
  15743. * @param result defines the Matrix to store the result
  15744. * @returns the current matrix
  15745. */
  15746. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  15747. /**
  15748. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  15749. * @param ref matrix to store the result
  15750. */
  15751. toNormalMatrix(ref: Matrix): void;
  15752. /**
  15753. * Gets only rotation part of the current matrix
  15754. * @returns a new matrix sets to the extracted rotation matrix from the current one
  15755. */
  15756. getRotationMatrix(): Matrix;
  15757. /**
  15758. * Extracts the rotation matrix from the current one and sets it as the given "result"
  15759. * @param result defines the target matrix to store data to
  15760. * @returns the current matrix
  15761. */
  15762. getRotationMatrixToRef(result: Matrix): Matrix;
  15763. /**
  15764. * Creates a matrix from an array
  15765. * @param array defines the source array
  15766. * @param offset defines an offset in the source array
  15767. * @returns a new Matrix set from the starting index of the given array
  15768. */
  15769. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  15770. /**
  15771. * Copy the content of an array into a given matrix
  15772. * @param array defines the source array
  15773. * @param offset defines an offset in the source array
  15774. * @param result defines the target matrix
  15775. */
  15776. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  15777. /**
  15778. * Stores an array into a matrix after having multiplied each component by a given factor
  15779. * @param array defines the source array
  15780. * @param offset defines the offset in the source array
  15781. * @param scale defines the scaling factor
  15782. * @param result defines the target matrix
  15783. */
  15784. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  15785. /**
  15786. * Stores a list of values (16) inside a given matrix
  15787. * @param initialM11 defines 1st value of 1st row
  15788. * @param initialM12 defines 2nd value of 1st row
  15789. * @param initialM13 defines 3rd value of 1st row
  15790. * @param initialM14 defines 4th value of 1st row
  15791. * @param initialM21 defines 1st value of 2nd row
  15792. * @param initialM22 defines 2nd value of 2nd row
  15793. * @param initialM23 defines 3rd value of 2nd row
  15794. * @param initialM24 defines 4th value of 2nd row
  15795. * @param initialM31 defines 1st value of 3rd row
  15796. * @param initialM32 defines 2nd value of 3rd row
  15797. * @param initialM33 defines 3rd value of 3rd row
  15798. * @param initialM34 defines 4th value of 3rd row
  15799. * @param initialM41 defines 1st value of 4th row
  15800. * @param initialM42 defines 2nd value of 4th row
  15801. * @param initialM43 defines 3rd value of 4th row
  15802. * @param initialM44 defines 4th value of 4th row
  15803. * @param result defines the target matrix
  15804. */
  15805. 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;
  15806. /**
  15807. * Gets an identity matrix that must not be updated
  15808. */
  15809. static readonly IdentityReadOnly: Matrix;
  15810. /**
  15811. * Creates new matrix from a list of values (16)
  15812. * @param initialM11 defines 1st value of 1st row
  15813. * @param initialM12 defines 2nd value of 1st row
  15814. * @param initialM13 defines 3rd value of 1st row
  15815. * @param initialM14 defines 4th value of 1st row
  15816. * @param initialM21 defines 1st value of 2nd row
  15817. * @param initialM22 defines 2nd value of 2nd row
  15818. * @param initialM23 defines 3rd value of 2nd row
  15819. * @param initialM24 defines 4th value of 2nd row
  15820. * @param initialM31 defines 1st value of 3rd row
  15821. * @param initialM32 defines 2nd value of 3rd row
  15822. * @param initialM33 defines 3rd value of 3rd row
  15823. * @param initialM34 defines 4th value of 3rd row
  15824. * @param initialM41 defines 1st value of 4th row
  15825. * @param initialM42 defines 2nd value of 4th row
  15826. * @param initialM43 defines 3rd value of 4th row
  15827. * @param initialM44 defines 4th value of 4th row
  15828. * @returns the new matrix
  15829. */
  15830. 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;
  15831. /**
  15832. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  15833. * @param scale defines the scale vector3
  15834. * @param rotation defines the rotation quaternion
  15835. * @param translation defines the translation vector3
  15836. * @returns a new matrix
  15837. */
  15838. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  15839. /**
  15840. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  15841. * @param scale defines the scale vector3
  15842. * @param rotation defines the rotation quaternion
  15843. * @param translation defines the translation vector3
  15844. * @param result defines the target matrix
  15845. */
  15846. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  15847. /**
  15848. * Creates a new identity matrix
  15849. * @returns a new identity matrix
  15850. */
  15851. static Identity(): Matrix;
  15852. /**
  15853. * Creates a new identity matrix and stores the result in a given matrix
  15854. * @param result defines the target matrix
  15855. */
  15856. static IdentityToRef(result: Matrix): void;
  15857. /**
  15858. * Creates a new zero matrix
  15859. * @returns a new zero matrix
  15860. */
  15861. static Zero(): Matrix;
  15862. /**
  15863. * Creates a new rotation matrix for "angle" radians around the X axis
  15864. * @param angle defines the angle (in radians) to use
  15865. * @return the new matrix
  15866. */
  15867. static RotationX(angle: number): Matrix;
  15868. /**
  15869. * Creates a new matrix as the invert of a given matrix
  15870. * @param source defines the source matrix
  15871. * @returns the new matrix
  15872. */
  15873. static Invert(source: Matrix): Matrix;
  15874. /**
  15875. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  15876. * @param angle defines the angle (in radians) to use
  15877. * @param result defines the target matrix
  15878. */
  15879. static RotationXToRef(angle: number, result: Matrix): void;
  15880. /**
  15881. * Creates a new rotation matrix for "angle" radians around the Y axis
  15882. * @param angle defines the angle (in radians) to use
  15883. * @return the new matrix
  15884. */
  15885. static RotationY(angle: number): Matrix;
  15886. /**
  15887. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  15888. * @param angle defines the angle (in radians) to use
  15889. * @param result defines the target matrix
  15890. */
  15891. static RotationYToRef(angle: number, result: Matrix): void;
  15892. /**
  15893. * Creates a new rotation matrix for "angle" radians around the Z axis
  15894. * @param angle defines the angle (in radians) to use
  15895. * @return the new matrix
  15896. */
  15897. static RotationZ(angle: number): Matrix;
  15898. /**
  15899. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  15900. * @param angle defines the angle (in radians) to use
  15901. * @param result defines the target matrix
  15902. */
  15903. static RotationZToRef(angle: number, result: Matrix): void;
  15904. /**
  15905. * Creates a new rotation matrix for "angle" radians around the given axis
  15906. * @param axis defines the axis to use
  15907. * @param angle defines the angle (in radians) to use
  15908. * @return the new matrix
  15909. */
  15910. static RotationAxis(axis: Vector3, angle: number): Matrix;
  15911. /**
  15912. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  15913. * @param axis defines the axis to use
  15914. * @param angle defines the angle (in radians) to use
  15915. * @param result defines the target matrix
  15916. */
  15917. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  15918. /**
  15919. * Creates a rotation matrix
  15920. * @param yaw defines the yaw angle in radians (Y axis)
  15921. * @param pitch defines the pitch angle in radians (X axis)
  15922. * @param roll defines the roll angle in radians (X axis)
  15923. * @returns the new rotation matrix
  15924. */
  15925. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  15926. /**
  15927. * Creates a rotation matrix and stores it in a given matrix
  15928. * @param yaw defines the yaw angle in radians (Y axis)
  15929. * @param pitch defines the pitch angle in radians (X axis)
  15930. * @param roll defines the roll angle in radians (X axis)
  15931. * @param result defines the target matrix
  15932. */
  15933. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  15934. /**
  15935. * Creates a scaling matrix
  15936. * @param x defines the scale factor on X axis
  15937. * @param y defines the scale factor on Y axis
  15938. * @param z defines the scale factor on Z axis
  15939. * @returns the new matrix
  15940. */
  15941. static Scaling(x: number, y: number, z: number): Matrix;
  15942. /**
  15943. * Creates a scaling matrix and stores it in a given matrix
  15944. * @param x defines the scale factor on X axis
  15945. * @param y defines the scale factor on Y axis
  15946. * @param z defines the scale factor on Z axis
  15947. * @param result defines the target matrix
  15948. */
  15949. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  15950. /**
  15951. * Creates a translation matrix
  15952. * @param x defines the translation on X axis
  15953. * @param y defines the translation on Y axis
  15954. * @param z defines the translationon Z axis
  15955. * @returns the new matrix
  15956. */
  15957. static Translation(x: number, y: number, z: number): Matrix;
  15958. /**
  15959. * Creates a translation matrix and stores it in a given matrix
  15960. * @param x defines the translation on X axis
  15961. * @param y defines the translation on Y axis
  15962. * @param z defines the translationon Z axis
  15963. * @param result defines the target matrix
  15964. */
  15965. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  15966. /**
  15967. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  15968. * @param startValue defines the start value
  15969. * @param endValue defines the end value
  15970. * @param gradient defines the gradient factor
  15971. * @returns the new matrix
  15972. */
  15973. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  15974. /**
  15975. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  15976. * @param startValue defines the start value
  15977. * @param endValue defines the end value
  15978. * @param gradient defines the gradient factor
  15979. * @param result defines the Matrix object where to store data
  15980. */
  15981. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  15982. /**
  15983. * Builds a new matrix whose values are computed by:
  15984. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  15985. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  15986. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  15987. * @param startValue defines the first matrix
  15988. * @param endValue defines the second matrix
  15989. * @param gradient defines the gradient between the two matrices
  15990. * @returns the new matrix
  15991. */
  15992. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  15993. /**
  15994. * Update a matrix to values which are computed by:
  15995. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  15996. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  15997. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  15998. * @param startValue defines the first matrix
  15999. * @param endValue defines the second matrix
  16000. * @param gradient defines the gradient between the two matrices
  16001. * @param result defines the target matrix
  16002. */
  16003. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  16004. /**
  16005. * 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"
  16006. * This function works in left handed mode
  16007. * @param eye defines the final position of the entity
  16008. * @param target defines where the entity should look at
  16009. * @param up defines the up vector for the entity
  16010. * @returns the new matrix
  16011. */
  16012. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  16013. /**
  16014. * 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".
  16015. * This function works in left handed mode
  16016. * @param eye defines the final position of the entity
  16017. * @param target defines where the entity should look at
  16018. * @param up defines the up vector for the entity
  16019. * @param result defines the target matrix
  16020. */
  16021. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  16022. /**
  16023. * 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"
  16024. * This function works in right handed mode
  16025. * @param eye defines the final position of the entity
  16026. * @param target defines where the entity should look at
  16027. * @param up defines the up vector for the entity
  16028. * @returns the new matrix
  16029. */
  16030. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  16031. /**
  16032. * 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".
  16033. * This function works in right handed mode
  16034. * @param eye defines the final position of the entity
  16035. * @param target defines where the entity should look at
  16036. * @param up defines the up vector for the entity
  16037. * @param result defines the target matrix
  16038. */
  16039. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  16040. /**
  16041. * Create a left-handed orthographic projection matrix
  16042. * @param width defines the viewport width
  16043. * @param height defines the viewport height
  16044. * @param znear defines the near clip plane
  16045. * @param zfar defines the far clip plane
  16046. * @returns a new matrix as a left-handed orthographic projection matrix
  16047. */
  16048. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  16049. /**
  16050. * Store a left-handed orthographic projection to a given matrix
  16051. * @param width defines the viewport width
  16052. * @param height defines the viewport height
  16053. * @param znear defines the near clip plane
  16054. * @param zfar defines the far clip plane
  16055. * @param result defines the target matrix
  16056. */
  16057. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  16058. /**
  16059. * Create a left-handed orthographic projection matrix
  16060. * @param left defines the viewport left coordinate
  16061. * @param right defines the viewport right coordinate
  16062. * @param bottom defines the viewport bottom coordinate
  16063. * @param top defines the viewport top coordinate
  16064. * @param znear defines the near clip plane
  16065. * @param zfar defines the far clip plane
  16066. * @returns a new matrix as a left-handed orthographic projection matrix
  16067. */
  16068. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  16069. /**
  16070. * Stores a left-handed orthographic projection into a given matrix
  16071. * @param left defines the viewport left coordinate
  16072. * @param right defines the viewport right coordinate
  16073. * @param bottom defines the viewport bottom coordinate
  16074. * @param top defines the viewport top coordinate
  16075. * @param znear defines the near clip plane
  16076. * @param zfar defines the far clip plane
  16077. * @param result defines the target matrix
  16078. */
  16079. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  16080. /**
  16081. * Creates a right-handed orthographic projection matrix
  16082. * @param left defines the viewport left coordinate
  16083. * @param right defines the viewport right coordinate
  16084. * @param bottom defines the viewport bottom coordinate
  16085. * @param top defines the viewport top coordinate
  16086. * @param znear defines the near clip plane
  16087. * @param zfar defines the far clip plane
  16088. * @returns a new matrix as a right-handed orthographic projection matrix
  16089. */
  16090. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  16091. /**
  16092. * Stores a right-handed orthographic projection into a given matrix
  16093. * @param left defines the viewport left coordinate
  16094. * @param right defines the viewport right coordinate
  16095. * @param bottom defines the viewport bottom coordinate
  16096. * @param top defines the viewport top coordinate
  16097. * @param znear defines the near clip plane
  16098. * @param zfar defines the far clip plane
  16099. * @param result defines the target matrix
  16100. */
  16101. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  16102. /**
  16103. * Creates a left-handed perspective projection matrix
  16104. * @param width defines the viewport width
  16105. * @param height defines the viewport height
  16106. * @param znear defines the near clip plane
  16107. * @param zfar defines the far clip plane
  16108. * @returns a new matrix as a left-handed perspective projection matrix
  16109. */
  16110. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  16111. /**
  16112. * Creates a left-handed perspective projection matrix
  16113. * @param fov defines the horizontal field of view
  16114. * @param aspect defines the aspect ratio
  16115. * @param znear defines the near clip plane
  16116. * @param zfar defines the far clip plane
  16117. * @returns a new matrix as a left-handed perspective projection matrix
  16118. */
  16119. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  16120. /**
  16121. * Stores a left-handed perspective projection into a given matrix
  16122. * @param fov defines the horizontal field of view
  16123. * @param aspect defines the aspect ratio
  16124. * @param znear defines the near clip plane
  16125. * @param zfar defines the far clip plane
  16126. * @param result defines the target matrix
  16127. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  16128. */
  16129. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  16130. /**
  16131. * Creates a right-handed perspective projection matrix
  16132. * @param fov defines the horizontal field of view
  16133. * @param aspect defines the aspect ratio
  16134. * @param znear defines the near clip plane
  16135. * @param zfar defines the far clip plane
  16136. * @returns a new matrix as a right-handed perspective projection matrix
  16137. */
  16138. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  16139. /**
  16140. * Stores a right-handed perspective projection into a given matrix
  16141. * @param fov defines the horizontal field of view
  16142. * @param aspect defines the aspect ratio
  16143. * @param znear defines the near clip plane
  16144. * @param zfar defines the far clip plane
  16145. * @param result defines the target matrix
  16146. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  16147. */
  16148. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  16149. /**
  16150. * Stores a perspective projection for WebVR info a given matrix
  16151. * @param fov defines the field of view
  16152. * @param znear defines the near clip plane
  16153. * @param zfar defines the far clip plane
  16154. * @param result defines the target matrix
  16155. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  16156. */
  16157. static PerspectiveFovWebVRToRef(fov: {
  16158. upDegrees: number;
  16159. downDegrees: number;
  16160. leftDegrees: number;
  16161. rightDegrees: number;
  16162. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  16163. /**
  16164. * Computes a complete transformation matrix
  16165. * @param viewport defines the viewport to use
  16166. * @param world defines the world matrix
  16167. * @param view defines the view matrix
  16168. * @param projection defines the projection matrix
  16169. * @param zmin defines the near clip plane
  16170. * @param zmax defines the far clip plane
  16171. * @returns the transformation matrix
  16172. */
  16173. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  16174. /**
  16175. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  16176. * @param matrix defines the matrix to use
  16177. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  16178. */
  16179. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  16180. /**
  16181. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  16182. * @param matrix defines the matrix to use
  16183. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  16184. */
  16185. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  16186. /**
  16187. * Compute the transpose of a given matrix
  16188. * @param matrix defines the matrix to transpose
  16189. * @returns the new matrix
  16190. */
  16191. static Transpose(matrix: Matrix): Matrix;
  16192. /**
  16193. * Compute the transpose of a matrix and store it in a target matrix
  16194. * @param matrix defines the matrix to transpose
  16195. * @param result defines the target matrix
  16196. */
  16197. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  16198. /**
  16199. * Computes a reflection matrix from a plane
  16200. * @param plane defines the reflection plane
  16201. * @returns a new matrix
  16202. */
  16203. static Reflection(plane: Plane): Matrix;
  16204. /**
  16205. * Computes a reflection matrix from a plane
  16206. * @param plane defines the reflection plane
  16207. * @param result defines the target matrix
  16208. */
  16209. static ReflectionToRef(plane: Plane, result: Matrix): void;
  16210. /**
  16211. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  16212. * @param xaxis defines the value of the 1st axis
  16213. * @param yaxis defines the value of the 2nd axis
  16214. * @param zaxis defines the value of the 3rd axis
  16215. * @param result defines the target matrix
  16216. */
  16217. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  16218. /**
  16219. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  16220. * @param quat defines the quaternion to use
  16221. * @param result defines the target matrix
  16222. */
  16223. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  16224. }
  16225. class Plane {
  16226. normal: Vector3;
  16227. d: number;
  16228. /**
  16229. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  16230. */
  16231. constructor(a: number, b: number, c: number, d: number);
  16232. /**
  16233. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  16234. */
  16235. asArray(): number[];
  16236. /**
  16237. * Returns a new plane copied from the current Plane.
  16238. */
  16239. clone(): Plane;
  16240. /**
  16241. * Returns the string "Plane".
  16242. */
  16243. getClassName(): string;
  16244. /**
  16245. * Returns the Plane hash code.
  16246. */
  16247. getHashCode(): number;
  16248. /**
  16249. * Normalize the current Plane in place.
  16250. * Returns the updated Plane.
  16251. */
  16252. normalize(): Plane;
  16253. /**
  16254. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  16255. */
  16256. transform(transformation: Matrix): Plane;
  16257. /**
  16258. * Returns the dot product (float) of the point coordinates and the plane normal.
  16259. */
  16260. dotCoordinate(point: Vector3): number;
  16261. /**
  16262. * Updates the current Plane from the plane defined by the three given points.
  16263. * Returns the updated Plane.
  16264. */
  16265. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  16266. /**
  16267. * Boolean : True is the vector "direction" is the same side than the plane normal.
  16268. */
  16269. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  16270. /**
  16271. * Returns the signed distance (float) from the given point to the Plane.
  16272. */
  16273. signedDistanceTo(point: Vector3): number;
  16274. /**
  16275. * Returns a new Plane from the given array.
  16276. */
  16277. static FromArray(array: ArrayLike<number>): Plane;
  16278. /**
  16279. * Returns a new Plane defined by the three given points.
  16280. */
  16281. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  16282. /**
  16283. * Returns a new Plane the normal vector to this plane at the given origin point.
  16284. * Note : the vector "normal" is updated because normalized.
  16285. */
  16286. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  16287. /**
  16288. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  16289. */
  16290. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  16291. }
  16292. class Viewport {
  16293. x: number;
  16294. y: number;
  16295. width: number;
  16296. height: number;
  16297. /**
  16298. * Creates a Viewport object located at (x, y) and sized (width, height).
  16299. */
  16300. constructor(x: number, y: number, width: number, height: number);
  16301. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  16302. /**
  16303. * Returns a new Viewport copied from the current one.
  16304. */
  16305. clone(): Viewport;
  16306. }
  16307. class Frustum {
  16308. /**
  16309. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  16310. */
  16311. static GetPlanes(transform: Matrix): Plane[];
  16312. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16313. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16314. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16315. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16316. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16317. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16318. /**
  16319. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  16320. */
  16321. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  16322. }
  16323. enum Space {
  16324. LOCAL = 0,
  16325. WORLD = 1,
  16326. BONE = 2,
  16327. }
  16328. class Axis {
  16329. static X: Vector3;
  16330. static Y: Vector3;
  16331. static Z: Vector3;
  16332. }
  16333. class BezierCurve {
  16334. /**
  16335. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  16336. */
  16337. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  16338. }
  16339. enum Orientation {
  16340. CW = 0,
  16341. CCW = 1,
  16342. }
  16343. class Angle {
  16344. private _radians;
  16345. /**
  16346. * Creates an Angle object of "radians" radians (float).
  16347. */
  16348. constructor(radians: number);
  16349. /**
  16350. * Returns the Angle value in degrees (float).
  16351. */
  16352. degrees: () => number;
  16353. /**
  16354. * Returns the Angle value in radians (float).
  16355. */
  16356. radians: () => number;
  16357. /**
  16358. * Returns a new Angle object valued with the angle value in radians between the two given vectors.
  16359. */
  16360. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  16361. /**
  16362. * Returns a new Angle object from the given float in radians.
  16363. */
  16364. static FromRadians(radians: number): Angle;
  16365. /**
  16366. * Returns a new Angle object from the given float in degrees.
  16367. */
  16368. static FromDegrees(degrees: number): Angle;
  16369. }
  16370. class Arc2 {
  16371. startPoint: Vector2;
  16372. midPoint: Vector2;
  16373. endPoint: Vector2;
  16374. centerPoint: Vector2;
  16375. radius: number;
  16376. angle: Angle;
  16377. startAngle: Angle;
  16378. orientation: Orientation;
  16379. /**
  16380. * Creates an Arc object from the three given points : start, middle and end.
  16381. */
  16382. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  16383. }
  16384. class Path2 {
  16385. private _points;
  16386. private _length;
  16387. closed: boolean;
  16388. /**
  16389. * Creates a Path2 object from the starting 2D coordinates x and y.
  16390. */
  16391. constructor(x: number, y: number);
  16392. /**
  16393. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  16394. * Returns the updated Path2.
  16395. */
  16396. addLineTo(x: number, y: number): Path2;
  16397. /**
  16398. * 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.
  16399. * Returns the updated Path2.
  16400. */
  16401. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  16402. /**
  16403. * Closes the Path2.
  16404. * Returns the Path2.
  16405. */
  16406. close(): Path2;
  16407. /**
  16408. * Returns the Path2 total length (float).
  16409. */
  16410. length(): number;
  16411. /**
  16412. * Returns the Path2 internal array of points.
  16413. */
  16414. getPoints(): Vector2[];
  16415. /**
  16416. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  16417. */
  16418. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  16419. /**
  16420. * Returns a new Path2 starting at the coordinates (x, y).
  16421. */
  16422. static StartingAt(x: number, y: number): Path2;
  16423. }
  16424. class Path3D {
  16425. path: Vector3[];
  16426. private _curve;
  16427. private _distances;
  16428. private _tangents;
  16429. private _normals;
  16430. private _binormals;
  16431. private _raw;
  16432. /**
  16433. * new Path3D(path, normal, raw)
  16434. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  16435. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  16436. * path : an array of Vector3, the curve axis of the Path3D
  16437. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  16438. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  16439. */
  16440. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  16441. /**
  16442. * Returns the Path3D array of successive Vector3 designing its curve.
  16443. */
  16444. getCurve(): Vector3[];
  16445. /**
  16446. * Returns an array populated with tangent vectors on each Path3D curve point.
  16447. */
  16448. getTangents(): Vector3[];
  16449. /**
  16450. * Returns an array populated with normal vectors on each Path3D curve point.
  16451. */
  16452. getNormals(): Vector3[];
  16453. /**
  16454. * Returns an array populated with binormal vectors on each Path3D curve point.
  16455. */
  16456. getBinormals(): Vector3[];
  16457. /**
  16458. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  16459. */
  16460. getDistances(): number[];
  16461. /**
  16462. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  16463. * Returns the same object updated.
  16464. */
  16465. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  16466. private _compute(firstNormal);
  16467. private _getFirstNonNullVector(index);
  16468. private _getLastNonNullVector(index);
  16469. private _normalVector(v0, vt, va);
  16470. }
  16471. class Curve3 {
  16472. private _points;
  16473. private _length;
  16474. /**
  16475. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  16476. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  16477. * @param v1 (Vector3) the control point
  16478. * @param v2 (Vector3) the end point of the Quadratic Bezier
  16479. * @param nbPoints (integer) the wanted number of points in the curve
  16480. */
  16481. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  16482. /**
  16483. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  16484. * @param v0 (Vector3) the origin point of the Cubic Bezier
  16485. * @param v1 (Vector3) the first control point
  16486. * @param v2 (Vector3) the second control point
  16487. * @param v3 (Vector3) the end point of the Cubic Bezier
  16488. * @param nbPoints (integer) the wanted number of points in the curve
  16489. */
  16490. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  16491. /**
  16492. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  16493. * @param p1 (Vector3) the origin point of the Hermite Spline
  16494. * @param t1 (Vector3) the tangent vector at the origin point
  16495. * @param p2 (Vector3) the end point of the Hermite Spline
  16496. * @param t2 (Vector3) the tangent vector at the end point
  16497. * @param nbPoints (integer) the wanted number of points in the curve
  16498. */
  16499. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  16500. /**
  16501. * Returns a Curve3 object along a CatmullRom Spline curve :
  16502. * @param points (array of Vector3) the points the spline must pass through. At least, four points required.
  16503. * @param nbPoints (integer) the wanted number of points between each curve control points.
  16504. */
  16505. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3;
  16506. /**
  16507. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  16508. * A Curve3 is designed from a series of successive Vector3.
  16509. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  16510. */
  16511. constructor(points: Vector3[]);
  16512. /**
  16513. * Returns the Curve3 stored array of successive Vector3
  16514. */
  16515. getPoints(): Vector3[];
  16516. /**
  16517. * Returns the computed length (float) of the curve.
  16518. */
  16519. length(): number;
  16520. /**
  16521. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  16522. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  16523. * curveA and curveB keep unchanged.
  16524. */
  16525. continue(curve: Curve3): Curve3;
  16526. private _computeLength(path);
  16527. }
  16528. class PositionNormalVertex {
  16529. position: Vector3;
  16530. normal: Vector3;
  16531. constructor(position?: Vector3, normal?: Vector3);
  16532. clone(): PositionNormalVertex;
  16533. }
  16534. class PositionNormalTextureVertex {
  16535. position: Vector3;
  16536. normal: Vector3;
  16537. uv: Vector2;
  16538. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  16539. clone(): PositionNormalTextureVertex;
  16540. }
  16541. class Tmp {
  16542. static Color3: Color3[];
  16543. static Vector2: Vector2[];
  16544. static Vector3: Vector3[];
  16545. static Vector4: Vector4[];
  16546. static Quaternion: Quaternion[];
  16547. static Matrix: Matrix[];
  16548. }
  16549. }
  16550. declare module BABYLON {
  16551. class SphericalPolynomial {
  16552. x: Vector3;
  16553. y: Vector3;
  16554. z: Vector3;
  16555. xx: Vector3;
  16556. yy: Vector3;
  16557. zz: Vector3;
  16558. xy: Vector3;
  16559. yz: Vector3;
  16560. zx: Vector3;
  16561. addAmbient(color: Color3): void;
  16562. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  16563. scale(scale: number): void;
  16564. }
  16565. class SphericalHarmonics {
  16566. L00: Vector3;
  16567. L1_1: Vector3;
  16568. L10: Vector3;
  16569. L11: Vector3;
  16570. L2_2: Vector3;
  16571. L2_1: Vector3;
  16572. L20: Vector3;
  16573. L21: Vector3;
  16574. L22: Vector3;
  16575. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  16576. scale(scale: number): void;
  16577. convertIncidentRadianceToIrradiance(): void;
  16578. convertIrradianceToLambertianRadiance(): void;
  16579. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  16580. }
  16581. }
  16582. declare module BABYLON {
  16583. /**
  16584. * Defines a target to use with MorphTargetManager
  16585. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  16586. */
  16587. class MorphTarget implements IAnimatable {
  16588. /** defines the name of the target */
  16589. name: string;
  16590. /**
  16591. * Gets or sets the list of animations
  16592. */
  16593. animations: Animation[];
  16594. private _positions;
  16595. private _normals;
  16596. private _tangents;
  16597. private _influence;
  16598. /**
  16599. * Observable raised when the influence changes
  16600. */
  16601. onInfluenceChanged: Observable<boolean>;
  16602. /**
  16603. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  16604. */
  16605. influence: number;
  16606. /**
  16607. * Creates a new MorphTarget
  16608. * @param name defines the name of the target
  16609. * @param influence defines the influence to use
  16610. */
  16611. constructor(
  16612. /** defines the name of the target */
  16613. name: string, influence?: number);
  16614. /**
  16615. * Gets a boolean defining if the target contains position data
  16616. */
  16617. readonly hasPositions: boolean;
  16618. /**
  16619. * Gets a boolean defining if the target contains normal data
  16620. */
  16621. readonly hasNormals: boolean;
  16622. /**
  16623. * Gets a boolean defining if the target contains tangent data
  16624. */
  16625. readonly hasTangents: boolean;
  16626. /**
  16627. * Affects position data to this target
  16628. * @param data defines the position data to use
  16629. */
  16630. setPositions(data: Nullable<FloatArray>): void;
  16631. /**
  16632. * Gets the position data stored in this target
  16633. * @returns a FloatArray containing the position data (or null if not present)
  16634. */
  16635. getPositions(): Nullable<FloatArray>;
  16636. /**
  16637. * Affects normal data to this target
  16638. * @param data defines the normal data to use
  16639. */
  16640. setNormals(data: Nullable<FloatArray>): void;
  16641. /**
  16642. * Gets the normal data stored in this target
  16643. * @returns a FloatArray containing the normal data (or null if not present)
  16644. */
  16645. getNormals(): Nullable<FloatArray>;
  16646. /**
  16647. * Affects tangent data to this target
  16648. * @param data defines the tangent data to use
  16649. */
  16650. setTangents(data: Nullable<FloatArray>): void;
  16651. /**
  16652. * Gets the tangent data stored in this target
  16653. * @returns a FloatArray containing the tangent data (or null if not present)
  16654. */
  16655. getTangents(): Nullable<FloatArray>;
  16656. /**
  16657. * Serializes the current target into a Serialization object
  16658. * @returns the serialized object
  16659. */
  16660. serialize(): any;
  16661. /**
  16662. * Creates a new target from serialized data
  16663. * @param serializationObject defines the serialized data to use
  16664. * @returns a new MorphTarget
  16665. */
  16666. static Parse(serializationObject: any): MorphTarget;
  16667. /**
  16668. * Creates a MorphTarget from mesh data
  16669. * @param mesh defines the source mesh
  16670. * @param name defines the name to use for the new target
  16671. * @param influence defines the influence to attach to the target
  16672. * @returns a new MorphTarget
  16673. */
  16674. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  16675. }
  16676. }
  16677. declare module BABYLON {
  16678. /**
  16679. * This class is used to deform meshes using morphing between different targets
  16680. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  16681. */
  16682. class MorphTargetManager {
  16683. private _targets;
  16684. private _targetObservable;
  16685. private _activeTargets;
  16686. private _scene;
  16687. private _influences;
  16688. private _supportsNormals;
  16689. private _supportsTangents;
  16690. private _vertexCount;
  16691. private _uniqueId;
  16692. private _tempInfluences;
  16693. /**
  16694. * Creates a new MorphTargetManager
  16695. * @param scene defines the current scene
  16696. */
  16697. constructor(scene?: Nullable<Scene>);
  16698. /**
  16699. * Gets the unique ID of this manager
  16700. */
  16701. readonly uniqueId: number;
  16702. /**
  16703. * Gets the number of vertices handled by this manager
  16704. */
  16705. readonly vertexCount: number;
  16706. /**
  16707. * Gets a boolean indicating if this manager supports morphing of normals
  16708. */
  16709. readonly supportsNormals: boolean;
  16710. /**
  16711. * Gets a boolean indicating if this manager supports morphing of tangents
  16712. */
  16713. readonly supportsTangents: boolean;
  16714. /**
  16715. * Gets the number of targets stored in this manager
  16716. */
  16717. readonly numTargets: number;
  16718. /**
  16719. * Gets the number of influencers (ie. the number of targets with influences > 0)
  16720. */
  16721. readonly numInfluencers: number;
  16722. /**
  16723. * Gets the list of influences (one per target)
  16724. */
  16725. readonly influences: Float32Array;
  16726. /**
  16727. * Gets the active target at specified index. An active target is a target with an influence > 0
  16728. * @param index defines the index to check
  16729. * @returns the requested target
  16730. */
  16731. getActiveTarget(index: number): MorphTarget;
  16732. /**
  16733. * Gets the target at specified index
  16734. * @param index defines the index to check
  16735. * @returns the requested target
  16736. */
  16737. getTarget(index: number): MorphTarget;
  16738. /**
  16739. * Add a new target to this manager
  16740. * @param target defines the target to add
  16741. */
  16742. addTarget(target: MorphTarget): void;
  16743. /**
  16744. * Removes a target from the manager
  16745. * @param target defines the target to remove
  16746. */
  16747. removeTarget(target: MorphTarget): void;
  16748. /**
  16749. * Serializes the current manager into a Serialization object
  16750. * @returns the serialized object
  16751. */
  16752. serialize(): any;
  16753. private _syncActiveTargets(needUpdate);
  16754. /**
  16755. * Syncrhonize the targets with all the meshes using this morph target manager
  16756. */
  16757. synchronize(): void;
  16758. /**
  16759. * Creates a new MorphTargetManager from serialized data
  16760. * @param serializationObject defines the serialized data
  16761. * @param scene defines the hosting scene
  16762. * @returns the new MorphTargetManager
  16763. */
  16764. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  16765. }
  16766. }
  16767. declare module BABYLON {
  16768. /**
  16769. * This represents a GPU particle system in Babylon
  16770. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  16771. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  16772. */
  16773. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  16774. /**
  16775. * The id of the Particle system.
  16776. */
  16777. id: string;
  16778. /**
  16779. * The friendly name of the Particle system.
  16780. */
  16781. name: string;
  16782. /**
  16783. * The emitter represents the Mesh or position we are attaching the particle system to.
  16784. */
  16785. emitter: Nullable<AbstractMesh | Vector3>;
  16786. /**
  16787. * The rendering group used by the Particle system to chose when to render.
  16788. */
  16789. renderingGroupId: number;
  16790. /**
  16791. * The layer mask we are rendering the particles through.
  16792. */
  16793. layerMask: number;
  16794. private _capacity;
  16795. private _activeCount;
  16796. private _currentActiveCount;
  16797. private _renderEffect;
  16798. private _updateEffect;
  16799. private _buffer0;
  16800. private _buffer1;
  16801. private _spriteBuffer;
  16802. private _updateVAO;
  16803. private _renderVAO;
  16804. private _targetIndex;
  16805. private _sourceBuffer;
  16806. private _targetBuffer;
  16807. private _scene;
  16808. private _engine;
  16809. private _currentRenderId;
  16810. private _started;
  16811. private _stopped;
  16812. private _timeDelta;
  16813. private _randomTexture;
  16814. private readonly _attributesStrideSize;
  16815. private _updateEffectOptions;
  16816. private _randomTextureSize;
  16817. private _actualFrame;
  16818. /**
  16819. * List of animations used by the particle system.
  16820. */
  16821. animations: Animation[];
  16822. /**
  16823. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  16824. */
  16825. static readonly IsSupported: boolean;
  16826. /**
  16827. * An event triggered when the system is disposed.
  16828. */
  16829. onDisposeObservable: Observable<GPUParticleSystem>;
  16830. /**
  16831. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16832. */
  16833. updateSpeed: number;
  16834. /**
  16835. * The amount of time the particle system is running (depends of the overall update speed).
  16836. */
  16837. targetStopDuration: number;
  16838. /**
  16839. * The texture used to render each particle. (this can be a spritesheet)
  16840. */
  16841. particleTexture: Nullable<Texture>;
  16842. /**
  16843. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16844. */
  16845. blendMode: number;
  16846. /**
  16847. * Minimum life time of emitting particles.
  16848. */
  16849. minLifeTime: number;
  16850. /**
  16851. * Maximum life time of emitting particles.
  16852. */
  16853. maxLifeTime: number;
  16854. /**
  16855. * Minimum Size of emitting particles.
  16856. */
  16857. minSize: number;
  16858. /**
  16859. * Maximum Size of emitting particles.
  16860. */
  16861. maxSize: number;
  16862. /**
  16863. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16864. */
  16865. color1: Color4;
  16866. /**
  16867. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16868. */
  16869. color2: Color4;
  16870. /**
  16871. * Color the particle will have at the end of its lifetime.
  16872. */
  16873. colorDead: Color4;
  16874. /**
  16875. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16876. */
  16877. emitRate: number;
  16878. /**
  16879. * You can use gravity if you want to give an orientation to your particles.
  16880. */
  16881. gravity: Vector3;
  16882. /**
  16883. * Minimum power of emitting particles.
  16884. */
  16885. minEmitPower: number;
  16886. /**
  16887. * Maximum power of emitting particles.
  16888. */
  16889. maxEmitPower: number;
  16890. /**
  16891. * The particle emitter type defines the emitter used by the particle system.
  16892. * It can be for example box, sphere, or cone...
  16893. */
  16894. particleEmitterType: Nullable<IParticleEmitterType>;
  16895. /**
  16896. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16897. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16898. */
  16899. direction1: Vector3;
  16900. /**
  16901. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16902. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16903. */
  16904. direction2: Vector3;
  16905. /**
  16906. * 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.
  16907. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16908. */
  16909. minEmitBox: Vector3;
  16910. /**
  16911. * 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.
  16912. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16913. */
  16914. maxEmitBox: Vector3;
  16915. /**
  16916. * Gets the maximum number of particles active at the same time.
  16917. * @returns The max number of active particles.
  16918. */
  16919. getCapacity(): number;
  16920. /**
  16921. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16922. * to override the particles.
  16923. */
  16924. forceDepthWrite: boolean;
  16925. /**
  16926. * Gets or set the number of active particles
  16927. */
  16928. activeParticleCount: number;
  16929. /**
  16930. * Is this system ready to be used/rendered
  16931. * @return true if the system is ready
  16932. */
  16933. isReady(): boolean;
  16934. /**
  16935. * Gets Wether the system has been started.
  16936. * @returns True if it has been started, otherwise false.
  16937. */
  16938. isStarted(): boolean;
  16939. /**
  16940. * Starts the particle system and begins to emit.
  16941. */
  16942. start(): void;
  16943. /**
  16944. * Stops the particle system.
  16945. */
  16946. stop(): void;
  16947. /**
  16948. * Remove all active particles
  16949. */
  16950. reset(): void;
  16951. /**
  16952. * Returns the string "GPUParticleSystem"
  16953. * @returns a string containing the class name
  16954. */
  16955. getClassName(): string;
  16956. /**
  16957. * Instantiates a GPU particle system.
  16958. * 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.
  16959. * @param name The name of the particle system
  16960. * @param capacity The max number of particles alive at the same time
  16961. * @param scene The scene the particle system belongs to
  16962. */
  16963. constructor(name: string, options: Partial<{
  16964. capacity: number;
  16965. randomTextureSize: number;
  16966. }>, scene: Scene);
  16967. private _createUpdateVAO(source);
  16968. private _createRenderVAO(source, spriteSource);
  16969. private _initialize(force?);
  16970. /** @ignore */
  16971. _recreateUpdateEffect(): void;
  16972. /** @ignore */
  16973. _recreateRenderEffect(): void;
  16974. /**
  16975. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16976. */
  16977. animate(): void;
  16978. /**
  16979. * Renders the particle system in its current state.
  16980. * @returns the current number of particles
  16981. */
  16982. render(): number;
  16983. /**
  16984. * Rebuilds the particle system
  16985. */
  16986. rebuild(): void;
  16987. private _releaseBuffers();
  16988. private _releaseVAOs();
  16989. /**
  16990. * Disposes the particle system and free the associated resources
  16991. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16992. */
  16993. dispose(disposeTexture?: boolean): void;
  16994. /**
  16995. * Clones the particle system.
  16996. * @param name The name of the cloned object
  16997. * @param newEmitter The new emitter to use
  16998. * @returns the cloned particle system
  16999. */
  17000. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  17001. /**
  17002. * Serializes the particle system to a JSON object.
  17003. * @returns the JSON object
  17004. */
  17005. serialize(): any;
  17006. /**
  17007. * Parses a JSON object to create a GPU particle system.
  17008. * @param parsedParticleSystem The JSON object to parse
  17009. * @param scene The scene to create the particle system in
  17010. * @param rootUrl The root url to use to load external dependencies like texture
  17011. * @returns the parsed GPU particle system
  17012. */
  17013. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  17014. }
  17015. }
  17016. declare module BABYLON {
  17017. /**
  17018. * Interface representing a particle system in Babylon.
  17019. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17020. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17021. */
  17022. interface IParticleSystem {
  17023. /**
  17024. * The id of the Particle system.
  17025. */
  17026. id: string;
  17027. /**
  17028. * The name of the Particle system.
  17029. */
  17030. name: string;
  17031. /**
  17032. * The emitter represents the Mesh or position we are attaching the particle system to.
  17033. */
  17034. emitter: Nullable<AbstractMesh | Vector3>;
  17035. /**
  17036. * The rendering group used by the Particle system to chose when to render.
  17037. */
  17038. renderingGroupId: number;
  17039. /**
  17040. * The layer mask we are rendering the particles through.
  17041. */
  17042. layerMask: number;
  17043. /**
  17044. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17045. */
  17046. updateSpeed: number;
  17047. /**
  17048. * The amount of time the particle system is running (depends of the overall update speed).
  17049. */
  17050. targetStopDuration: number;
  17051. /**
  17052. * The texture used to render each particle. (this can be a spritesheet)
  17053. */
  17054. particleTexture: Nullable<Texture>;
  17055. /**
  17056. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17057. */
  17058. blendMode: number;
  17059. /**
  17060. * Minimum life time of emitting particles.
  17061. */
  17062. minLifeTime: number;
  17063. /**
  17064. * Maximum life time of emitting particles.
  17065. */
  17066. maxLifeTime: number;
  17067. /**
  17068. * Minimum Size of emitting particles.
  17069. */
  17070. minSize: number;
  17071. /**
  17072. * Maximum Size of emitting particles.
  17073. */
  17074. maxSize: number;
  17075. /**
  17076. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17077. */
  17078. color1: Color4;
  17079. /**
  17080. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17081. */
  17082. color2: Color4;
  17083. /**
  17084. * Color the particle will have at the end of its lifetime.
  17085. */
  17086. colorDead: Color4;
  17087. /**
  17088. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17089. */
  17090. emitRate: number;
  17091. /**
  17092. * You can use gravity if you want to give an orientation to your particles.
  17093. */
  17094. gravity: Vector3;
  17095. /**
  17096. * Minimum power of emitting particles.
  17097. */
  17098. minEmitPower: number;
  17099. /**
  17100. * Maximum power of emitting particles.
  17101. */
  17102. maxEmitPower: number;
  17103. /**
  17104. * The particle emitter type defines the emitter used by the particle system.
  17105. * It can be for example box, sphere, or cone...
  17106. */
  17107. particleEmitterType: Nullable<IParticleEmitterType>;
  17108. /**
  17109. * Gets the maximum number of particles active at the same time.
  17110. * @returns The max number of active particles.
  17111. */
  17112. getCapacity(): number;
  17113. /**
  17114. * Gets Wether the system has been started.
  17115. * @returns True if it has been started, otherwise false.
  17116. */
  17117. isStarted(): boolean;
  17118. /**
  17119. * Gets if the particle system has been started.
  17120. * @return true if the system has been started, otherwise false.
  17121. */
  17122. isStarted(): boolean;
  17123. /**
  17124. * Animates the particle system for this frame.
  17125. */
  17126. animate(): void;
  17127. /**
  17128. * Renders the particle system in its current state.
  17129. * @returns the current number of particles
  17130. */
  17131. render(): number;
  17132. /**
  17133. * Dispose the particle system and frees its associated resources.
  17134. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17135. */
  17136. dispose(disposeTexture?: boolean): void;
  17137. /**
  17138. * Clones the particle system.
  17139. * @param name The name of the cloned object
  17140. * @param newEmitter The new emitter to use
  17141. * @returns the cloned particle system
  17142. */
  17143. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17144. /**
  17145. * Serializes the particle system to a JSON object.
  17146. * @returns the JSON object
  17147. */
  17148. serialize(): any;
  17149. /**
  17150. * Rebuild the particle system
  17151. */
  17152. rebuild(): void;
  17153. /**
  17154. * Starts the particle system and begins to emit.
  17155. */
  17156. start(): void;
  17157. /**
  17158. * Stops the particle system.
  17159. */
  17160. stop(): void;
  17161. /**
  17162. * Remove all active particles
  17163. */
  17164. reset(): void;
  17165. /**
  17166. * Is this system ready to be used/rendered
  17167. * @return true if the system is ready
  17168. */
  17169. isReady(): boolean;
  17170. }
  17171. }
  17172. declare module BABYLON {
  17173. /**
  17174. * A particle represents one of the element emitted by a particle system.
  17175. * This is mainly define by its coordinates, direction, velocity and age.
  17176. */
  17177. class Particle {
  17178. /**
  17179. * particleSystem the particle system the particle belongs to.
  17180. */
  17181. particleSystem: ParticleSystem;
  17182. /**
  17183. * The world position of the particle in the scene.
  17184. */
  17185. position: Vector3;
  17186. /**
  17187. * The world direction of the particle in the scene.
  17188. */
  17189. direction: Vector3;
  17190. /**
  17191. * The color of the particle.
  17192. */
  17193. color: Color4;
  17194. /**
  17195. * The color change of the particle per step.
  17196. */
  17197. colorStep: Color4;
  17198. /**
  17199. * Defines how long will the life of the particle be.
  17200. */
  17201. lifeTime: number;
  17202. /**
  17203. * The current age of the particle.
  17204. */
  17205. age: number;
  17206. /**
  17207. * The current size of the particle.
  17208. */
  17209. size: number;
  17210. /**
  17211. * The current angle of the particle.
  17212. */
  17213. angle: number;
  17214. /**
  17215. * Defines how fast is the angle changing.
  17216. */
  17217. angularSpeed: number;
  17218. /**
  17219. * Defines the cell index used by the particle to be rendered from a sprite.
  17220. */
  17221. cellIndex: number;
  17222. private _currentFrameCounter;
  17223. /**
  17224. * Creates a new instance Particle
  17225. * @param particleSystem the particle system the particle belongs to
  17226. */
  17227. constructor(
  17228. /**
  17229. * particleSystem the particle system the particle belongs to.
  17230. */
  17231. particleSystem: ParticleSystem);
  17232. private updateCellInfoFromSystem();
  17233. /**
  17234. * Defines how the sprite cell index is updated for the particle. This is
  17235. * defined as a callback.
  17236. */
  17237. updateCellIndex: (scaledUpdateSpeed: number) => void;
  17238. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  17239. private _updateCellIndexWithCustomSpeed();
  17240. /**
  17241. * Copy the properties of particle to another one.
  17242. * @param other the particle to copy the information to.
  17243. */
  17244. copyTo(other: Particle): void;
  17245. }
  17246. }
  17247. declare module BABYLON {
  17248. /**
  17249. * This represents a particle system in Babylon.
  17250. * 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.
  17251. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17252. * @example https://doc.babylonjs.com/babylon101/particles
  17253. */
  17254. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17255. /**
  17256. * Source color is added to the destination color without alpha affecting the result.
  17257. */
  17258. static BLENDMODE_ONEONE: number;
  17259. /**
  17260. * Blend current color and particle color using particle’s alpha.
  17261. */
  17262. static BLENDMODE_STANDARD: number;
  17263. /**
  17264. * List of animations used by the particle system.
  17265. */
  17266. animations: Animation[];
  17267. /**
  17268. * The id of the Particle system.
  17269. */
  17270. id: string;
  17271. /**
  17272. * The friendly name of the Particle system.
  17273. */
  17274. name: string;
  17275. /**
  17276. * The rendering group used by the Particle system to chose when to render.
  17277. */
  17278. renderingGroupId: number;
  17279. /**
  17280. * The emitter represents the Mesh or position we are attaching the particle system to.
  17281. */
  17282. emitter: Nullable<AbstractMesh | Vector3>;
  17283. /**
  17284. * The maximum number of particles to emit per frame
  17285. */
  17286. emitRate: number;
  17287. /**
  17288. * If you want to launch only a few particles at once, that can be done, as well.
  17289. */
  17290. manualEmitCount: number;
  17291. /**
  17292. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17293. */
  17294. updateSpeed: number;
  17295. /**
  17296. * The amount of time the particle system is running (depends of the overall update speed).
  17297. */
  17298. targetStopDuration: number;
  17299. /**
  17300. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17301. */
  17302. disposeOnStop: boolean;
  17303. /**
  17304. * Minimum power of emitting particles.
  17305. */
  17306. minEmitPower: number;
  17307. /**
  17308. * Maximum power of emitting particles.
  17309. */
  17310. maxEmitPower: number;
  17311. /**
  17312. * Minimum life time of emitting particles.
  17313. */
  17314. minLifeTime: number;
  17315. /**
  17316. * Maximum life time of emitting particles.
  17317. */
  17318. maxLifeTime: number;
  17319. /**
  17320. * Minimum Size of emitting particles.
  17321. */
  17322. minSize: number;
  17323. /**
  17324. * Maximum Size of emitting particles.
  17325. */
  17326. maxSize: number;
  17327. /**
  17328. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17329. */
  17330. minAngularSpeed: number;
  17331. /**
  17332. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17333. */
  17334. maxAngularSpeed: number;
  17335. /**
  17336. * The texture used to render each particle. (this can be a spritesheet)
  17337. */
  17338. particleTexture: Nullable<Texture>;
  17339. /**
  17340. * The layer mask we are rendering the particles through.
  17341. */
  17342. layerMask: number;
  17343. /**
  17344. * This can help using your own shader to render the particle system.
  17345. * The according effect will be created
  17346. */
  17347. customShader: any;
  17348. /**
  17349. * By default particle system starts as soon as they are created. This prevents the
  17350. * automatic start to happen and let you decide when to start emitting particles.
  17351. */
  17352. preventAutoStart: boolean;
  17353. /**
  17354. * This function can be defined to provide custom update for active particles.
  17355. * This function will be called instead of regular update (age, position, color, etc.).
  17356. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17357. */
  17358. updateFunction: (particles: Particle[]) => void;
  17359. /**
  17360. * Callback triggered when the particle animation is ending.
  17361. */
  17362. onAnimationEnd: Nullable<() => void>;
  17363. /**
  17364. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17365. */
  17366. blendMode: number;
  17367. /**
  17368. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17369. * to override the particles.
  17370. */
  17371. forceDepthWrite: boolean;
  17372. /**
  17373. * You can use gravity if you want to give an orientation to your particles.
  17374. */
  17375. gravity: Vector3;
  17376. /**
  17377. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17378. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17379. */
  17380. direction1: Vector3;
  17381. /**
  17382. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17383. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17384. */
  17385. direction2: Vector3;
  17386. /**
  17387. * 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.
  17388. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17389. */
  17390. minEmitBox: Vector3;
  17391. /**
  17392. * 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.
  17393. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17394. */
  17395. maxEmitBox: Vector3;
  17396. /**
  17397. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17398. */
  17399. color1: Color4;
  17400. /**
  17401. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17402. */
  17403. color2: Color4;
  17404. /**
  17405. * Color the particle will have at the end of its lifetime.
  17406. */
  17407. colorDead: Color4;
  17408. /**
  17409. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  17410. */
  17411. textureMask: Color4;
  17412. /**
  17413. * The particle emitter type defines the emitter used by the particle system.
  17414. * It can be for example box, sphere, or cone...
  17415. */
  17416. particleEmitterType: IParticleEmitterType;
  17417. /**
  17418. * This function can be defined to specify initial direction for every new particle.
  17419. * It by default use the emitterType defined function.
  17420. */
  17421. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17422. /**
  17423. * This function can be defined to specify initial position for every new particle.
  17424. * It by default use the emitterType defined function.
  17425. */
  17426. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17427. /**
  17428. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  17429. */
  17430. spriteCellLoop: boolean;
  17431. /**
  17432. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  17433. */
  17434. spriteCellChangeSpeed: number;
  17435. /**
  17436. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  17437. */
  17438. startSpriteCellID: number;
  17439. /**
  17440. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  17441. */
  17442. endSpriteCellID: number;
  17443. /**
  17444. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  17445. */
  17446. spriteCellWidth: number;
  17447. /**
  17448. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  17449. */
  17450. spriteCellHeight: number;
  17451. /**
  17452. * An event triggered when the system is disposed.
  17453. */
  17454. onDisposeObservable: Observable<ParticleSystem>;
  17455. private _onDisposeObserver;
  17456. /**
  17457. * Sets a callback that will be triggered when the system is disposed.
  17458. */
  17459. onDispose: () => void;
  17460. /**
  17461. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  17462. */
  17463. readonly isAnimationSheetEnabled: Boolean;
  17464. private _particles;
  17465. private _epsilon;
  17466. private _capacity;
  17467. private _scene;
  17468. private _stockParticles;
  17469. private _newPartsExcess;
  17470. private _vertexData;
  17471. private _vertexBuffer;
  17472. private _vertexBuffers;
  17473. private _indexBuffer;
  17474. private _effect;
  17475. private _customEffect;
  17476. private _cachedDefines;
  17477. private _scaledColorStep;
  17478. private _colorDiff;
  17479. private _scaledDirection;
  17480. private _scaledGravity;
  17481. private _currentRenderId;
  17482. private _alive;
  17483. private _started;
  17484. private _stopped;
  17485. private _actualFrame;
  17486. private _scaledUpdateSpeed;
  17487. private _vertexBufferSize;
  17488. private _isAnimationSheetEnabled;
  17489. /**
  17490. * this is the Sub-emitters templates that will be used to generate particle system when the particle dies, this property is used by the root particle system only.
  17491. */
  17492. subEmitters: ParticleSystem[];
  17493. /**
  17494. * The current active Sub-systems, this property is used by the root particle system only.
  17495. */
  17496. activeSubSystems: Array<ParticleSystem>;
  17497. private _rootParticleSystem;
  17498. /**
  17499. * Gets the current list of active particles
  17500. */
  17501. readonly particles: Particle[];
  17502. /**
  17503. * Returns the string "ParticleSystem"
  17504. * @returns a string containing the class name
  17505. */
  17506. getClassName(): string;
  17507. /**
  17508. * Instantiates a particle system.
  17509. * 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.
  17510. * @param name The name of the particle system
  17511. * @param capacity The max number of particles alive at the same time
  17512. * @param scene The scene the particle system belongs to
  17513. * @param customEffect a custom effect used to change the way particles are rendered by default
  17514. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17515. * @param epsilon Offset used to render the particles
  17516. */
  17517. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17518. private _createIndexBuffer();
  17519. /**
  17520. * Gets the maximum number of particles active at the same time.
  17521. * @returns The max number of active particles.
  17522. */
  17523. getCapacity(): number;
  17524. /**
  17525. * Gets Wether there are still active particles in the system.
  17526. * @returns True if it is alive, otherwise false.
  17527. */
  17528. isAlive(): boolean;
  17529. /**
  17530. * Gets Wether the system has been started.
  17531. * @returns True if it has been started, otherwise false.
  17532. */
  17533. isStarted(): boolean;
  17534. /**
  17535. * Starts the particle system and begins to emit.
  17536. */
  17537. start(): void;
  17538. /**
  17539. * Stops the particle system.
  17540. * @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.
  17541. */
  17542. stop(stopSubEmitters?: boolean): void;
  17543. /**
  17544. * Remove all active particles
  17545. */
  17546. reset(): void;
  17547. /**
  17548. * @ignore (for internal use only)
  17549. */
  17550. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17551. /**
  17552. * @ignore (for internal use only)
  17553. */
  17554. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17555. /**
  17556. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17557. * Its lifetime will start back at 0.
  17558. */
  17559. recycleParticle: (particle: Particle) => void;
  17560. private _stopSubEmitters();
  17561. private _createParticle;
  17562. private _removeFromRoot();
  17563. private _emitFromParticle;
  17564. private _update(newParticles);
  17565. private _getEffect();
  17566. /**
  17567. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17568. */
  17569. animate(): void;
  17570. private _appendParticleVertexes;
  17571. private _appenedParticleVertexesWithSheet(offset, particle);
  17572. private _appenedParticleVertexesNoSheet(offset, particle);
  17573. /**
  17574. * Rebuilds the particle system.
  17575. */
  17576. rebuild(): void;
  17577. /**
  17578. * Is this system ready to be used/rendered
  17579. * @return true if the system is ready
  17580. */
  17581. isReady(): boolean;
  17582. /**
  17583. * Renders the particle system in its current state.
  17584. * @returns the current number of particles
  17585. */
  17586. render(): number;
  17587. /**
  17588. * Disposes the particle system and free the associated resources
  17589. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17590. */
  17591. dispose(disposeTexture?: boolean): void;
  17592. /**
  17593. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  17594. * @param radius The radius of the sphere to emit from
  17595. * @returns the emitter
  17596. */
  17597. createSphereEmitter(radius?: number): SphereParticleEmitter;
  17598. /**
  17599. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  17600. * @param radius The radius of the sphere to emit from
  17601. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17602. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17603. * @returns the emitter
  17604. */
  17605. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17606. /**
  17607. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  17608. * @param radius The radius of the cone to emit from
  17609. * @param angle The base angle of the cone
  17610. * @returns the emitter
  17611. */
  17612. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17613. /**
  17614. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17615. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17616. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17617. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17618. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17619. * @returns the emitter
  17620. */
  17621. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17622. /**
  17623. * Clones the particle system.
  17624. * @param name The name of the cloned object
  17625. * @param newEmitter The new emitter to use
  17626. * @returns the cloned particle system
  17627. */
  17628. clone(name: string, newEmitter: any): ParticleSystem;
  17629. /**
  17630. * Serializes the particle system to a JSON object.
  17631. * @returns the JSON object
  17632. */
  17633. serialize(): any;
  17634. /**
  17635. * Parses a JSON object to create a particle system.
  17636. * @param parsedParticleSystem The JSON object to parse
  17637. * @param scene The scene to create the particle system in
  17638. * @param rootUrl The root url to use to load external dependencies like texture
  17639. * @returns the Parsed particle system
  17640. */
  17641. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  17642. }
  17643. }
  17644. declare module BABYLON {
  17645. /**
  17646. * Represents one particle of a solid particle system.
  17647. */
  17648. class SolidParticle {
  17649. /**
  17650. * particle global index
  17651. */
  17652. idx: number;
  17653. /**
  17654. * The color of the particle
  17655. */
  17656. color: Nullable<Color4>;
  17657. /**
  17658. * The world space position of the particle.
  17659. */
  17660. position: Vector3;
  17661. /**
  17662. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  17663. */
  17664. rotation: Vector3;
  17665. /**
  17666. * The world space rotation quaternion of the particle.
  17667. */
  17668. rotationQuaternion: Nullable<Quaternion>;
  17669. /**
  17670. * The scaling of the particle.
  17671. */
  17672. scaling: Vector3;
  17673. /**
  17674. * The uvs of the particle.
  17675. */
  17676. uvs: Vector4;
  17677. /**
  17678. * The current speed of the particle.
  17679. */
  17680. velocity: Vector3;
  17681. /**
  17682. * The pivot point in the particle local space.
  17683. */
  17684. pivot: Vector3;
  17685. /**
  17686. * Must the particle be translated from its pivot point in its local space ?
  17687. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  17688. * Default : false
  17689. */
  17690. translateFromPivot: boolean;
  17691. /**
  17692. * Is the particle active or not ?
  17693. */
  17694. alive: boolean;
  17695. /**
  17696. * Is the particle visible or not ?
  17697. */
  17698. isVisible: boolean;
  17699. /**
  17700. * Index of this particle in the global "positions" array (Internal use)
  17701. */
  17702. _pos: number;
  17703. /**
  17704. * Index of this particle in the global "indices" array (Internal use)
  17705. */
  17706. _ind: number;
  17707. /**
  17708. * ModelShape of this particle (Internal use)
  17709. */
  17710. _model: ModelShape;
  17711. /**
  17712. * ModelShape id of this particle
  17713. */
  17714. shapeId: number;
  17715. /**
  17716. * Index of the particle in its shape id (Internal use)
  17717. */
  17718. idxInShape: number;
  17719. /**
  17720. * Reference to the shape model BoundingInfo object (Internal use)
  17721. */
  17722. _modelBoundingInfo: BoundingInfo;
  17723. /**
  17724. * Particle BoundingInfo object (Internal use)
  17725. */
  17726. _boundingInfo: BoundingInfo;
  17727. /**
  17728. * Reference to the SPS what the particle belongs to (Internal use)
  17729. */
  17730. _sps: SolidParticleSystem;
  17731. /**
  17732. * Still set as invisible in order to skip useless computations (Internal use)
  17733. */
  17734. _stillInvisible: boolean;
  17735. /**
  17736. * Last computed particle rotation matrix
  17737. */
  17738. _rotationMatrix: number[];
  17739. /**
  17740. * Parent particle Id, if any.
  17741. * Default null.
  17742. */
  17743. parentId: Nullable<number>;
  17744. /**
  17745. * Internal global position in the SPS.
  17746. */
  17747. _globalPosition: Vector3;
  17748. /**
  17749. * Creates a Solid Particle object.
  17750. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  17751. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  17752. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  17753. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  17754. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  17755. * @param shapeId (integer) is the model shape identifier in the SPS.
  17756. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  17757. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  17758. */
  17759. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  17760. /**
  17761. * Legacy support, changed scale to scaling
  17762. */
  17763. /**
  17764. * Legacy support, changed scale to scaling
  17765. */
  17766. scale: Vector3;
  17767. /**
  17768. * Legacy support, changed quaternion to rotationQuaternion
  17769. */
  17770. /**
  17771. * Legacy support, changed quaternion to rotationQuaternion
  17772. */
  17773. quaternion: Nullable<Quaternion>;
  17774. /**
  17775. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  17776. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  17777. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  17778. * @returns true if it intersects
  17779. */
  17780. intersectsMesh(target: Mesh | SolidParticle): boolean;
  17781. }
  17782. /**
  17783. * Represents the shape of the model used by one particle of a solid particle system.
  17784. * SPS internal tool, don't use it manually.
  17785. */
  17786. class ModelShape {
  17787. /**
  17788. * The shape id.
  17789. */
  17790. shapeID: number;
  17791. /**
  17792. * flat array of model positions (internal use)
  17793. */
  17794. _shape: Vector3[];
  17795. /**
  17796. * flat array of model UVs (internal use)
  17797. */
  17798. _shapeUV: number[];
  17799. /**
  17800. * length of the shape in the model indices array (internal use)
  17801. */
  17802. _indicesLength: number;
  17803. /**
  17804. * Custom position function (internal use)
  17805. */
  17806. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  17807. /**
  17808. * Custom vertex function (internal use)
  17809. */
  17810. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  17811. /**
  17812. * 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.
  17813. * SPS internal tool, don't use it manually.
  17814. * @ignore
  17815. */
  17816. 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>);
  17817. }
  17818. /**
  17819. * Represents a Depth Sorted Particle in the solid particle system.
  17820. */
  17821. class DepthSortedParticle {
  17822. /**
  17823. * Index of the particle in the "indices" array
  17824. */
  17825. ind: number;
  17826. /**
  17827. * Length of the particle shape in the "indices" array
  17828. */
  17829. indicesLength: number;
  17830. /**
  17831. * Squared distance from the particle to the camera
  17832. */
  17833. sqDistance: number;
  17834. }
  17835. }
  17836. declare module BABYLON {
  17837. /**
  17838. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  17839. *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.
  17840. * The SPS is also a particle system. It provides some methods to manage the particles.
  17841. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  17842. *
  17843. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  17844. */
  17845. class SolidParticleSystem implements IDisposable {
  17846. /**
  17847. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  17848. * Example : var p = SPS.particles[i];
  17849. */
  17850. particles: SolidParticle[];
  17851. /**
  17852. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  17853. */
  17854. nbParticles: number;
  17855. /**
  17856. * If the particles must ever face the camera (default false). Useful for planar particles.
  17857. */
  17858. billboard: boolean;
  17859. /**
  17860. * Recompute normals when adding a shape
  17861. */
  17862. recomputeNormals: boolean;
  17863. /**
  17864. * This a counter ofr your own usage. It's not set by any SPS functions.
  17865. */
  17866. counter: number;
  17867. /**
  17868. * The SPS name. This name is also given to the underlying mesh.
  17869. */
  17870. name: string;
  17871. /**
  17872. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  17873. */
  17874. mesh: Mesh;
  17875. /**
  17876. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  17877. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  17878. */
  17879. vars: any;
  17880. /**
  17881. * This array is populated when the SPS is set as 'pickable'.
  17882. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  17883. * Each element of this array is an object `{idx: int, faceId: int}`.
  17884. * `idx` is the picked particle index in the `SPS.particles` array
  17885. * `faceId` is the picked face index counted within this particle.
  17886. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  17887. */
  17888. pickedParticles: {
  17889. idx: number;
  17890. faceId: number;
  17891. }[];
  17892. /**
  17893. * This array is populated when `enableDepthSort` is set to true.
  17894. * Each element of this array is an instance of the class DepthSortedParticle.
  17895. */
  17896. depthSortedParticles: DepthSortedParticle[];
  17897. /**
  17898. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  17899. */
  17900. _bSphereOnly: boolean;
  17901. /**
  17902. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  17903. */
  17904. _bSphereRadiusFactor: number;
  17905. private _scene;
  17906. private _positions;
  17907. private _indices;
  17908. private _normals;
  17909. private _colors;
  17910. private _uvs;
  17911. private _indices32;
  17912. private _positions32;
  17913. private _normals32;
  17914. private _fixedNormal32;
  17915. private _colors32;
  17916. private _uvs32;
  17917. private _index;
  17918. private _updatable;
  17919. private _pickable;
  17920. private _isVisibilityBoxLocked;
  17921. private _alwaysVisible;
  17922. private _depthSort;
  17923. private _shapeCounter;
  17924. private _copy;
  17925. private _shape;
  17926. private _shapeUV;
  17927. private _color;
  17928. private _computeParticleColor;
  17929. private _computeParticleTexture;
  17930. private _computeParticleRotation;
  17931. private _computeParticleVertex;
  17932. private _computeBoundingBox;
  17933. private _depthSortParticles;
  17934. private _cam_axisZ;
  17935. private _cam_axisY;
  17936. private _cam_axisX;
  17937. private _axisZ;
  17938. private _camera;
  17939. private _particle;
  17940. private _camDir;
  17941. private _camInvertedPosition;
  17942. private _rotMatrix;
  17943. private _invertMatrix;
  17944. private _rotated;
  17945. private _quaternion;
  17946. private _vertex;
  17947. private _normal;
  17948. private _yaw;
  17949. private _pitch;
  17950. private _roll;
  17951. private _halfroll;
  17952. private _halfpitch;
  17953. private _halfyaw;
  17954. private _sinRoll;
  17955. private _cosRoll;
  17956. private _sinPitch;
  17957. private _cosPitch;
  17958. private _sinYaw;
  17959. private _cosYaw;
  17960. private _mustUnrotateFixedNormals;
  17961. private _minimum;
  17962. private _maximum;
  17963. private _minBbox;
  17964. private _maxBbox;
  17965. private _particlesIntersect;
  17966. private _depthSortFunction;
  17967. private _needs32Bits;
  17968. private _pivotBackTranslation;
  17969. private _scaledPivot;
  17970. private _particleHasParent;
  17971. private _parent;
  17972. /**
  17973. * Creates a SPS (Solid Particle System) object.
  17974. * @param name (String) is the SPS name, this will be the underlying mesh name.
  17975. * @param scene (Scene) is the scene in which the SPS is added.
  17976. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  17977. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  17978. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  17979. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  17980. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  17981. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  17982. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  17983. */
  17984. constructor(name: string, scene: Scene, options?: {
  17985. updatable?: boolean;
  17986. isPickable?: boolean;
  17987. enableDepthSort?: boolean;
  17988. particleIntersection?: boolean;
  17989. boundingSphereOnly?: boolean;
  17990. bSphereRadiusFactor?: number;
  17991. });
  17992. /**
  17993. * Builds the SPS underlying mesh. Returns a standard Mesh.
  17994. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  17995. * @returns the created mesh
  17996. */
  17997. buildMesh(): Mesh;
  17998. /**
  17999. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  18000. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  18001. * Thus the particles generated from `digest()` have their property `position` set yet.
  18002. * @param mesh ( Mesh ) is the mesh to be digested
  18003. * @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
  18004. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  18005. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  18006. * @returns the current SPS
  18007. */
  18008. digest(mesh: Mesh, options?: {
  18009. facetNb?: number;
  18010. number?: number;
  18011. delta?: number;
  18012. }): SolidParticleSystem;
  18013. private _unrotateFixedNormals();
  18014. private _resetCopy();
  18015. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  18016. private _posToShape(positions);
  18017. private _uvsToShapeUV(uvs);
  18018. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  18019. /**
  18020. * Adds some particles to the SPS from the model shape. Returns the shape id.
  18021. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  18022. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  18023. * @param nb (positive integer) the number of particles to be created from this model
  18024. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  18025. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  18026. * @returns the number of shapes in the system
  18027. */
  18028. addShape(mesh: Mesh, nb: number, options?: {
  18029. positionFunction?: any;
  18030. vertexFunction?: any;
  18031. }): number;
  18032. private _rebuildParticle(particle);
  18033. /**
  18034. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  18035. * @returns the SPS.
  18036. */
  18037. rebuildMesh(): SolidParticleSystem;
  18038. /**
  18039. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  18040. * This method calls `updateParticle()` for each particle of the SPS.
  18041. * For an animated SPS, it is usually called within the render loop.
  18042. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  18043. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  18044. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  18045. * @returns the SPS.
  18046. */
  18047. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  18048. private _quaternionRotationYPR();
  18049. private _quaternionToRotationMatrix();
  18050. /**
  18051. * Disposes the SPS.
  18052. */
  18053. dispose(): void;
  18054. /**
  18055. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  18056. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18057. * @returns the SPS.
  18058. */
  18059. refreshVisibleSize(): SolidParticleSystem;
  18060. /**
  18061. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  18062. * @param size the size (float) of the visibility box
  18063. * note : this doesn't lock the SPS mesh bounding box.
  18064. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18065. */
  18066. setVisibilityBox(size: number): void;
  18067. /**
  18068. * Gets whether the SPS as always visible or not
  18069. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18070. */
  18071. /**
  18072. * Sets the SPS as always visible or not
  18073. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18074. */
  18075. isAlwaysVisible: boolean;
  18076. /**
  18077. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  18078. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18079. */
  18080. /**
  18081. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  18082. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18083. */
  18084. isVisibilityBoxLocked: boolean;
  18085. /**
  18086. * Gets if `setParticles()` computes the particle rotations or not.
  18087. * Default value : true. The SPS is faster when it's set to false.
  18088. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  18089. */
  18090. /**
  18091. * Tells to `setParticles()` to compute the particle rotations or not.
  18092. * Default value : true. The SPS is faster when it's set to false.
  18093. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  18094. */
  18095. computeParticleRotation: boolean;
  18096. /**
  18097. * Gets if `setParticles()` computes the particle colors or not.
  18098. * Default value : true. The SPS is faster when it's set to false.
  18099. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  18100. */
  18101. /**
  18102. * Tells to `setParticles()` to compute the particle colors or not.
  18103. * Default value : true. The SPS is faster when it's set to false.
  18104. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  18105. */
  18106. computeParticleColor: boolean;
  18107. /**
  18108. * Gets if `setParticles()` computes the particle textures or not.
  18109. * Default value : true. The SPS is faster when it's set to false.
  18110. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  18111. */
  18112. computeParticleTexture: boolean;
  18113. /**
  18114. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  18115. * Default value : false. The SPS is faster when it's set to false.
  18116. * Note : the particle custom vertex positions aren't stored values.
  18117. */
  18118. /**
  18119. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  18120. * Default value : false. The SPS is faster when it's set to false.
  18121. * Note : the particle custom vertex positions aren't stored values.
  18122. */
  18123. computeParticleVertex: boolean;
  18124. /**
  18125. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  18126. */
  18127. /**
  18128. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  18129. */
  18130. computeBoundingBox: boolean;
  18131. /**
  18132. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  18133. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  18134. * Default : `true`
  18135. */
  18136. /**
  18137. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  18138. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  18139. * Default : `true`
  18140. */
  18141. depthSortParticles: boolean;
  18142. /**
  18143. * This function does nothing. It may be overwritten to set all the particle first values.
  18144. * The SPS doesn't call this function, you may have to call it by your own.
  18145. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  18146. */
  18147. initParticles(): void;
  18148. /**
  18149. * This function does nothing. It may be overwritten to recycle a particle.
  18150. * The SPS doesn't call this function, you may have to call it by your own.
  18151. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  18152. * @param particle The particle to recycle
  18153. * @returns the recycled particle
  18154. */
  18155. recycleParticle(particle: SolidParticle): SolidParticle;
  18156. /**
  18157. * Updates a particle : this function should be overwritten by the user.
  18158. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  18159. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  18160. * @example : just set a particle position or velocity and recycle conditions
  18161. * @param particle The particle to update
  18162. * @returns the updated particle
  18163. */
  18164. updateParticle(particle: SolidParticle): SolidParticle;
  18165. /**
  18166. * Updates a vertex of a particle : it can be overwritten by the user.
  18167. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  18168. * @param particle the current particle
  18169. * @param vertex the current index of the current particle
  18170. * @param pt the index of the current vertex in the particle shape
  18171. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  18172. * @example : just set a vertex particle position
  18173. * @returns the updated vertex
  18174. */
  18175. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  18176. /**
  18177. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  18178. * This does nothing and may be overwritten by the user.
  18179. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  18180. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  18181. * @param update the boolean update value actually passed to setParticles()
  18182. */
  18183. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  18184. /**
  18185. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  18186. * This will be passed three parameters.
  18187. * This does nothing and may be overwritten by the user.
  18188. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  18189. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  18190. * @param update the boolean update value actually passed to setParticles()
  18191. */
  18192. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  18193. }
  18194. }
  18195. declare module BABYLON {
  18196. interface PhysicsImpostorJoint {
  18197. mainImpostor: PhysicsImpostor;
  18198. connectedImpostor: PhysicsImpostor;
  18199. joint: PhysicsJoint;
  18200. }
  18201. class PhysicsEngine {
  18202. private _physicsPlugin;
  18203. gravity: Vector3;
  18204. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  18205. setGravity(gravity: Vector3): void;
  18206. /**
  18207. * Set the time step of the physics engine.
  18208. * default is 1/60.
  18209. * To slow it down, enter 1/600 for example.
  18210. * To speed it up, 1/30
  18211. * @param {number} newTimeStep the new timestep to apply to this world.
  18212. */
  18213. setTimeStep(newTimeStep?: number): void;
  18214. /**
  18215. * Get the time step of the physics engine.
  18216. */
  18217. getTimeStep(): number;
  18218. dispose(): void;
  18219. getPhysicsPluginName(): string;
  18220. static Epsilon: number;
  18221. private _impostors;
  18222. private _joints;
  18223. /**
  18224. * Adding a new impostor for the impostor tracking.
  18225. * This will be done by the impostor itself.
  18226. * @param {PhysicsImpostor} impostor the impostor to add
  18227. */
  18228. addImpostor(impostor: PhysicsImpostor): void;
  18229. /**
  18230. * Remove an impostor from the engine.
  18231. * This impostor and its mesh will not longer be updated by the physics engine.
  18232. * @param {PhysicsImpostor} impostor the impostor to remove
  18233. */
  18234. removeImpostor(impostor: PhysicsImpostor): void;
  18235. /**
  18236. * Add a joint to the physics engine
  18237. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  18238. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  18239. * @param {PhysicsJoint} the joint that will connect both impostors.
  18240. */
  18241. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18242. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18243. /**
  18244. * Called by the scene. no need to call it.
  18245. */
  18246. _step(delta: number): void;
  18247. getPhysicsPlugin(): IPhysicsEnginePlugin;
  18248. getImpostors(): Array<PhysicsImpostor>;
  18249. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18250. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  18251. }
  18252. interface IPhysicsEnginePlugin {
  18253. world: any;
  18254. name: string;
  18255. setGravity(gravity: Vector3): void;
  18256. setTimeStep(timeStep: number): void;
  18257. getTimeStep(): number;
  18258. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  18259. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18260. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18261. generatePhysicsBody(impostor: PhysicsImpostor): void;
  18262. removePhysicsBody(impostor: PhysicsImpostor): void;
  18263. generateJoint(joint: PhysicsImpostorJoint): void;
  18264. removeJoint(joint: PhysicsImpostorJoint): void;
  18265. isSupported(): boolean;
  18266. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  18267. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  18268. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18269. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18270. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18271. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18272. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  18273. getBodyMass(impostor: PhysicsImpostor): number;
  18274. getBodyFriction(impostor: PhysicsImpostor): number;
  18275. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  18276. getBodyRestitution(impostor: PhysicsImpostor): number;
  18277. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  18278. sleepBody(impostor: PhysicsImpostor): void;
  18279. wakeUpBody(impostor: PhysicsImpostor): void;
  18280. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  18281. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  18282. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18283. getRadius(impostor: PhysicsImpostor): number;
  18284. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  18285. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  18286. dispose(): void;
  18287. }
  18288. }
  18289. declare module BABYLON {
  18290. class PhysicsHelper {
  18291. private _scene;
  18292. private _physicsEngine;
  18293. constructor(scene: Scene);
  18294. /**
  18295. * @param {Vector3} origin the origin of the explosion
  18296. * @param {number} radius the explosion radius
  18297. * @param {number} strength the explosion strength
  18298. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  18299. */
  18300. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  18301. /**
  18302. * @param {Vector3} origin the origin of the explosion
  18303. * @param {number} radius the explosion radius
  18304. * @param {number} strength the explosion strength
  18305. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  18306. */
  18307. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  18308. /**
  18309. * @param {Vector3} origin the origin of the explosion
  18310. * @param {number} radius the explosion radius
  18311. * @param {number} strength the explosion strength
  18312. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  18313. */
  18314. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  18315. /**
  18316. * @param {Vector3} origin the origin of the updraft
  18317. * @param {number} radius the radius of the updraft
  18318. * @param {number} strength the strength of the updraft
  18319. * @param {number} height the height of the updraft
  18320. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  18321. */
  18322. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  18323. /**
  18324. * @param {Vector3} origin the of the vortex
  18325. * @param {number} radius the radius of the vortex
  18326. * @param {number} strength the strength of the vortex
  18327. * @param {number} height the height of the vortex
  18328. */
  18329. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  18330. }
  18331. /***** Radial explosion *****/
  18332. class PhysicsRadialExplosionEvent {
  18333. private _scene;
  18334. private _sphere;
  18335. private _sphereOptions;
  18336. private _rays;
  18337. private _dataFetched;
  18338. constructor(scene: Scene);
  18339. /**
  18340. * Returns the data related to the radial explosion event (sphere & rays).
  18341. * @returns {PhysicsRadialExplosionEventData}
  18342. */
  18343. getData(): PhysicsRadialExplosionEventData;
  18344. /**
  18345. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  18346. * @param impostor
  18347. * @param {Vector3} origin the origin of the explosion
  18348. * @param {number} radius the explosion radius
  18349. * @param {number} strength the explosion strength
  18350. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  18351. * @returns {Nullable<PhysicsForceAndContactPoint>}
  18352. */
  18353. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  18354. /**
  18355. * Disposes the sphere.
  18356. * @param {bolean} force
  18357. */
  18358. dispose(force?: boolean): void;
  18359. /*** Helpers ***/
  18360. private _prepareSphere();
  18361. private _intersectsWithSphere(impostor, origin, radius);
  18362. }
  18363. /***** Gravitational Field *****/
  18364. class PhysicsGravitationalFieldEvent {
  18365. private _physicsHelper;
  18366. private _scene;
  18367. private _origin;
  18368. private _radius;
  18369. private _strength;
  18370. private _falloff;
  18371. private _tickCallback;
  18372. private _sphere;
  18373. private _dataFetched;
  18374. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  18375. /**
  18376. * Returns the data related to the gravitational field event (sphere).
  18377. * @returns {PhysicsGravitationalFieldEventData}
  18378. */
  18379. getData(): PhysicsGravitationalFieldEventData;
  18380. /**
  18381. * Enables the gravitational field.
  18382. */
  18383. enable(): void;
  18384. /**
  18385. * Disables the gravitational field.
  18386. */
  18387. disable(): void;
  18388. /**
  18389. * Disposes the sphere.
  18390. * @param {bolean} force
  18391. */
  18392. dispose(force?: boolean): void;
  18393. private _tick();
  18394. }
  18395. /***** Updraft *****/
  18396. class PhysicsUpdraftEvent {
  18397. private _scene;
  18398. private _origin;
  18399. private _radius;
  18400. private _strength;
  18401. private _height;
  18402. private _updraftMode;
  18403. private _physicsEngine;
  18404. private _originTop;
  18405. private _originDirection;
  18406. private _tickCallback;
  18407. private _cylinder;
  18408. private _cylinderPosition;
  18409. private _dataFetched;
  18410. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  18411. /**
  18412. * Returns the data related to the updraft event (cylinder).
  18413. * @returns {PhysicsUpdraftEventData}
  18414. */
  18415. getData(): PhysicsUpdraftEventData;
  18416. /**
  18417. * Enables the updraft.
  18418. */
  18419. enable(): void;
  18420. /**
  18421. * Disables the cortex.
  18422. */
  18423. disable(): void;
  18424. /**
  18425. * Disposes the sphere.
  18426. * @param {bolean} force
  18427. */
  18428. dispose(force?: boolean): void;
  18429. private getImpostorForceAndContactPoint(impostor);
  18430. private _tick();
  18431. /*** Helpers ***/
  18432. private _prepareCylinder();
  18433. private _intersectsWithCylinder(impostor);
  18434. }
  18435. /***** Vortex *****/
  18436. class PhysicsVortexEvent {
  18437. private _scene;
  18438. private _origin;
  18439. private _radius;
  18440. private _strength;
  18441. private _height;
  18442. private _physicsEngine;
  18443. private _originTop;
  18444. private _centripetalForceThreshold;
  18445. private _updraftMultiplier;
  18446. private _tickCallback;
  18447. private _cylinder;
  18448. private _cylinderPosition;
  18449. private _dataFetched;
  18450. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  18451. /**
  18452. * Returns the data related to the vortex event (cylinder).
  18453. * @returns {PhysicsVortexEventData}
  18454. */
  18455. getData(): PhysicsVortexEventData;
  18456. /**
  18457. * Enables the vortex.
  18458. */
  18459. enable(): void;
  18460. /**
  18461. * Disables the cortex.
  18462. */
  18463. disable(): void;
  18464. /**
  18465. * Disposes the sphere.
  18466. * @param {bolean} force
  18467. */
  18468. dispose(force?: boolean): void;
  18469. private getImpostorForceAndContactPoint(impostor);
  18470. private _tick();
  18471. /*** Helpers ***/
  18472. private _prepareCylinder();
  18473. private _intersectsWithCylinder(impostor);
  18474. }
  18475. /***** Enums *****/
  18476. /**
  18477. * The strenght of the force in correspondence to the distance of the affected object
  18478. */
  18479. enum PhysicsRadialImpulseFalloff {
  18480. Constant = 0,
  18481. Linear = 1,
  18482. }
  18483. /**
  18484. * The strenght of the force in correspondence to the distance of the affected object
  18485. */
  18486. enum PhysicsUpdraftMode {
  18487. Center = 0,
  18488. Perpendicular = 1,
  18489. }
  18490. /***** Data interfaces *****/
  18491. interface PhysicsForceAndContactPoint {
  18492. force: Vector3;
  18493. contactPoint: Vector3;
  18494. }
  18495. interface PhysicsRadialExplosionEventData {
  18496. sphere: Mesh;
  18497. rays: Array<Ray>;
  18498. }
  18499. interface PhysicsGravitationalFieldEventData {
  18500. sphere: Mesh;
  18501. }
  18502. interface PhysicsUpdraftEventData {
  18503. cylinder: Mesh;
  18504. }
  18505. interface PhysicsVortexEventData {
  18506. cylinder: Mesh;
  18507. }
  18508. }
  18509. declare module BABYLON {
  18510. interface PhysicsImpostorParameters {
  18511. mass: number;
  18512. friction?: number;
  18513. restitution?: number;
  18514. nativeOptions?: any;
  18515. ignoreParent?: boolean;
  18516. disableBidirectionalTransformation?: boolean;
  18517. }
  18518. interface IPhysicsEnabledObject {
  18519. position: Vector3;
  18520. rotationQuaternion: Nullable<Quaternion>;
  18521. scaling: Vector3;
  18522. rotation?: Vector3;
  18523. parent?: any;
  18524. getBoundingInfo(): BoundingInfo;
  18525. computeWorldMatrix(force: boolean): Matrix;
  18526. getWorldMatrix?(): Matrix;
  18527. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  18528. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  18529. getIndices?(): Nullable<IndicesArray>;
  18530. getScene?(): Scene;
  18531. getAbsolutePosition(): Vector3;
  18532. getAbsolutePivotPoint(): Vector3;
  18533. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  18534. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  18535. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  18536. getClassName(): string;
  18537. }
  18538. class PhysicsImpostor {
  18539. object: IPhysicsEnabledObject;
  18540. type: number;
  18541. private _options;
  18542. private _scene;
  18543. static DEFAULT_OBJECT_SIZE: Vector3;
  18544. static IDENTITY_QUATERNION: Quaternion;
  18545. private _physicsEngine;
  18546. private _physicsBody;
  18547. private _bodyUpdateRequired;
  18548. private _onBeforePhysicsStepCallbacks;
  18549. private _onAfterPhysicsStepCallbacks;
  18550. private _onPhysicsCollideCallbacks;
  18551. private _deltaPosition;
  18552. private _deltaRotation;
  18553. private _deltaRotationConjugated;
  18554. private _parent;
  18555. private _isDisposed;
  18556. private static _tmpVecs;
  18557. private static _tmpQuat;
  18558. readonly isDisposed: boolean;
  18559. mass: number;
  18560. friction: number;
  18561. restitution: number;
  18562. uniqueId: number;
  18563. private _joints;
  18564. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  18565. /**
  18566. * This function will completly initialize this impostor.
  18567. * It will create a new body - but only if this mesh has no parent.
  18568. * If it has, this impostor will not be used other than to define the impostor
  18569. * of the child mesh.
  18570. */
  18571. _init(): void;
  18572. private _getPhysicsParent();
  18573. /**
  18574. * Should a new body be generated.
  18575. */
  18576. isBodyInitRequired(): boolean;
  18577. setScalingUpdated(updated: boolean): void;
  18578. /**
  18579. * Force a regeneration of this or the parent's impostor's body.
  18580. * Use under cautious - This will remove all joints already implemented.
  18581. */
  18582. forceUpdate(): void;
  18583. /**
  18584. * Gets the body that holds this impostor. Either its own, or its parent.
  18585. */
  18586. /**
  18587. * Set the physics body. Used mainly by the physics engine/plugin
  18588. */
  18589. physicsBody: any;
  18590. parent: Nullable<PhysicsImpostor>;
  18591. resetUpdateFlags(): void;
  18592. getObjectExtendSize(): Vector3;
  18593. getObjectCenter(): Vector3;
  18594. /**
  18595. * Get a specific parametes from the options parameter.
  18596. */
  18597. getParam(paramName: string): any;
  18598. /**
  18599. * Sets a specific parameter in the options given to the physics plugin
  18600. */
  18601. setParam(paramName: string, value: number): void;
  18602. /**
  18603. * Specifically change the body's mass option. Won't recreate the physics body object
  18604. */
  18605. setMass(mass: number): void;
  18606. getLinearVelocity(): Nullable<Vector3>;
  18607. setLinearVelocity(velocity: Nullable<Vector3>): void;
  18608. getAngularVelocity(): Nullable<Vector3>;
  18609. setAngularVelocity(velocity: Nullable<Vector3>): void;
  18610. /**
  18611. * Execute a function with the physics plugin native code.
  18612. * Provide a function the will have two variables - the world object and the physics body object.
  18613. */
  18614. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  18615. /**
  18616. * Register a function that will be executed before the physics world is stepping forward.
  18617. */
  18618. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18619. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18620. /**
  18621. * Register a function that will be executed after the physics step
  18622. */
  18623. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18624. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18625. /**
  18626. * register a function that will be executed when this impostor collides against a different body.
  18627. */
  18628. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  18629. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  18630. private _tmpQuat;
  18631. private _tmpQuat2;
  18632. getParentsRotation(): Quaternion;
  18633. /**
  18634. * this function is executed by the physics engine.
  18635. */
  18636. beforeStep: () => void;
  18637. /**
  18638. * this function is executed by the physics engine.
  18639. */
  18640. afterStep: () => void;
  18641. /**
  18642. * Legacy collision detection event support
  18643. */
  18644. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  18645. onCollide: (e: {
  18646. body: any;
  18647. }) => void;
  18648. /**
  18649. * Apply a force
  18650. */
  18651. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  18652. /**
  18653. * Apply an impulse
  18654. */
  18655. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  18656. /**
  18657. * A help function to create a joint.
  18658. */
  18659. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  18660. /**
  18661. * Add a joint to this impostor with a different impostor.
  18662. */
  18663. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  18664. /**
  18665. * Will keep this body still, in a sleep mode.
  18666. */
  18667. sleep(): PhysicsImpostor;
  18668. /**
  18669. * Wake the body up.
  18670. */
  18671. wakeUp(): PhysicsImpostor;
  18672. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18673. dispose(): void;
  18674. setDeltaPosition(position: Vector3): void;
  18675. setDeltaRotation(rotation: Quaternion): void;
  18676. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  18677. getRadius(): number;
  18678. /**
  18679. * Sync a bone with this impostor
  18680. * @param bone The bone to sync to the impostor.
  18681. * @param boneMesh The mesh that the bone is influencing.
  18682. * @param jointPivot The pivot of the joint / bone in local space.
  18683. * @param distToJoint Optional distance from the impostor to the joint.
  18684. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  18685. */
  18686. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  18687. /**
  18688. * Sync impostor to a bone
  18689. * @param bone The bone that the impostor will be synced to.
  18690. * @param boneMesh The mesh that the bone is influencing.
  18691. * @param jointPivot The pivot of the joint / bone in local space.
  18692. * @param distToJoint Optional distance from the impostor to the joint.
  18693. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  18694. * @param boneAxis Optional vector3 axis the bone is aligned with
  18695. */
  18696. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  18697. static NoImpostor: number;
  18698. static SphereImpostor: number;
  18699. static BoxImpostor: number;
  18700. static PlaneImpostor: number;
  18701. static MeshImpostor: number;
  18702. static CylinderImpostor: number;
  18703. static ParticleImpostor: number;
  18704. static HeightmapImpostor: number;
  18705. }
  18706. }
  18707. declare module BABYLON {
  18708. interface PhysicsJointData {
  18709. mainPivot?: Vector3;
  18710. connectedPivot?: Vector3;
  18711. mainAxis?: Vector3;
  18712. connectedAxis?: Vector3;
  18713. collision?: boolean;
  18714. nativeParams?: any;
  18715. }
  18716. /**
  18717. * This is a holder class for the physics joint created by the physics plugin.
  18718. * It holds a set of functions to control the underlying joint.
  18719. */
  18720. class PhysicsJoint {
  18721. type: number;
  18722. jointData: PhysicsJointData;
  18723. private _physicsJoint;
  18724. protected _physicsPlugin: IPhysicsEnginePlugin;
  18725. constructor(type: number, jointData: PhysicsJointData);
  18726. physicsJoint: any;
  18727. physicsPlugin: IPhysicsEnginePlugin;
  18728. /**
  18729. * Execute a function that is physics-plugin specific.
  18730. * @param {Function} func the function that will be executed.
  18731. * It accepts two parameters: the physics world and the physics joint.
  18732. */
  18733. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  18734. static DistanceJoint: number;
  18735. static HingeJoint: number;
  18736. static BallAndSocketJoint: number;
  18737. static WheelJoint: number;
  18738. static SliderJoint: number;
  18739. static PrismaticJoint: number;
  18740. static UniversalJoint: number;
  18741. static Hinge2Joint: number;
  18742. static PointToPointJoint: number;
  18743. static SpringJoint: number;
  18744. static LockJoint: number;
  18745. }
  18746. /**
  18747. * A class representing a physics distance joint.
  18748. */
  18749. class DistanceJoint extends PhysicsJoint {
  18750. constructor(jointData: DistanceJointData);
  18751. /**
  18752. * Update the predefined distance.
  18753. */
  18754. updateDistance(maxDistance: number, minDistance?: number): void;
  18755. }
  18756. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  18757. constructor(type: number, jointData: PhysicsJointData);
  18758. /**
  18759. * Set the motor values.
  18760. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18761. * @param {number} force the force to apply
  18762. * @param {number} maxForce max force for this motor.
  18763. */
  18764. setMotor(force?: number, maxForce?: number): void;
  18765. /**
  18766. * Set the motor's limits.
  18767. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18768. */
  18769. setLimit(upperLimit: number, lowerLimit?: number): void;
  18770. }
  18771. /**
  18772. * This class represents a single hinge physics joint
  18773. */
  18774. class HingeJoint extends MotorEnabledJoint {
  18775. constructor(jointData: PhysicsJointData);
  18776. /**
  18777. * Set the motor values.
  18778. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18779. * @param {number} force the force to apply
  18780. * @param {number} maxForce max force for this motor.
  18781. */
  18782. setMotor(force?: number, maxForce?: number): void;
  18783. /**
  18784. * Set the motor's limits.
  18785. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18786. */
  18787. setLimit(upperLimit: number, lowerLimit?: number): void;
  18788. }
  18789. /**
  18790. * This class represents a dual hinge physics joint (same as wheel joint)
  18791. */
  18792. class Hinge2Joint extends MotorEnabledJoint {
  18793. constructor(jointData: PhysicsJointData);
  18794. /**
  18795. * Set the motor values.
  18796. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18797. * @param {number} force the force to apply
  18798. * @param {number} maxForce max force for this motor.
  18799. * @param {motorIndex} the motor's index, 0 or 1.
  18800. */
  18801. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18802. /**
  18803. * Set the motor limits.
  18804. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18805. * @param {number} upperLimit the upper limit
  18806. * @param {number} lowerLimit lower limit
  18807. * @param {motorIndex} the motor's index, 0 or 1.
  18808. */
  18809. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18810. }
  18811. interface IMotorEnabledJoint {
  18812. physicsJoint: any;
  18813. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18814. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18815. }
  18816. interface DistanceJointData extends PhysicsJointData {
  18817. maxDistance: number;
  18818. }
  18819. interface SpringJointData extends PhysicsJointData {
  18820. length: number;
  18821. stiffness: number;
  18822. damping: number;
  18823. }
  18824. }
  18825. declare module BABYLON {
  18826. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  18827. static OCCLUSION_TYPE_NONE: number;
  18828. static OCCLUSION_TYPE_OPTIMISTIC: number;
  18829. static OCCLUSION_TYPE_STRICT: number;
  18830. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  18831. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  18832. static readonly BILLBOARDMODE_NONE: number;
  18833. static readonly BILLBOARDMODE_X: number;
  18834. static readonly BILLBOARDMODE_Y: number;
  18835. static readonly BILLBOARDMODE_Z: number;
  18836. static readonly BILLBOARDMODE_ALL: number;
  18837. private _facetPositions;
  18838. private _facetNormals;
  18839. private _facetPartitioning;
  18840. private _facetNb;
  18841. private _partitioningSubdivisions;
  18842. private _partitioningBBoxRatio;
  18843. private _facetDataEnabled;
  18844. private _facetParameters;
  18845. private _bbSize;
  18846. private _subDiv;
  18847. private _facetDepthSort;
  18848. private _facetDepthSortEnabled;
  18849. private _depthSortedIndices;
  18850. private _depthSortedFacets;
  18851. private _facetDepthSortFunction;
  18852. private _facetDepthSortFrom;
  18853. private _facetDepthSortOrigin;
  18854. private _invertedMatrix;
  18855. /**
  18856. * Read-only : the number of facets in the mesh
  18857. */
  18858. readonly facetNb: number;
  18859. /**
  18860. * The number (integer) of subdivisions per axis in the partioning space
  18861. */
  18862. partitioningSubdivisions: number;
  18863. /**
  18864. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  18865. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box.
  18866. */
  18867. partitioningBBoxRatio: number;
  18868. /**
  18869. * Boolean : must the facet be depth sorted on next call to `updateFacetData()` ?
  18870. * Works only for updatable meshes.
  18871. * Doesn't work with multi-materials.
  18872. */
  18873. mustDepthSortFacets: boolean;
  18874. /**
  18875. * The location (Vector3) where the facet depth sort must be computed from.
  18876. * By default, the active camera position.
  18877. * Used only when facet depth sort is enabled.
  18878. */
  18879. facetDepthSortFrom: Vector3;
  18880. /**
  18881. * Read-only boolean : is the feature facetData enabled ?
  18882. */
  18883. readonly isFacetDataEnabled: boolean;
  18884. _updateNonUniformScalingState(value: boolean): boolean;
  18885. /**
  18886. * An event triggered when this mesh collides with another one
  18887. */
  18888. onCollideObservable: Observable<AbstractMesh>;
  18889. private _onCollideObserver;
  18890. onCollide: () => void;
  18891. /**
  18892. * An event triggered when the collision's position changes
  18893. */
  18894. onCollisionPositionChangeObservable: Observable<Vector3>;
  18895. private _onCollisionPositionChangeObserver;
  18896. onCollisionPositionChange: () => void;
  18897. /**
  18898. * An event triggered when material is changed
  18899. */
  18900. onMaterialChangedObservable: Observable<AbstractMesh>;
  18901. definedFacingForward: boolean;
  18902. /**
  18903. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  18904. * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  18905. * or
  18906. * 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.
  18907. * for more info check WebGl documentations
  18908. */
  18909. occlusionQueryAlgorithmType: number;
  18910. /**
  18911. * 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:
  18912. * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  18913. * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  18914. * 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.
  18915. */
  18916. occlusionType: number;
  18917. /**
  18918. * 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.
  18919. * The default value is -1 which means don't break the query and wait till the result.
  18920. */
  18921. occlusionRetryCount: number;
  18922. private _occlusionInternalRetryCounter;
  18923. protected _isOccluded: boolean;
  18924. /**
  18925. * Property isOccluded : 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.
  18926. */
  18927. isOccluded: boolean;
  18928. private _isOcclusionQueryInProgress;
  18929. /**
  18930. * Flag to check the progress status of the query
  18931. */
  18932. readonly isOcclusionQueryInProgress: boolean;
  18933. private _occlusionQuery;
  18934. private _visibility;
  18935. /**
  18936. * Gets or sets mesh visibility between 0 and 1 (defult is 1)
  18937. */
  18938. /**
  18939. * Gets or sets mesh visibility between 0 and 1 (defult is 1)
  18940. */
  18941. visibility: number;
  18942. alphaIndex: number;
  18943. isVisible: boolean;
  18944. isPickable: boolean;
  18945. showBoundingBox: boolean;
  18946. showSubMeshesBoundingBox: boolean;
  18947. isBlocker: boolean;
  18948. enablePointerMoveEvents: boolean;
  18949. renderingGroupId: number;
  18950. private _material;
  18951. material: Nullable<Material>;
  18952. private _receiveShadows;
  18953. receiveShadows: boolean;
  18954. renderOutline: boolean;
  18955. outlineColor: Color3;
  18956. outlineWidth: number;
  18957. renderOverlay: boolean;
  18958. overlayColor: Color3;
  18959. overlayAlpha: number;
  18960. private _hasVertexAlpha;
  18961. hasVertexAlpha: boolean;
  18962. private _useVertexColors;
  18963. useVertexColors: boolean;
  18964. private _computeBonesUsingShaders;
  18965. computeBonesUsingShaders: boolean;
  18966. private _numBoneInfluencers;
  18967. numBoneInfluencers: number;
  18968. private _applyFog;
  18969. applyFog: boolean;
  18970. useOctreeForRenderingSelection: boolean;
  18971. useOctreeForPicking: boolean;
  18972. useOctreeForCollisions: boolean;
  18973. private _layerMask;
  18974. layerMask: number;
  18975. /**
  18976. * True if the mesh must be rendered in any case.
  18977. */
  18978. alwaysSelectAsActiveMesh: boolean;
  18979. /**
  18980. * This scene's action manager
  18981. */
  18982. actionManager: Nullable<ActionManager>;
  18983. physicsImpostor: Nullable<PhysicsImpostor>;
  18984. private _checkCollisions;
  18985. private _collisionMask;
  18986. private _collisionGroup;
  18987. ellipsoid: Vector3;
  18988. ellipsoidOffset: Vector3;
  18989. private _collider;
  18990. private _oldPositionForCollisions;
  18991. private _diffPositionForCollisions;
  18992. collisionMask: number;
  18993. collisionGroup: number;
  18994. edgesWidth: number;
  18995. edgesColor: Color4;
  18996. _edgesRenderer: Nullable<EdgesRenderer>;
  18997. private _collisionsTransformMatrix;
  18998. private _collisionsScalingMatrix;
  18999. _masterMesh: Nullable<AbstractMesh>;
  19000. _boundingInfo: Nullable<BoundingInfo>;
  19001. _renderId: number;
  19002. subMeshes: SubMesh[];
  19003. _submeshesOctree: Octree<SubMesh>;
  19004. _intersectionsInProgress: AbstractMesh[];
  19005. _unIndexed: boolean;
  19006. _lightSources: Light[];
  19007. readonly _positions: Nullable<Vector3[]>;
  19008. _waitingActions: any;
  19009. _waitingFreezeWorldMatrix: Nullable<boolean>;
  19010. private _skeleton;
  19011. _bonesTransformMatrices: Nullable<Float32Array>;
  19012. skeleton: Nullable<Skeleton>;
  19013. constructor(name: string, scene?: Nullable<Scene>);
  19014. /**
  19015. * Returns the string "AbstractMesh"
  19016. */
  19017. getClassName(): string;
  19018. /**
  19019. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  19020. */
  19021. toString(fullDetails?: boolean): string;
  19022. _rebuild(): void;
  19023. _resyncLightSources(): void;
  19024. _resyncLighSource(light: Light): void;
  19025. /** @ignore */
  19026. _unBindEffect(): void;
  19027. _removeLightSource(light: Light): void;
  19028. private _markSubMeshesAsDirty(func);
  19029. _markSubMeshesAsLightDirty(): void;
  19030. _markSubMeshesAsAttributesDirty(): void;
  19031. _markSubMeshesAsMiscDirty(): void;
  19032. /**
  19033. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  19034. * Default : (1.0, 1.0, 1.0)
  19035. */
  19036. /**
  19037. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  19038. * Default : (1.0, 1.0, 1.0)
  19039. */
  19040. scaling: Vector3;
  19041. /**
  19042. * Disables the mesh edger rendering mode.
  19043. * Returns the AbstractMesh.
  19044. */
  19045. disableEdgesRendering(): AbstractMesh;
  19046. /**
  19047. * Enables the edge rendering mode on the mesh.
  19048. * This mode makes the mesh edges visible.
  19049. * Returns the AbstractMesh.
  19050. */
  19051. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19052. /**
  19053. * Returns true if the mesh is blocked. Used by the class Mesh.
  19054. * Returns the boolean `false` by default.
  19055. */
  19056. readonly isBlocked: boolean;
  19057. /**
  19058. * Returns the mesh itself by default, used by the class Mesh.
  19059. * Returned type : AbstractMesh
  19060. */
  19061. getLOD(camera: Camera): AbstractMesh;
  19062. /**
  19063. * Returns 0 by default, used by the class Mesh.
  19064. * Returns an integer.
  19065. */
  19066. getTotalVertices(): number;
  19067. /**
  19068. * Returns null by default, used by the class Mesh.
  19069. * Returned type : integer array
  19070. */
  19071. getIndices(): Nullable<IndicesArray>;
  19072. /**
  19073. * Returns the array of the requested vertex data kind. Used by the class Mesh. Returns null here.
  19074. * Returned type : float array or Float32Array
  19075. */
  19076. getVerticesData(kind: string): Nullable<FloatArray>;
  19077. /**
  19078. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19079. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19080. * The `data` are either a numeric array either a Float32Array.
  19081. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19082. * 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).
  19083. * Note that a new underlying VertexBuffer object is created each call.
  19084. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19085. *
  19086. * Possible `kind` values :
  19087. * - BABYLON.VertexBuffer.PositionKind
  19088. * - BABYLON.VertexBuffer.UVKind
  19089. * - BABYLON.VertexBuffer.UV2Kind
  19090. * - BABYLON.VertexBuffer.UV3Kind
  19091. * - BABYLON.VertexBuffer.UV4Kind
  19092. * - BABYLON.VertexBuffer.UV5Kind
  19093. * - BABYLON.VertexBuffer.UV6Kind
  19094. * - BABYLON.VertexBuffer.ColorKind
  19095. * - BABYLON.VertexBuffer.MatricesIndicesKind
  19096. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19097. * - BABYLON.VertexBuffer.MatricesWeightsKind
  19098. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19099. *
  19100. * Returns the Mesh.
  19101. */
  19102. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19103. /**
  19104. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19105. * If the mesh has no geometry, it is simply returned as it is.
  19106. * The `data` are either a numeric array either a Float32Array.
  19107. * No new underlying VertexBuffer object is created.
  19108. * 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.
  19109. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19110. *
  19111. * Possible `kind` values :
  19112. * - BABYLON.VertexBuffer.PositionKind
  19113. * - BABYLON.VertexBuffer.UVKind
  19114. * - BABYLON.VertexBuffer.UV2Kind
  19115. * - BABYLON.VertexBuffer.UV3Kind
  19116. * - BABYLON.VertexBuffer.UV4Kind
  19117. * - BABYLON.VertexBuffer.UV5Kind
  19118. * - BABYLON.VertexBuffer.UV6Kind
  19119. * - BABYLON.VertexBuffer.ColorKind
  19120. * - BABYLON.VertexBuffer.MatricesIndicesKind
  19121. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19122. * - BABYLON.VertexBuffer.MatricesWeightsKind
  19123. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19124. *
  19125. * Returns the Mesh.
  19126. */
  19127. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  19128. /**
  19129. * Sets the mesh indices.
  19130. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19131. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19132. * This method creates a new index buffer each call.
  19133. * Returns the Mesh.
  19134. */
  19135. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  19136. /** Returns false by default, used by the class Mesh.
  19137. * Returns a boolean
  19138. */
  19139. isVerticesDataPresent(kind: string): boolean;
  19140. /**
  19141. * Returns the mesh BoundingInfo object or creates a new one and returns it if undefined.
  19142. * Returns a BoundingInfo
  19143. */
  19144. getBoundingInfo(): BoundingInfo;
  19145. /**
  19146. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units).
  19147. * @param includeDescendants Take the hierarchy's bounding box instead of the mesh's bounding box.
  19148. */
  19149. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  19150. /**
  19151. * Sets a mesh new object BoundingInfo.
  19152. * Returns the AbstractMesh.
  19153. */
  19154. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  19155. readonly useBones: boolean;
  19156. _preActivate(): void;
  19157. _preActivateForIntermediateRendering(renderId: number): void;
  19158. _activate(renderId: number): void;
  19159. /**
  19160. * Returns the latest update of the World matrix
  19161. * Returns a Matrix.
  19162. */
  19163. getWorldMatrix(): Matrix;
  19164. /**
  19165. * Returns the latest update of the World matrix determinant.
  19166. */
  19167. protected _getWorldMatrixDeterminant(): number;
  19168. /**
  19169. * Perform relative position change from the point of view of behind the front of the mesh.
  19170. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19171. * Supports definition of mesh facing forward or backward.
  19172. * @param {number} amountRight
  19173. * @param {number} amountUp
  19174. * @param {number} amountForward
  19175. *
  19176. * Returns the AbstractMesh.
  19177. */
  19178. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  19179. /**
  19180. * Calculate relative position change from the point of view of behind the front of the mesh.
  19181. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19182. * Supports definition of mesh facing forward or backward.
  19183. * @param {number} amountRight
  19184. * @param {number} amountUp
  19185. * @param {number} amountForward
  19186. *
  19187. * Returns a new Vector3.
  19188. */
  19189. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  19190. /**
  19191. * Perform relative rotation change from the point of view of behind the front of the mesh.
  19192. * Supports definition of mesh facing forward or backward.
  19193. * @param {number} flipBack
  19194. * @param {number} twirlClockwise
  19195. * @param {number} tiltRight
  19196. *
  19197. * Returns the AbstractMesh.
  19198. */
  19199. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  19200. /**
  19201. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  19202. * Supports definition of mesh facing forward or backward.
  19203. * @param {number} flipBack
  19204. * @param {number} twirlClockwise
  19205. * @param {number} tiltRight
  19206. *
  19207. * Returns a new Vector3.
  19208. */
  19209. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  19210. /**
  19211. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  19212. * @param includeDescendants Include bounding info from descendants as well (true by default).
  19213. */
  19214. getHierarchyBoundingVectors(includeDescendants?: boolean): {
  19215. min: Vector3;
  19216. max: Vector3;
  19217. };
  19218. /**
  19219. * Updates the mesh BoundingInfo object and all its children BoundingInfo objects also.
  19220. * Returns the AbstractMesh.
  19221. */
  19222. _updateBoundingInfo(): AbstractMesh;
  19223. /**
  19224. * Update a mesh's children BoundingInfo objects only.
  19225. * Returns the AbstractMesh.
  19226. */
  19227. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  19228. protected _afterComputeWorldMatrix(): void;
  19229. /**
  19230. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19231. * A mesh is in the frustum if its bounding box intersects the frustum.
  19232. * Boolean returned.
  19233. */
  19234. isInFrustum(frustumPlanes: Plane[]): boolean;
  19235. /**
  19236. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  19237. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  19238. * Boolean returned.
  19239. */
  19240. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  19241. /**
  19242. * True if the mesh intersects another mesh or a SolidParticle object.
  19243. * 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)
  19244. * includeDescendants can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  19245. * Returns a boolean.
  19246. */
  19247. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  19248. /**
  19249. * Returns true if the passed point (Vector3) is inside the mesh bounding box.
  19250. * Returns a boolean.
  19251. */
  19252. intersectsPoint(point: Vector3): boolean;
  19253. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  19254. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  19255. /**
  19256. * Returns the distance from the mesh to the active camera.
  19257. * Returns a float.
  19258. */
  19259. getDistanceToCamera(camera?: Nullable<Camera>): number;
  19260. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  19261. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  19262. /**
  19263. * Property checkCollisions : Boolean, whether the camera should check the collisions against the mesh.
  19264. * Default `false`.
  19265. */
  19266. checkCollisions: boolean;
  19267. /**
  19268. * Gets Collider object used to compute collisions (not physics)
  19269. */
  19270. readonly collider: Collider;
  19271. moveWithCollisions(displacement: Vector3): AbstractMesh;
  19272. private _onCollisionPositionChange;
  19273. /**
  19274. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  19275. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree.
  19276. * Returns an Octree of submeshes.
  19277. */
  19278. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  19279. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  19280. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  19281. _checkCollision(collider: Collider): AbstractMesh;
  19282. _generatePointsArray(): boolean;
  19283. /**
  19284. * Checks if the passed Ray intersects with the mesh.
  19285. * Returns an object PickingInfo.
  19286. */
  19287. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  19288. /**
  19289. * Clones the mesh, used by the class Mesh.
  19290. * Just returns `null` for an AbstractMesh.
  19291. */
  19292. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19293. /**
  19294. * Disposes all the mesh submeshes.
  19295. * Returns the AbstractMesh.
  19296. */
  19297. releaseSubMeshes(): AbstractMesh;
  19298. /**
  19299. * Releases resources associated with this abstract mesh.
  19300. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19301. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19302. */
  19303. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19304. /**
  19305. * Adds the passed mesh as a child to the current mesh.
  19306. * Returns the AbstractMesh.
  19307. */
  19308. addChild(mesh: AbstractMesh): AbstractMesh;
  19309. /**
  19310. * Removes the passed mesh from the current mesh children list.
  19311. * Returns the AbstractMesh.
  19312. */
  19313. removeChild(mesh: AbstractMesh): AbstractMesh;
  19314. /**
  19315. * Initialize the facet data arrays : facetNormals, facetPositions and facetPartitioning.
  19316. * Returns the AbstractMesh.
  19317. */
  19318. private _initFacetData();
  19319. /**
  19320. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  19321. * This method can be called within the render loop.
  19322. * 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.
  19323. * Returns the AbstractMesh.
  19324. */
  19325. updateFacetData(): AbstractMesh;
  19326. /**
  19327. * Returns the facetLocalNormals array.
  19328. * The normals are expressed in the mesh local space.
  19329. */
  19330. getFacetLocalNormals(): Vector3[];
  19331. /**
  19332. * Returns the facetLocalPositions array.
  19333. * The facet positions are expressed in the mesh local space.
  19334. */
  19335. getFacetLocalPositions(): Vector3[];
  19336. /**
  19337. * Returns the facetLocalPartioning array.
  19338. */
  19339. getFacetLocalPartitioning(): number[][];
  19340. /**
  19341. * Returns the i-th facet position in the world system.
  19342. * This method allocates a new Vector3 per call.
  19343. */
  19344. getFacetPosition(i: number): Vector3;
  19345. /**
  19346. * Sets the reference Vector3 with the i-th facet position in the world system.
  19347. * Returns the AbstractMesh.
  19348. */
  19349. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  19350. /**
  19351. * Returns the i-th facet normal in the world system.
  19352. * This method allocates a new Vector3 per call.
  19353. */
  19354. getFacetNormal(i: number): Vector3;
  19355. /**
  19356. * Sets the reference Vector3 with the i-th facet normal in the world system.
  19357. * Returns the AbstractMesh.
  19358. */
  19359. getFacetNormalToRef(i: number, ref: Vector3): this;
  19360. /**
  19361. * 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).
  19362. */
  19363. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  19364. /**
  19365. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found.
  19366. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) World projection on the facet.
  19367. * If checkFace is 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.
  19368. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  19369. * 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.
  19370. */
  19371. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19372. /**
  19373. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found.
  19374. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) local projection on the facet.
  19375. * If checkFace is 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.
  19376. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  19377. * 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.
  19378. */
  19379. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19380. /**
  19381. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  19382. */
  19383. getFacetDataParameters(): any;
  19384. /**
  19385. * Disables the feature FacetData and frees the related memory.
  19386. * Returns the AbstractMesh.
  19387. */
  19388. disableFacetData(): AbstractMesh;
  19389. /**
  19390. * Updates the AbstractMesh indices array. Actually, used by the Mesh object.
  19391. * Returns the mesh.
  19392. */
  19393. updateIndices(indices: IndicesArray): AbstractMesh;
  19394. /**
  19395. * The mesh Geometry. Actually used by the Mesh object.
  19396. * Returns a blank geometry object.
  19397. */
  19398. /**
  19399. * Creates new normals data for the mesh.
  19400. * @param updatable.
  19401. */
  19402. createNormals(updatable: boolean): void;
  19403. /**
  19404. * Align the mesh with a normal.
  19405. * Returns the mesh.
  19406. */
  19407. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  19408. protected checkOcclusionQuery(): void;
  19409. }
  19410. }
  19411. declare module BABYLON {
  19412. class Buffer {
  19413. private _engine;
  19414. private _buffer;
  19415. private _data;
  19416. private _updatable;
  19417. private _instanced;
  19418. /**
  19419. * Gets the byte stride.
  19420. */
  19421. readonly byteStride: number;
  19422. /**
  19423. * Constructor
  19424. * @param engine the engine
  19425. * @param data the data to use for this buffer
  19426. * @param updatable whether the data is updatable
  19427. * @param stride the stride (optional)
  19428. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  19429. * @param instanced whether the buffer is instanced (optional)
  19430. * @param useBytes set to true if the stride in in bytes (optional)
  19431. */
  19432. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  19433. /**
  19434. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  19435. * @param kind defines the vertex buffer kind (position, normal, etc.)
  19436. * @param offset defines offset in the buffer (0 by default)
  19437. * @param size defines the size in floats of attributes (position is 3 for instance)
  19438. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  19439. * @param instanced defines if the vertex buffer contains indexed data
  19440. * @param useBytes defines if the offset and stride are in bytes
  19441. * @returns the new vertex buffer
  19442. */
  19443. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  19444. isUpdatable(): boolean;
  19445. getData(): Nullable<DataArray>;
  19446. getBuffer(): Nullable<WebGLBuffer>;
  19447. /**
  19448. * Gets the stride in float32 units (i.e. byte stride / 4).
  19449. * May not be an integer if the byte stride is not divisible by 4.
  19450. * DEPRECATED. Use byteStride instead.
  19451. * @returns the stride in float32 units
  19452. */
  19453. getStrideSize(): number;
  19454. create(data?: Nullable<DataArray>): void;
  19455. _rebuild(): void;
  19456. update(data: DataArray): void;
  19457. /**
  19458. * Updates the data directly.
  19459. * @param data the new data
  19460. * @param offset the new offset
  19461. * @param vertexCount the vertex count (optional)
  19462. * @param useBytes set to true if the offset is in bytes
  19463. */
  19464. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  19465. dispose(): void;
  19466. }
  19467. }
  19468. declare module BABYLON {
  19469. class CSG {
  19470. private polygons;
  19471. matrix: Matrix;
  19472. position: Vector3;
  19473. rotation: Vector3;
  19474. rotationQuaternion: Nullable<Quaternion>;
  19475. scaling: Vector3;
  19476. static FromMesh(mesh: Mesh): CSG;
  19477. private static FromPolygons(polygons);
  19478. clone(): CSG;
  19479. union(csg: CSG): CSG;
  19480. unionInPlace(csg: CSG): void;
  19481. subtract(csg: CSG): CSG;
  19482. subtractInPlace(csg: CSG): void;
  19483. intersect(csg: CSG): CSG;
  19484. intersectInPlace(csg: CSG): void;
  19485. inverse(): CSG;
  19486. inverseInPlace(): void;
  19487. copyTransformAttributes(csg: CSG): CSG;
  19488. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  19489. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  19490. }
  19491. }
  19492. declare module BABYLON {
  19493. /**
  19494. * Class used to store geometry data (vertex buffers + index buffer)
  19495. */
  19496. class Geometry implements IGetSetVerticesData {
  19497. /**
  19498. * Gets or sets the unique ID of the geometry
  19499. */
  19500. id: string;
  19501. /**
  19502. * Gets the delay loading state of the geometry (none by default which means not delayed)
  19503. */
  19504. delayLoadState: number;
  19505. /**
  19506. * Gets the file containing the data to load when running in delay load state
  19507. */
  19508. delayLoadingFile: Nullable<string>;
  19509. /**
  19510. * Callback called when the geometry is updated
  19511. */
  19512. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  19513. private _scene;
  19514. private _engine;
  19515. private _meshes;
  19516. private _totalVertices;
  19517. private _indices;
  19518. private _vertexBuffers;
  19519. private _isDisposed;
  19520. private _extend;
  19521. private _boundingBias;
  19522. /** @ignore */
  19523. _delayInfo: Array<string>;
  19524. private _indexBuffer;
  19525. private _indexBufferIsUpdatable;
  19526. /** @ignore */
  19527. _boundingInfo: Nullable<BoundingInfo>;
  19528. /** @ignore */
  19529. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  19530. /** @ignore */
  19531. _softwareSkinningRenderId: number;
  19532. private _vertexArrayObjects;
  19533. private _updatable;
  19534. /** @ignore */
  19535. _positions: Nullable<Vector3[]>;
  19536. /**
  19537. * 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
  19538. */
  19539. /**
  19540. * 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
  19541. */
  19542. boundingBias: Vector2;
  19543. /**
  19544. * Static function used to attach a new empty geometry to a mesh
  19545. * @param mesh defines the mesh to attach the geometry to
  19546. * @returns the new {BABYLON.Geometry}
  19547. */
  19548. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  19549. /**
  19550. * Creates a new geometry
  19551. * @param id defines the unique ID
  19552. * @param scene defines the hosting scene
  19553. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  19554. * @param updatable defines if geometry must be updatable (false by default)
  19555. * @param mesh defines the mesh that will be associated with the geometry
  19556. */
  19557. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  19558. /**
  19559. * Gets the current extend of the geometry
  19560. */
  19561. readonly extend: {
  19562. minimum: Vector3;
  19563. maximum: Vector3;
  19564. };
  19565. /**
  19566. * Gets the hosting scene
  19567. * @returns the hosting {BABYLON.Scene}
  19568. */
  19569. getScene(): Scene;
  19570. /**
  19571. * Gets the hosting engine
  19572. * @returns the hosting {BABYLON.Engine}
  19573. */
  19574. getEngine(): Engine;
  19575. /**
  19576. * Defines if the geometry is ready to use
  19577. * @returns true if the geometry is ready to be used
  19578. */
  19579. isReady(): boolean;
  19580. /**
  19581. * Gets a value indicating that the geometry should not be serialized
  19582. */
  19583. readonly doNotSerialize: boolean;
  19584. /** @ignore */
  19585. _rebuild(): void;
  19586. /**
  19587. * Affects all gemetry data in one call
  19588. * @param vertexData defines the geometry data
  19589. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  19590. */
  19591. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  19592. /**
  19593. * Set specific vertex data
  19594. * @param kind defines the data kind (Position, normal, etc...)
  19595. * @param data defines the vertex data to use
  19596. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  19597. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  19598. */
  19599. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  19600. /**
  19601. * Removes a specific vertex data
  19602. * @param kind defines the data kind (Position, normal, etc...)
  19603. */
  19604. removeVerticesData(kind: string): void;
  19605. /**
  19606. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  19607. * @param buffer defines the vertex buffer to use
  19608. * @param totalVertices defines the total number of vertices for position kind (could be null)
  19609. */
  19610. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  19611. /**
  19612. * Update a specific vertex buffer
  19613. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  19614. * It will do nothing if the buffer is not updatable
  19615. * @param kind defines the data kind (Position, normal, etc...)
  19616. * @param data defines the data to use
  19617. * @param offset defines the offset in the target buffer where to store the data
  19618. * @param useBytes set to true if the offset is in bytes
  19619. */
  19620. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  19621. /**
  19622. * Update a specific vertex buffer
  19623. * This function will create a new buffer if the current one is not updatable
  19624. * @param kind defines the data kind (Position, normal, etc...)
  19625. * @param data defines the data to use
  19626. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  19627. */
  19628. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  19629. private _updateBoundingInfo(updateExtends, data);
  19630. /** @ignore */
  19631. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  19632. /**
  19633. * Gets total number of vertices
  19634. * @returns the total number of vertices
  19635. */
  19636. getTotalVertices(): number;
  19637. /**
  19638. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  19639. * @param kind defines the data kind (Position, normal, etc...)
  19640. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  19641. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19642. * @returns a float array containing vertex data
  19643. */
  19644. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19645. /**
  19646. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  19647. * @param kind defines the data kind (Position, normal, etc...)
  19648. * @returns true if the vertex buffer with the specified kind is updatable
  19649. */
  19650. isVertexBufferUpdatable(kind: string): boolean;
  19651. /**
  19652. * Gets a specific vertex buffer
  19653. * @param kind defines the data kind (Position, normal, etc...)
  19654. * @returns a {BABYLON.VertexBuffer}
  19655. */
  19656. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19657. /**
  19658. * Returns all vertex buffers
  19659. * @return an object holding all vertex buffers indexed by kind
  19660. */
  19661. getVertexBuffers(): Nullable<{
  19662. [key: string]: VertexBuffer;
  19663. }>;
  19664. /**
  19665. * Gets a boolean indicating if specific vertex buffer is present
  19666. * @param kind defines the data kind (Position, normal, etc...)
  19667. * @returns true if data is present
  19668. */
  19669. isVerticesDataPresent(kind: string): boolean;
  19670. /**
  19671. * Gets a list of all attached data kinds (Position, normal, etc...)
  19672. * @returns a list of string containing all kinds
  19673. */
  19674. getVerticesDataKinds(): string[];
  19675. /**
  19676. * Update index buffer
  19677. * @param indices defines the indices to store in the index buffer
  19678. * @param offset defines the offset in the target buffer where to store the data
  19679. */
  19680. updateIndices(indices: IndicesArray, offset?: number): void;
  19681. /**
  19682. * Creates a new index buffer
  19683. * @param indices defines the indices to store in the index buffer
  19684. * @param totalVertices defines the total number of vertices (could be null)
  19685. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  19686. */
  19687. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  19688. /**
  19689. * Return the total number of indices
  19690. * @returns the total number of indices
  19691. */
  19692. getTotalIndices(): number;
  19693. /**
  19694. * Gets the index buffer array
  19695. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  19696. * @returns the index buffer array
  19697. */
  19698. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  19699. /**
  19700. * Gets the index buffer
  19701. * @return the index buffer
  19702. */
  19703. getIndexBuffer(): Nullable<WebGLBuffer>;
  19704. /** @ignore */
  19705. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  19706. /**
  19707. * Release the associated resources for a specific mesh
  19708. * @param mesh defines the source mesh
  19709. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  19710. */
  19711. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  19712. /**
  19713. * Apply current geometry to a given mesh
  19714. * @param mesh defines the mesh to apply geometry to
  19715. */
  19716. applyToMesh(mesh: Mesh): void;
  19717. private _updateExtend(data?);
  19718. private _applyToMesh(mesh);
  19719. private notifyUpdate(kind?);
  19720. /**
  19721. * Load the geometry if it was flagged as delay loaded
  19722. * @param scene defines the hosting scene
  19723. * @param onLoaded defines a callback called when the geometry is loaded
  19724. */
  19725. load(scene: Scene, onLoaded?: () => void): void;
  19726. private _queueLoad(scene, onLoaded?);
  19727. /**
  19728. * Invert the geometry to move from a right handed system to a left handed one.
  19729. */
  19730. toLeftHanded(): void;
  19731. /** @ignore */
  19732. _resetPointsArrayCache(): void;
  19733. /** @ignore */
  19734. _generatePointsArray(): boolean;
  19735. /**
  19736. * Gets a value indicating if the geometry is disposed
  19737. * @returns true if the geometry was disposed
  19738. */
  19739. isDisposed(): boolean;
  19740. private _disposeVertexArrayObjects();
  19741. /**
  19742. * Free all associated resources
  19743. */
  19744. dispose(): void;
  19745. /**
  19746. * Clone the current geometry into a new geometry
  19747. * @param id defines the unique ID of the new geometry
  19748. * @returns a new geometry object
  19749. */
  19750. copy(id: string): Geometry;
  19751. /**
  19752. * Serialize the current geometry info (and not the vertices data) into a JSON object
  19753. * @return a JSON representation of the current geometry data (without the vertices data)
  19754. */
  19755. serialize(): any;
  19756. private toNumberArray(origin);
  19757. /**
  19758. * Serialize all vertices data into a JSON oject
  19759. * @returns a JSON representation of the current geometry data
  19760. */
  19761. serializeVerticeData(): any;
  19762. /**
  19763. * Extracts a clone of a mesh geometry
  19764. * @param mesh defines the source mesh
  19765. * @param id defines the unique ID of the new geometry object
  19766. * @returns the new geometry object
  19767. */
  19768. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  19769. /**
  19770. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  19771. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  19772. * Be aware Math.random() could cause collisions, but:
  19773. * "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"
  19774. * @returns a string containing a new GUID
  19775. */
  19776. static RandomId(): string;
  19777. /** @ignore */
  19778. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  19779. private static _CleanMatricesWeights(parsedGeometry, mesh);
  19780. /**
  19781. * Create a new geometry from persisted data (Using .babylon file format)
  19782. * @param parsedVertexData defines the persisted data
  19783. * @param scene defines the hosting scene
  19784. * @param rootUrl defines the root url to use to load assets (like delayed data)
  19785. * @returns the new geometry object
  19786. */
  19787. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  19788. }
  19789. /**
  19790. * Abstract class used to provide common services for all typed geometries
  19791. */
  19792. class _PrimitiveGeometry extends Geometry {
  19793. private _canBeRegenerated;
  19794. private _beingRegenerated;
  19795. /**
  19796. * Creates a new typed geometry
  19797. * @param id defines the unique ID of the geometry
  19798. * @param scene defines the hosting scene
  19799. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19800. * @param mesh defines the hosting mesh (can be null)
  19801. */
  19802. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  19803. /**
  19804. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  19805. * @returns true if the geometry can be regenerated
  19806. */
  19807. canBeRegenerated(): boolean;
  19808. /**
  19809. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  19810. */
  19811. regenerate(): void;
  19812. /**
  19813. * Clone the geometry
  19814. * @param id defines the unique ID of the new geometry
  19815. * @returns the new geometry
  19816. */
  19817. asNewGeometry(id: string): Geometry;
  19818. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  19819. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  19820. /** @ignore */
  19821. _regenerateVertexData(): VertexData;
  19822. copy(id: string): Geometry;
  19823. serialize(): any;
  19824. }
  19825. /**
  19826. * Creates a ribbon geometry
  19827. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  19828. */
  19829. class RibbonGeometry extends _PrimitiveGeometry {
  19830. /**
  19831. * Defines the array of paths to use
  19832. */
  19833. pathArray: Vector3[][];
  19834. /**
  19835. * Defines if the last and first points of each path in your pathArray must be joined
  19836. */
  19837. closeArray: boolean;
  19838. /**
  19839. * Defines if the last and first points of each path in your pathArray must be joined
  19840. */
  19841. closePath: boolean;
  19842. /**
  19843. * Defines the offset between points
  19844. */
  19845. offset: number;
  19846. /**
  19847. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19848. */
  19849. side: number;
  19850. /**
  19851. * Creates a ribbon geometry
  19852. * @param id defines the unique ID of the geometry
  19853. * @param scene defines the hosting scene
  19854. * @param pathArray defines the array of paths to use
  19855. * @param closeArray defines if the last path and the first path must be joined
  19856. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  19857. * @param offset defines the offset between points
  19858. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19859. * @param mesh defines the hosting mesh (can be null)
  19860. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19861. */
  19862. constructor(id: string, scene: Scene,
  19863. /**
  19864. * Defines the array of paths to use
  19865. */
  19866. pathArray: Vector3[][],
  19867. /**
  19868. * Defines if the last and first points of each path in your pathArray must be joined
  19869. */
  19870. closeArray: boolean,
  19871. /**
  19872. * Defines if the last and first points of each path in your pathArray must be joined
  19873. */
  19874. closePath: boolean,
  19875. /**
  19876. * Defines the offset between points
  19877. */
  19878. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  19879. /**
  19880. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19881. */
  19882. side?: number);
  19883. /** @ignore */
  19884. _regenerateVertexData(): VertexData;
  19885. copy(id: string): Geometry;
  19886. }
  19887. /**
  19888. * Creates a box geometry
  19889. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  19890. */
  19891. class BoxGeometry extends _PrimitiveGeometry {
  19892. /**
  19893. * Defines the zise of the box (width, height and depth are the same)
  19894. */
  19895. size: number;
  19896. /**
  19897. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19898. */
  19899. side: number;
  19900. /**
  19901. * Creates a box geometry
  19902. * @param id defines the unique ID of the geometry
  19903. * @param scene defines the hosting scene
  19904. * @param size defines the zise of the box (width, height and depth are the same)
  19905. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19906. * @param mesh defines the hosting mesh (can be null)
  19907. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19908. */
  19909. constructor(id: string, scene: Scene,
  19910. /**
  19911. * Defines the zise of the box (width, height and depth are the same)
  19912. */
  19913. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19914. /**
  19915. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19916. */
  19917. side?: number);
  19918. _regenerateVertexData(): VertexData;
  19919. copy(id: string): Geometry;
  19920. serialize(): any;
  19921. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  19922. }
  19923. /**
  19924. * Creates a sphere geometry
  19925. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  19926. */
  19927. class SphereGeometry extends _PrimitiveGeometry {
  19928. /**
  19929. * Defines the number of segments to use to create the sphere
  19930. */
  19931. segments: number;
  19932. /**
  19933. * Defines the diameter of the sphere
  19934. */
  19935. diameter: number;
  19936. /**
  19937. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19938. */
  19939. side: number;
  19940. /**
  19941. * Create a new sphere geometry
  19942. * @param id defines the unique ID of the geometry
  19943. * @param scene defines the hosting scene
  19944. * @param segments defines the number of segments to use to create the sphere
  19945. * @param diameter defines the diameter of the sphere
  19946. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19947. * @param mesh defines the hosting mesh (can be null)
  19948. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19949. */
  19950. constructor(id: string, scene: Scene,
  19951. /**
  19952. * Defines the number of segments to use to create the sphere
  19953. */
  19954. segments: number,
  19955. /**
  19956. * Defines the diameter of the sphere
  19957. */
  19958. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19959. /**
  19960. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19961. */
  19962. side?: number);
  19963. _regenerateVertexData(): VertexData;
  19964. copy(id: string): Geometry;
  19965. serialize(): any;
  19966. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  19967. }
  19968. /**
  19969. * Creates a disc geometry
  19970. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  19971. */
  19972. class DiscGeometry extends _PrimitiveGeometry {
  19973. /**
  19974. * Defines the radius of the disc
  19975. */
  19976. radius: number;
  19977. /**
  19978. * Defines the tesselation factor to apply to the disc
  19979. */
  19980. tessellation: number;
  19981. /**
  19982. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19983. */
  19984. side: number;
  19985. /**
  19986. * Creates a new disc geometry
  19987. * @param id defines the unique ID of the geometry
  19988. * @param scene defines the hosting scene
  19989. * @param radius defines the radius of the disc
  19990. * @param tessellation defines the tesselation factor to apply to the disc
  19991. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19992. * @param mesh defines the hosting mesh (can be null)
  19993. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19994. */
  19995. constructor(id: string, scene: Scene,
  19996. /**
  19997. * Defines the radius of the disc
  19998. */
  19999. radius: number,
  20000. /**
  20001. * Defines the tesselation factor to apply to the disc
  20002. */
  20003. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20004. /**
  20005. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20006. */
  20007. side?: number);
  20008. _regenerateVertexData(): VertexData;
  20009. copy(id: string): Geometry;
  20010. }
  20011. /**
  20012. * Creates a new cylinder geometry
  20013. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  20014. */
  20015. class CylinderGeometry extends _PrimitiveGeometry {
  20016. /**
  20017. * Defines the height of the cylinder
  20018. */
  20019. height: number;
  20020. /**
  20021. * Defines the diameter of the cylinder's top cap
  20022. */
  20023. diameterTop: number;
  20024. /**
  20025. * Defines the diameter of the cylinder's bottom cap
  20026. */
  20027. diameterBottom: number;
  20028. /**
  20029. * Defines the tessellation factor to apply to the cylinder
  20030. */
  20031. tessellation: number;
  20032. /**
  20033. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20034. */
  20035. subdivisions: number;
  20036. /**
  20037. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20038. */
  20039. side: number;
  20040. /**
  20041. * Creates a new cylinder geometry
  20042. * @param id defines the unique ID of the geometry
  20043. * @param scene defines the hosting scene
  20044. * @param height defines the height of the cylinder
  20045. * @param diameterTop defines the diameter of the cylinder's top cap
  20046. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  20047. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  20048. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  20049. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20050. * @param mesh defines the hosting mesh (can be null)
  20051. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20052. */
  20053. constructor(id: string, scene: Scene,
  20054. /**
  20055. * Defines the height of the cylinder
  20056. */
  20057. height: number,
  20058. /**
  20059. * Defines the diameter of the cylinder's top cap
  20060. */
  20061. diameterTop: number,
  20062. /**
  20063. * Defines the diameter of the cylinder's bottom cap
  20064. */
  20065. diameterBottom: number,
  20066. /**
  20067. * Defines the tessellation factor to apply to the cylinder
  20068. */
  20069. tessellation: number,
  20070. /**
  20071. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20072. */
  20073. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20074. /**
  20075. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20076. */
  20077. side?: number);
  20078. _regenerateVertexData(): VertexData;
  20079. copy(id: string): Geometry;
  20080. serialize(): any;
  20081. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  20082. }
  20083. /**
  20084. * Creates a new torus geometry
  20085. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  20086. */
  20087. class TorusGeometry extends _PrimitiveGeometry {
  20088. /**
  20089. * Defines the diameter of the torus
  20090. */
  20091. diameter: number;
  20092. /**
  20093. * Defines the thickness of the torus (ie. internal diameter)
  20094. */
  20095. thickness: number;
  20096. /**
  20097. * Defines the tesselation factor to apply to the torus
  20098. */
  20099. tessellation: number;
  20100. /**
  20101. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20102. */
  20103. side: number;
  20104. /**
  20105. * Creates a new torus geometry
  20106. * @param id defines the unique ID of the geometry
  20107. * @param scene defines the hosting scene
  20108. * @param diameter defines the diameter of the torus
  20109. * @param thickness defines the thickness of the torus (ie. internal diameter)
  20110. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  20111. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20112. * @param mesh defines the hosting mesh (can be null)
  20113. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20114. */
  20115. constructor(id: string, scene: Scene,
  20116. /**
  20117. * Defines the diameter of the torus
  20118. */
  20119. diameter: number,
  20120. /**
  20121. * Defines the thickness of the torus (ie. internal diameter)
  20122. */
  20123. thickness: number,
  20124. /**
  20125. * Defines the tesselation factor to apply to the torus
  20126. */
  20127. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20128. /**
  20129. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20130. */
  20131. side?: number);
  20132. _regenerateVertexData(): VertexData;
  20133. copy(id: string): Geometry;
  20134. serialize(): any;
  20135. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  20136. }
  20137. /**
  20138. * Creates a new ground geometry
  20139. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  20140. */
  20141. class GroundGeometry extends _PrimitiveGeometry {
  20142. /**
  20143. * Defines the width of the ground
  20144. */
  20145. width: number;
  20146. /**
  20147. * Defines the height of the ground
  20148. */
  20149. height: number;
  20150. /**
  20151. * Defines the subdivisions to apply to the ground
  20152. */
  20153. subdivisions: number;
  20154. /**
  20155. * Creates a new ground geometry
  20156. * @param id defines the unique ID of the geometry
  20157. * @param scene defines the hosting scene
  20158. * @param width defines the width of the ground
  20159. * @param height defines the height of the ground
  20160. * @param subdivisions defines the subdivisions to apply to the ground
  20161. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20162. * @param mesh defines the hosting mesh (can be null)
  20163. */
  20164. constructor(id: string, scene: Scene,
  20165. /**
  20166. * Defines the width of the ground
  20167. */
  20168. width: number,
  20169. /**
  20170. * Defines the height of the ground
  20171. */
  20172. height: number,
  20173. /**
  20174. * Defines the subdivisions to apply to the ground
  20175. */
  20176. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20177. _regenerateVertexData(): VertexData;
  20178. copy(id: string): Geometry;
  20179. serialize(): any;
  20180. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  20181. }
  20182. /**
  20183. * Creates a tiled ground geometry
  20184. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  20185. */
  20186. class TiledGroundGeometry extends _PrimitiveGeometry {
  20187. /**
  20188. * Defines the minimum value on X axis
  20189. */
  20190. xmin: number;
  20191. /**
  20192. * Defines the minimum value on Z axis
  20193. */
  20194. zmin: number;
  20195. /**
  20196. * Defines the maximum value on X axis
  20197. */
  20198. xmax: number;
  20199. /**
  20200. * Defines the maximum value on Z axis
  20201. */
  20202. zmax: number;
  20203. /**
  20204. * Defines the subdivisions to apply to the ground
  20205. */
  20206. subdivisions: {
  20207. w: number;
  20208. h: number;
  20209. };
  20210. /**
  20211. * Defines the precision to use when computing the tiles
  20212. */
  20213. precision: {
  20214. w: number;
  20215. h: number;
  20216. };
  20217. /**
  20218. * Creates a tiled ground geometry
  20219. * @param id defines the unique ID of the geometry
  20220. * @param scene defines the hosting scene
  20221. * @param xmin defines the minimum value on X axis
  20222. * @param zmin defines the minimum value on Z axis
  20223. * @param xmax defines the maximum value on X axis
  20224. * @param zmax defines the maximum value on Z axis
  20225. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  20226. * @param precision defines the precision to use when computing the tiles
  20227. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20228. * @param mesh defines the hosting mesh (can be null)
  20229. */
  20230. constructor(id: string, scene: Scene,
  20231. /**
  20232. * Defines the minimum value on X axis
  20233. */
  20234. xmin: number,
  20235. /**
  20236. * Defines the minimum value on Z axis
  20237. */
  20238. zmin: number,
  20239. /**
  20240. * Defines the maximum value on X axis
  20241. */
  20242. xmax: number,
  20243. /**
  20244. * Defines the maximum value on Z axis
  20245. */
  20246. zmax: number,
  20247. /**
  20248. * Defines the subdivisions to apply to the ground
  20249. */
  20250. subdivisions: {
  20251. w: number;
  20252. h: number;
  20253. },
  20254. /**
  20255. * Defines the precision to use when computing the tiles
  20256. */
  20257. precision: {
  20258. w: number;
  20259. h: number;
  20260. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20261. _regenerateVertexData(): VertexData;
  20262. copy(id: string): Geometry;
  20263. }
  20264. /**
  20265. * Creates a plane geometry
  20266. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  20267. */
  20268. class PlaneGeometry extends _PrimitiveGeometry {
  20269. /**
  20270. * Defines the size of the plane (width === height)
  20271. */
  20272. size: number;
  20273. /**
  20274. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20275. */
  20276. side: number;
  20277. /**
  20278. * Creates a plane geometry
  20279. * @param id defines the unique ID of the geometry
  20280. * @param scene defines the hosting scene
  20281. * @param size defines the size of the plane (width === height)
  20282. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20283. * @param mesh defines the hosting mesh (can be null)
  20284. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20285. */
  20286. constructor(id: string, scene: Scene,
  20287. /**
  20288. * Defines the size of the plane (width === height)
  20289. */
  20290. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20291. /**
  20292. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20293. */
  20294. side?: number);
  20295. _regenerateVertexData(): VertexData;
  20296. copy(id: string): Geometry;
  20297. serialize(): any;
  20298. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  20299. }
  20300. /**
  20301. * Creates a torus knot geometry
  20302. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  20303. */
  20304. class TorusKnotGeometry extends _PrimitiveGeometry {
  20305. /**
  20306. * Defines the radius of the torus knot
  20307. */
  20308. radius: number;
  20309. /**
  20310. * Defines the thickness of the torus knot tube
  20311. */
  20312. tube: number;
  20313. /**
  20314. * Defines the number of radial segments
  20315. */
  20316. radialSegments: number;
  20317. /**
  20318. * Defines the number of tubular segments
  20319. */
  20320. tubularSegments: number;
  20321. /**
  20322. * Defines the first number of windings
  20323. */
  20324. p: number;
  20325. /**
  20326. * Defines the second number of windings
  20327. */
  20328. q: number;
  20329. /**
  20330. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20331. */
  20332. side: number;
  20333. /**
  20334. * Creates a torus knot geometry
  20335. * @param id defines the unique ID of the geometry
  20336. * @param scene defines the hosting scene
  20337. * @param radius defines the radius of the torus knot
  20338. * @param tube defines the thickness of the torus knot tube
  20339. * @param radialSegments defines the number of radial segments
  20340. * @param tubularSegments defines the number of tubular segments
  20341. * @param p defines the first number of windings
  20342. * @param q defines the second number of windings
  20343. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20344. * @param mesh defines the hosting mesh (can be null)
  20345. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20346. */
  20347. constructor(id: string, scene: Scene,
  20348. /**
  20349. * Defines the radius of the torus knot
  20350. */
  20351. radius: number,
  20352. /**
  20353. * Defines the thickness of the torus knot tube
  20354. */
  20355. tube: number,
  20356. /**
  20357. * Defines the number of radial segments
  20358. */
  20359. radialSegments: number,
  20360. /**
  20361. * Defines the number of tubular segments
  20362. */
  20363. tubularSegments: number,
  20364. /**
  20365. * Defines the first number of windings
  20366. */
  20367. p: number,
  20368. /**
  20369. * Defines the second number of windings
  20370. */
  20371. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20372. /**
  20373. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20374. */
  20375. side?: number);
  20376. _regenerateVertexData(): VertexData;
  20377. copy(id: string): Geometry;
  20378. serialize(): any;
  20379. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  20380. }
  20381. }
  20382. declare module BABYLON {
  20383. class GroundMesh extends Mesh {
  20384. generateOctree: boolean;
  20385. private _heightQuads;
  20386. _subdivisionsX: number;
  20387. _subdivisionsY: number;
  20388. _width: number;
  20389. _height: number;
  20390. _minX: number;
  20391. _maxX: number;
  20392. _minZ: number;
  20393. _maxZ: number;
  20394. constructor(name: string, scene: Scene);
  20395. getClassName(): string;
  20396. readonly subdivisions: number;
  20397. readonly subdivisionsX: number;
  20398. readonly subdivisionsY: number;
  20399. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20400. /**
  20401. * Returns a height (y) value in the Worl system :
  20402. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20403. * Returns the ground y position if (x, z) are outside the ground surface.
  20404. */
  20405. getHeightAtCoordinates(x: number, z: number): number;
  20406. /**
  20407. * Returns a normalized vector (Vector3) orthogonal to the ground
  20408. * at the ground coordinates (x, z) expressed in the World system.
  20409. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20410. */
  20411. getNormalAtCoordinates(x: number, z: number): Vector3;
  20412. /**
  20413. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20414. * at the ground coordinates (x, z) expressed in the World system.
  20415. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20416. * Returns the GroundMesh.
  20417. */
  20418. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20419. /**
  20420. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20421. * if the ground has been updated.
  20422. * This can be used in the render loop.
  20423. * Returns the GroundMesh.
  20424. */
  20425. updateCoordinateHeights(): GroundMesh;
  20426. private _getFacetAt(x, z);
  20427. private _initHeightQuads();
  20428. private _computeHeightQuads();
  20429. serialize(serializationObject: any): void;
  20430. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20431. }
  20432. }
  20433. declare module BABYLON {
  20434. /**
  20435. * Creates an instance based on a source mesh.
  20436. */
  20437. class InstancedMesh extends AbstractMesh {
  20438. private _sourceMesh;
  20439. private _currentLOD;
  20440. constructor(name: string, source: Mesh);
  20441. /**
  20442. * Returns the string "InstancedMesh".
  20443. */
  20444. getClassName(): string;
  20445. readonly receiveShadows: boolean;
  20446. readonly material: Nullable<Material>;
  20447. readonly visibility: number;
  20448. readonly skeleton: Nullable<Skeleton>;
  20449. renderingGroupId: number;
  20450. /**
  20451. * Returns the total number of vertices (integer).
  20452. */
  20453. getTotalVertices(): number;
  20454. readonly sourceMesh: Mesh;
  20455. /**
  20456. * Is this node ready to be used/rendered
  20457. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20458. * @return {boolean} is it ready
  20459. */
  20460. isReady(completeCheck?: boolean): boolean;
  20461. /**
  20462. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  20463. */
  20464. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  20465. /**
  20466. * Sets the vertex data of the mesh geometry for the requested `kind`.
  20467. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  20468. * The `data` are either a numeric array either a Float32Array.
  20469. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  20470. * 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).
  20471. * Note that a new underlying VertexBuffer object is created each call.
  20472. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  20473. *
  20474. * Possible `kind` values :
  20475. * - BABYLON.VertexBuffer.PositionKind
  20476. * - BABYLON.VertexBuffer.UVKind
  20477. * - BABYLON.VertexBuffer.UV2Kind
  20478. * - BABYLON.VertexBuffer.UV3Kind
  20479. * - BABYLON.VertexBuffer.UV4Kind
  20480. * - BABYLON.VertexBuffer.UV5Kind
  20481. * - BABYLON.VertexBuffer.UV6Kind
  20482. * - BABYLON.VertexBuffer.ColorKind
  20483. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20484. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20485. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20486. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20487. *
  20488. * Returns the Mesh.
  20489. */
  20490. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20491. /**
  20492. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  20493. * If the mesh has no geometry, it is simply returned as it is.
  20494. * The `data` are either a numeric array either a Float32Array.
  20495. * No new underlying VertexBuffer object is created.
  20496. * 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.
  20497. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  20498. *
  20499. * Possible `kind` values :
  20500. * - BABYLON.VertexBuffer.PositionKind
  20501. * - BABYLON.VertexBuffer.UVKind
  20502. * - BABYLON.VertexBuffer.UV2Kind
  20503. * - BABYLON.VertexBuffer.UV3Kind
  20504. * - BABYLON.VertexBuffer.UV4Kind
  20505. * - BABYLON.VertexBuffer.UV5Kind
  20506. * - BABYLON.VertexBuffer.UV6Kind
  20507. * - BABYLON.VertexBuffer.ColorKind
  20508. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20509. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20510. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20511. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20512. *
  20513. * Returns the Mesh.
  20514. */
  20515. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20516. /**
  20517. * Sets the mesh indices.
  20518. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  20519. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  20520. * This method creates a new index buffer each call.
  20521. * Returns the Mesh.
  20522. */
  20523. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  20524. /**
  20525. * Boolean : True if the mesh owns the requested kind of data.
  20526. */
  20527. isVerticesDataPresent(kind: string): boolean;
  20528. /**
  20529. * Returns an array of indices (IndicesArray).
  20530. */
  20531. getIndices(): Nullable<IndicesArray>;
  20532. readonly _positions: Nullable<Vector3[]>;
  20533. /**
  20534. * Sets a new updated BoundingInfo to the mesh.
  20535. * Returns the mesh.
  20536. */
  20537. refreshBoundingInfo(): InstancedMesh;
  20538. _preActivate(): InstancedMesh;
  20539. _activate(renderId: number): InstancedMesh;
  20540. /**
  20541. * Returns the current associated LOD AbstractMesh.
  20542. */
  20543. getLOD(camera: Camera): AbstractMesh;
  20544. _syncSubMeshes(): InstancedMesh;
  20545. _generatePointsArray(): boolean;
  20546. /**
  20547. * Creates a new InstancedMesh from the current mesh.
  20548. * - name (string) : the cloned mesh name
  20549. * - newParent (optional Node) : the optional Node to parent the clone to.
  20550. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  20551. *
  20552. * Returns the clone.
  20553. */
  20554. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  20555. /**
  20556. * Disposes the InstancedMesh.
  20557. * Returns nothing.
  20558. */
  20559. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20560. }
  20561. }
  20562. declare module BABYLON {
  20563. class LinesMesh extends Mesh {
  20564. useVertexColor: boolean | undefined;
  20565. useVertexAlpha: boolean | undefined;
  20566. color: Color3;
  20567. alpha: number;
  20568. /**
  20569. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20570. * This margin is expressed in world space coordinates, so its value may vary.
  20571. * Default value is 0.1
  20572. * @returns the intersection Threshold value.
  20573. */
  20574. /**
  20575. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20576. * This margin is expressed in world space coordinates, so its value may vary.
  20577. * @param value the new threshold to apply
  20578. */
  20579. intersectionThreshold: number;
  20580. private _intersectionThreshold;
  20581. private _colorShader;
  20582. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  20583. /**
  20584. * Returns the string "LineMesh"
  20585. */
  20586. getClassName(): string;
  20587. material: Material;
  20588. readonly checkCollisions: boolean;
  20589. createInstance(name: string): InstancedMesh;
  20590. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  20591. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  20592. dispose(doNotRecurse?: boolean): void;
  20593. /**
  20594. * Returns a new LineMesh object cloned from the current one.
  20595. */
  20596. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  20597. }
  20598. }
  20599. declare module BABYLON {
  20600. class _InstancesBatch {
  20601. mustReturn: boolean;
  20602. visibleInstances: Nullable<InstancedMesh[]>[];
  20603. renderSelf: boolean[];
  20604. }
  20605. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20606. static _FRONTSIDE: number;
  20607. static _BACKSIDE: number;
  20608. static _DOUBLESIDE: number;
  20609. static _DEFAULTSIDE: number;
  20610. static _NO_CAP: number;
  20611. static _CAP_START: number;
  20612. static _CAP_END: number;
  20613. static _CAP_ALL: number;
  20614. /**
  20615. * Mesh side orientation : usually the external or front surface
  20616. */
  20617. static readonly FRONTSIDE: number;
  20618. /**
  20619. * Mesh side orientation : usually the internal or back surface
  20620. */
  20621. static readonly BACKSIDE: number;
  20622. /**
  20623. * Mesh side orientation : both internal and external or front and back surfaces
  20624. */
  20625. static readonly DOUBLESIDE: number;
  20626. /**
  20627. * Mesh side orientation : by default, `FRONTSIDE`
  20628. */
  20629. static readonly DEFAULTSIDE: number;
  20630. /**
  20631. * Mesh cap setting : no cap
  20632. */
  20633. static readonly NO_CAP: number;
  20634. /**
  20635. * Mesh cap setting : one cap at the beginning of the mesh
  20636. */
  20637. static readonly CAP_START: number;
  20638. /**
  20639. * Mesh cap setting : one cap at the end of the mesh
  20640. */
  20641. static readonly CAP_END: number;
  20642. /**
  20643. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20644. */
  20645. static readonly CAP_ALL: number;
  20646. /**
  20647. * An event triggered before rendering the mesh
  20648. */
  20649. onBeforeRenderObservable: Observable<Mesh>;
  20650. /**
  20651. * An event triggered after rendering the mesh
  20652. */
  20653. onAfterRenderObservable: Observable<Mesh>;
  20654. /**
  20655. * An event triggered before drawing the mesh
  20656. */
  20657. onBeforeDrawObservable: Observable<Mesh>;
  20658. private _onBeforeDrawObserver;
  20659. onBeforeDraw: () => void;
  20660. delayLoadState: number;
  20661. instances: InstancedMesh[];
  20662. delayLoadingFile: string;
  20663. _binaryInfo: any;
  20664. private _LODLevels;
  20665. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  20666. private _morphTargetManager;
  20667. morphTargetManager: Nullable<MorphTargetManager>;
  20668. _geometry: Nullable<Geometry>;
  20669. _delayInfo: Array<string>;
  20670. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20671. _visibleInstances: any;
  20672. private _renderIdForInstances;
  20673. private _batchCache;
  20674. private _instancesBufferSize;
  20675. private _instancesBuffer;
  20676. private _instancesData;
  20677. private _overridenInstanceCount;
  20678. private _effectiveMaterial;
  20679. _shouldGenerateFlatShading: boolean;
  20680. private _preActivateId;
  20681. _originalBuilderSideOrientation: number;
  20682. overrideMaterialSideOrientation: Nullable<number>;
  20683. private _areNormalsFrozen;
  20684. private _sourcePositions;
  20685. private _sourceNormals;
  20686. private _source;
  20687. readonly source: Nullable<Mesh>;
  20688. isUnIndexed: boolean;
  20689. /**
  20690. * @constructor
  20691. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  20692. * @param {Scene} scene The scene to add this mesh to.
  20693. * @param {Node} parent The parent of this mesh, if it has one
  20694. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  20695. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20696. * When false, achieved by calling a clone(), also passing False.
  20697. * This will make creation of children, recursive.
  20698. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20699. */
  20700. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20701. /**
  20702. * Returns the string "Mesh".
  20703. */
  20704. getClassName(): string;
  20705. /**
  20706. * Returns a string.
  20707. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  20708. */
  20709. toString(fullDetails?: boolean): string;
  20710. _unBindEffect(): void;
  20711. /**
  20712. * True if the mesh has some Levels Of Details (LOD).
  20713. * Returns a boolean.
  20714. */
  20715. readonly hasLODLevels: boolean;
  20716. /**
  20717. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  20718. * @returns an array of {BABYLON.MeshLODLevel}
  20719. */
  20720. getLODLevels(): MeshLODLevel[];
  20721. private _sortLODLevels();
  20722. /**
  20723. * Add a mesh as LOD level triggered at the given distance.
  20724. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20725. * @param {number} distance The distance from the center of the object to show this level
  20726. * @param {Mesh} mesh The mesh to be added as LOD level
  20727. * @return {Mesh} This mesh (for chaining)
  20728. */
  20729. addLODLevel(distance: number, mesh: Mesh): Mesh;
  20730. /**
  20731. * Returns the LOD level mesh at the passed distance or null if not found.
  20732. * It is related to the method `addLODLevel(distance, mesh)`.
  20733. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20734. * Returns an object Mesh or `null`.
  20735. */
  20736. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20737. /**
  20738. * Remove a mesh from the LOD array
  20739. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20740. * @param {Mesh} mesh The mesh to be removed.
  20741. * @return {Mesh} This mesh (for chaining)
  20742. */
  20743. removeLODLevel(mesh: Mesh): Mesh;
  20744. /**
  20745. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20746. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20747. */
  20748. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  20749. /**
  20750. * Returns the mesh internal Geometry object.
  20751. */
  20752. readonly geometry: Nullable<Geometry>;
  20753. /**
  20754. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20755. */
  20756. getTotalVertices(): number;
  20757. /**
  20758. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  20759. * 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.
  20760. * You can force the copy with forceCopy === true
  20761. * Returns null if the mesh has no geometry or no vertex buffer.
  20762. * Possible `kind` values :
  20763. * - BABYLON.VertexBuffer.PositionKind
  20764. * - BABYLON.VertexBuffer.UVKind
  20765. * - BABYLON.VertexBuffer.UV2Kind
  20766. * - BABYLON.VertexBuffer.UV3Kind
  20767. * - BABYLON.VertexBuffer.UV4Kind
  20768. * - BABYLON.VertexBuffer.UV5Kind
  20769. * - BABYLON.VertexBuffer.UV6Kind
  20770. * - BABYLON.VertexBuffer.ColorKind
  20771. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20772. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20773. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20774. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20775. */
  20776. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20777. /**
  20778. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  20779. * Returns `null` if the mesh has no geometry.
  20780. * Possible `kind` values :
  20781. * - BABYLON.VertexBuffer.PositionKind
  20782. * - BABYLON.VertexBuffer.UVKind
  20783. * - BABYLON.VertexBuffer.UV2Kind
  20784. * - BABYLON.VertexBuffer.UV3Kind
  20785. * - BABYLON.VertexBuffer.UV4Kind
  20786. * - BABYLON.VertexBuffer.UV5Kind
  20787. * - BABYLON.VertexBuffer.UV6Kind
  20788. * - BABYLON.VertexBuffer.ColorKind
  20789. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20790. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20791. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20792. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20793. */
  20794. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20795. /**
  20796. * Returns a boolean depending on the existence of the Vertex Data for the requested `kind`.
  20797. * Possible `kind` values :
  20798. * - BABYLON.VertexBuffer.PositionKind
  20799. * - BABYLON.VertexBuffer.UVKind
  20800. * - BABYLON.VertexBuffer.UV2Kind
  20801. * - BABYLON.VertexBuffer.UV3Kind
  20802. * - BABYLON.VertexBuffer.UV4Kind
  20803. * - BABYLON.VertexBuffer.UV5Kind
  20804. * - BABYLON.VertexBuffer.UV6Kind
  20805. * - BABYLON.VertexBuffer.ColorKind
  20806. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20807. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20808. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20809. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20810. */
  20811. isVerticesDataPresent(kind: string): boolean;
  20812. /**
  20813. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20814. * Possible `kind` values :
  20815. * - BABYLON.VertexBuffer.PositionKind
  20816. * - BABYLON.VertexBuffer.UVKind
  20817. * - BABYLON.VertexBuffer.UV2Kind
  20818. * - BABYLON.VertexBuffer.UV3Kind
  20819. * - BABYLON.VertexBuffer.UV4Kind
  20820. * - BABYLON.VertexBuffer.UV5Kind
  20821. * - BABYLON.VertexBuffer.UV6Kind
  20822. * - BABYLON.VertexBuffer.ColorKind
  20823. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20824. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20825. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20826. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20827. */
  20828. isVertexBufferUpdatable(kind: string): boolean;
  20829. /**
  20830. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  20831. * Possible `kind` values :
  20832. * - BABYLON.VertexBuffer.PositionKind
  20833. * - BABYLON.VertexBuffer.UVKind
  20834. * - BABYLON.VertexBuffer.UV2Kind
  20835. * - BABYLON.VertexBuffer.UV3Kind
  20836. * - BABYLON.VertexBuffer.UV4Kind
  20837. * - BABYLON.VertexBuffer.UV5Kind
  20838. * - BABYLON.VertexBuffer.UV6Kind
  20839. * - BABYLON.VertexBuffer.ColorKind
  20840. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20841. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20842. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20843. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20844. */
  20845. getVerticesDataKinds(): string[];
  20846. /**
  20847. * Returns a positive integer : the total number of indices in this mesh geometry.
  20848. * Returns zero if the mesh has no geometry.
  20849. */
  20850. getTotalIndices(): number;
  20851. /**
  20852. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20853. * If the parameter `copyWhenShared` is true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  20854. * Returns an empty array if the mesh has no geometry.
  20855. */
  20856. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  20857. readonly isBlocked: boolean;
  20858. /**
  20859. * Determine if the current mesh is ready to be rendered
  20860. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20861. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20862. * @returns true if all associated assets are ready (material, textures, shaders)
  20863. */
  20864. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20865. /**
  20866. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  20867. * This property is pertinent only for updatable parametric shapes.
  20868. */
  20869. readonly areNormalsFrozen: boolean;
  20870. /**
  20871. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  20872. * It has no effect at all on other shapes.
  20873. * It prevents the mesh normals from being recomputed on next `positions` array update.
  20874. * Returns the Mesh.
  20875. */
  20876. freezeNormals(): Mesh;
  20877. /**
  20878. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  20879. * It has no effect at all on other shapes.
  20880. * It reactivates the mesh normals computation if it was previously frozen.
  20881. * Returns the Mesh.
  20882. */
  20883. unfreezeNormals(): Mesh;
  20884. /**
  20885. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20886. */
  20887. overridenInstanceCount: number;
  20888. _preActivate(): Mesh;
  20889. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20890. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20891. /**
  20892. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20893. * This means the mesh underlying bounding box and sphere are recomputed.
  20894. * Returns the Mesh.
  20895. */
  20896. refreshBoundingInfo(): Mesh;
  20897. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  20898. private _getPositionData(applySkeleton);
  20899. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20900. subdivide(count: number): void;
  20901. /**
  20902. * Sets the vertex data of the mesh geometry for the requested `kind`.
  20903. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  20904. * The `data` are either a numeric array either a Float32Array.
  20905. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  20906. * 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).
  20907. * Note that a new underlying VertexBuffer object is created each call.
  20908. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  20909. *
  20910. * Possible `kind` values :
  20911. * - BABYLON.VertexBuffer.PositionKind
  20912. * - BABYLON.VertexBuffer.UVKind
  20913. * - BABYLON.VertexBuffer.UV2Kind
  20914. * - BABYLON.VertexBuffer.UV3Kind
  20915. * - BABYLON.VertexBuffer.UV4Kind
  20916. * - BABYLON.VertexBuffer.UV5Kind
  20917. * - BABYLON.VertexBuffer.UV6Kind
  20918. * - BABYLON.VertexBuffer.ColorKind
  20919. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20920. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20921. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20922. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20923. *
  20924. * Returns the Mesh.
  20925. */
  20926. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20927. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20928. /**
  20929. * Sets the mesh VertexBuffer.
  20930. * Returns the Mesh.
  20931. */
  20932. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20933. /**
  20934. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  20935. * If the mesh has no geometry, it is simply returned as it is.
  20936. * The `data` are either a numeric array either a Float32Array.
  20937. * No new underlying VertexBuffer object is created.
  20938. * 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.
  20939. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  20940. *
  20941. * Possible `kind` values :
  20942. * - BABYLON.VertexBuffer.PositionKind
  20943. * - BABYLON.VertexBuffer.UVKind
  20944. * - BABYLON.VertexBuffer.UV2Kind
  20945. * - BABYLON.VertexBuffer.UV3Kind
  20946. * - BABYLON.VertexBuffer.UV4Kind
  20947. * - BABYLON.VertexBuffer.UV5Kind
  20948. * - BABYLON.VertexBuffer.UV6Kind
  20949. * - BABYLON.VertexBuffer.ColorKind
  20950. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20951. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20952. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20953. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20954. *
  20955. * Returns the Mesh.
  20956. */
  20957. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20958. /**
  20959. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20960. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20961. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  20962. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  20963. * Returns the Mesh.
  20964. */
  20965. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20966. /**
  20967. * Creates a un-shared specific occurence of the geometry for the mesh.
  20968. * Returns the Mesh.
  20969. */
  20970. makeGeometryUnique(): Mesh;
  20971. /**
  20972. * Sets the mesh indices.
  20973. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  20974. * Type is Uint16Array by default unless the mesh has more than 65536 vertices.
  20975. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  20976. * This method creates a new index buffer each call.
  20977. * Returns the Mesh.
  20978. */
  20979. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20980. /**
  20981. * Update the current index buffer
  20982. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  20983. * Returns the Mesh.
  20984. */
  20985. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20986. /**
  20987. * Invert the geometry to move from a right handed system to a left handed one.
  20988. * Returns the Mesh.
  20989. */
  20990. toLeftHanded(): Mesh;
  20991. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20992. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20993. /**
  20994. * Registers for this mesh a javascript function called just before the rendering process.
  20995. * This function is passed the current mesh.
  20996. * Return the Mesh.
  20997. */
  20998. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20999. /**
  21000. * Disposes a previously registered javascript function called before the rendering.
  21001. * This function is passed the current mesh.
  21002. * Returns the Mesh.
  21003. */
  21004. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21005. /**
  21006. * Registers for this mesh a javascript function called just after the rendering is complete.
  21007. * This function is passed the current mesh.
  21008. * Returns the Mesh.
  21009. */
  21010. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21011. /**
  21012. * Disposes a previously registered javascript function called after the rendering.
  21013. * This function is passed the current mesh.
  21014. * Return the Mesh.
  21015. */
  21016. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21017. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21018. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21019. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21020. /**
  21021. * Triggers the draw call for the mesh.
  21022. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  21023. * Returns the Mesh.
  21024. */
  21025. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21026. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  21027. /**
  21028. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  21029. */
  21030. getEmittedParticleSystems(): IParticleSystem[];
  21031. /**
  21032. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  21033. */
  21034. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  21035. _checkDelayState(): Mesh;
  21036. private _queueLoad(scene);
  21037. /**
  21038. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  21039. */
  21040. isInFrustum(frustumPlanes: Plane[]): boolean;
  21041. /**
  21042. * Sets the mesh material by the material or multiMaterial `id` property.
  21043. * The material `id` is a string identifying the material or the multiMaterial.
  21044. * This method returns the Mesh.
  21045. */
  21046. setMaterialByID(id: string): Mesh;
  21047. /**
  21048. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21049. */
  21050. getAnimatables(): IAnimatable[];
  21051. /**
  21052. * Modifies the mesh geometry according to the passed transformation matrix.
  21053. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21054. * The mesh normals are modified accordingly the same transformation.
  21055. * tuto : http://doc.babylonjs.com/tutorials/How_Rotations_and_Translations_Work#baking-transform
  21056. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21057. * Returns the Mesh.
  21058. */
  21059. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21060. /**
  21061. * Modifies the mesh geometry according to its own current World Matrix.
  21062. * The mesh World Matrix is then reset.
  21063. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21064. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  21065. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21066. * Returns the Mesh.
  21067. */
  21068. bakeCurrentTransformIntoVertices(): Mesh;
  21069. readonly _positions: Nullable<Vector3[]>;
  21070. _resetPointsArrayCache(): Mesh;
  21071. _generatePointsArray(): boolean;
  21072. /**
  21073. * Returns a new Mesh object generated from the current mesh properties.
  21074. * This method must not get confused with createInstance().
  21075. * The parameter `name` is a string, the name given to the new mesh.
  21076. * The optional parameter `newParent` can be any Node object (default `null`).
  21077. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  21078. * 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.
  21079. */
  21080. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21081. /**
  21082. * Releases resources associated with this mesh.
  21083. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21084. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21085. */
  21086. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21087. /**
  21088. * Modifies the mesh geometry according to a displacement map.
  21089. * 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.
  21090. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21091. * This method returns nothing.
  21092. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  21093. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21094. * The parameter `onSuccess` is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  21095. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21096. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21097. *
  21098. * Returns the Mesh.
  21099. */
  21100. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21101. /**
  21102. * Modifies the mesh geometry according to a displacementMap buffer.
  21103. * 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.
  21104. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21105. * This method returns nothing.
  21106. * The parameter `buffer` is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21107. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  21108. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21109. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21110. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21111. *
  21112. * Returns the Mesh.
  21113. */
  21114. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21115. /**
  21116. * Modify the mesh to get a flat shading rendering.
  21117. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21118. * This method returns the Mesh.
  21119. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21120. */
  21121. convertToFlatShadedMesh(): Mesh;
  21122. /**
  21123. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21124. * In other words, more vertices, no more indices and a single bigger VBO.
  21125. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21126. * Returns the Mesh.
  21127. */
  21128. convertToUnIndexedMesh(): Mesh;
  21129. /**
  21130. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  21131. * This method returns the Mesh.
  21132. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21133. */
  21134. flipFaces(flipNormals?: boolean): Mesh;
  21135. /**
  21136. * Creates a new InstancedMesh object from the mesh model.
  21137. * An instance shares the same properties and the same material than its model.
  21138. * Only these properties of each instance can then be set individually :
  21139. * - position
  21140. * - rotation
  21141. * - rotationQuaternion
  21142. * - setPivotMatrix
  21143. * - scaling
  21144. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  21145. * Warning : this method is not supported for Line mesh and LineSystem
  21146. */
  21147. createInstance(name: string): InstancedMesh;
  21148. /**
  21149. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21150. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21151. * This method returns the Mesh.
  21152. */
  21153. synchronizeInstances(): Mesh;
  21154. /**
  21155. * Simplify the mesh according to the given array of settings.
  21156. * Function will return immediately and will simplify async. It returns the Mesh.
  21157. * @param settings a collection of simplification settings.
  21158. * @param parallelProcessing should all levels calculate parallel or one after the other.
  21159. * @param type the type of simplification to run.
  21160. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  21161. */
  21162. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  21163. /**
  21164. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21165. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21166. * This should be used together with the simplification to avoid disappearing triangles.
  21167. * Returns the Mesh.
  21168. * @param successCallback an optional success callback to be called after the optimization finished.
  21169. */
  21170. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21171. serialize(serializationObject: any): void;
  21172. _syncGeometryWithMorphTargetManager(): void;
  21173. /**
  21174. * Returns a new Mesh object parsed from the source provided.
  21175. * The parameter `parsedMesh` is the source.
  21176. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  21177. */
  21178. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21179. /**
  21180. * Creates a ribbon mesh.
  21181. * Please consider using the same method from the MeshBuilder class instead.
  21182. * The ribbon is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21183. *
  21184. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21185. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21186. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  21187. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  21188. * 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.
  21189. * 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.
  21190. * 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
  21191. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21192. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21193. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21194. */
  21195. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21196. /**
  21197. * Creates a plane polygonal mesh. By default, this is a disc.
  21198. * Please consider using the same method from the MeshBuilder class instead.
  21199. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  21200. * 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.
  21201. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21202. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21203. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21204. */
  21205. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21206. /**
  21207. * Creates a box mesh.
  21208. * Please consider using the same method from the MeshBuilder class instead.
  21209. * The parameter `size` sets the size (float) of each box side (default 1).
  21210. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21211. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21212. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21213. */
  21214. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21215. /**
  21216. * Creates a sphere mesh.
  21217. * Please consider using the same method from the MeshBuilder class instead.
  21218. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  21219. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  21220. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21221. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21222. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21223. */
  21224. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21225. /**
  21226. * Creates a cylinder or a cone mesh.
  21227. * Please consider using the same method from the MeshBuilder class instead.
  21228. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21229. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21230. * 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.
  21231. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21232. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21233. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21234. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21235. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21236. */
  21237. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21238. /**
  21239. * Creates a torus mesh.
  21240. * Please consider using the same method from the MeshBuilder class instead.
  21241. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  21242. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  21243. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  21244. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21245. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21246. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21247. */
  21248. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21249. /**
  21250. * Creates a torus knot mesh.
  21251. * Please consider using the same method from the MeshBuilder class instead.
  21252. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  21253. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  21254. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  21255. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  21256. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21257. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21258. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21259. */
  21260. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21261. /**
  21262. * Creates a line mesh.
  21263. * Please consider using the same method from the MeshBuilder class instead.
  21264. * 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.
  21265. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21266. * The parameter `points` is an array successive Vector3.
  21267. * 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
  21268. * When updating an instance, remember that only point positions can change, not the number of points.
  21269. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21270. */
  21271. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21272. /**
  21273. * Creates a dashed line mesh.
  21274. * Please consider using the same method from the MeshBuilder class instead.
  21275. * 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.
  21276. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21277. * The parameter `points` is an array successive Vector3.
  21278. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  21279. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  21280. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  21281. * 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
  21282. * When updating an instance, remember that only point positions can change, not the number of points.
  21283. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21284. */
  21285. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21286. /**
  21287. * Creates a polygon mesh.
  21288. * Please consider using the same method from the MeshBuilder class instead.
  21289. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21290. * 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.
  21291. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21292. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21293. * Remember you can only change the shape positions, not their number when updating a polygon.
  21294. */
  21295. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21296. /**
  21297. * Creates an extruded polygon mesh, with depth in the Y direction.
  21298. * Please consider using the same method from the MeshBuilder class instead.
  21299. */
  21300. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21301. /**
  21302. * Creates an extruded shape mesh.
  21303. * The extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21304. * Please consider using the same method from the MeshBuilder class instead.
  21305. *
  21306. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  21307. * 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
  21308. * extruded along the Z axis.
  21309. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21310. * 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.
  21311. * The parameter `scale` (float, default 1) is the value to scale the shape.
  21312. * 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
  21313. * 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
  21314. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21315. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21316. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21317. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21318. */
  21319. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21320. /**
  21321. * Creates an custom extruded shape mesh.
  21322. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21323. * Please consider using the same method from the MeshBuilder class instead.
  21324. *
  21325. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  21326. * 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
  21327. * extruded along the Z axis.
  21328. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21329. * 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
  21330. * and the distance of this point from the begining of the path :
  21331. * ```javascript
  21332. * var rotationFunction = function(i, distance) {
  21333. * // do things
  21334. * return rotationValue; }
  21335. * ```
  21336. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  21337. * 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
  21338. * and the distance of this point from the begining of the path :
  21339. * ```javascript
  21340. * var scaleFunction = function(i, distance) {
  21341. * // do things
  21342. * return scaleValue;}
  21343. * ```
  21344. * It must returns a float value that will be the scale value applied to the shape on each path point.
  21345. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  21346. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  21347. * 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
  21348. * 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
  21349. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21350. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21351. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21352. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21353. */
  21354. 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;
  21355. /**
  21356. * Creates lathe mesh.
  21357. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21358. * Please consider using the same method from the MeshBuilder class instead.
  21359. * 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
  21360. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  21361. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  21362. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  21363. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21364. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21365. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21366. */
  21367. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21368. /**
  21369. * Creates a plane mesh.
  21370. * Please consider using the same method from the MeshBuilder class instead.
  21371. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  21372. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21373. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21374. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21375. */
  21376. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21377. /**
  21378. * Creates a ground mesh.
  21379. * Please consider using the same method from the MeshBuilder class instead.
  21380. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  21381. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  21382. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21383. */
  21384. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21385. /**
  21386. * Creates a tiled ground mesh.
  21387. * Please consider using the same method from the MeshBuilder class instead.
  21388. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  21389. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  21390. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  21391. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  21392. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  21393. * numbers of subdivisions on the ground width and height of each tile.
  21394. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21395. */
  21396. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21397. w: number;
  21398. h: number;
  21399. }, precision: {
  21400. w: number;
  21401. h: number;
  21402. }, scene: Scene, updatable?: boolean): Mesh;
  21403. /**
  21404. * Creates a ground mesh from a height map.
  21405. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  21406. * Please consider using the same method from the MeshBuilder class instead.
  21407. * The parameter `url` sets the URL of the height map image resource.
  21408. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  21409. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  21410. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  21411. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  21412. * 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).
  21413. * This function is passed the newly built mesh :
  21414. * ```javascript
  21415. * function(mesh) { // do things
  21416. * return; }
  21417. * ```
  21418. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21419. */
  21420. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void): GroundMesh;
  21421. /**
  21422. * Creates a tube mesh.
  21423. * The tube is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21424. * Please consider using the same method from the MeshBuilder class instead.
  21425. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  21426. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  21427. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  21428. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  21429. * 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.
  21430. * It must return a radius value (positive float) :
  21431. * ```javascript
  21432. * var radiusFunction = function(i, distance) {
  21433. * // do things
  21434. * return radius; }
  21435. * ```
  21436. * 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
  21437. * 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
  21438. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21439. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21440. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21441. */
  21442. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21443. (i: number, distance: number): number;
  21444. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21445. /**
  21446. * Creates a polyhedron mesh.
  21447. * Please consider using the same method from the MeshBuilder class instead.
  21448. * 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
  21449. * to choose the wanted type.
  21450. * The parameter `size` (positive float, default 1) sets the polygon size.
  21451. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  21452. * 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`.
  21453. * 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
  21454. * 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)`).
  21455. * 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
  21456. * 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.
  21457. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21458. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21459. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21460. */
  21461. static CreatePolyhedron(name: string, options: {
  21462. type?: number;
  21463. size?: number;
  21464. sizeX?: number;
  21465. sizeY?: number;
  21466. sizeZ?: number;
  21467. custom?: any;
  21468. faceUV?: Vector4[];
  21469. faceColors?: Color4[];
  21470. updatable?: boolean;
  21471. sideOrientation?: number;
  21472. }, scene: Scene): Mesh;
  21473. /**
  21474. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  21475. * Please consider using the same method from the MeshBuilder class instead.
  21476. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  21477. * 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`).
  21478. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  21479. * 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.
  21480. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21481. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  21482. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21483. */
  21484. static CreateIcoSphere(name: string, options: {
  21485. radius?: number;
  21486. flat?: boolean;
  21487. subdivisions?: number;
  21488. sideOrientation?: number;
  21489. updatable?: boolean;
  21490. }, scene: Scene): Mesh;
  21491. /**
  21492. * Creates a decal mesh.
  21493. * Please consider using the same method from the MeshBuilder class instead.
  21494. * 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.
  21495. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  21496. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  21497. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  21498. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  21499. */
  21500. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21501. /**
  21502. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21503. */
  21504. setPositionsForCPUSkinning(): Float32Array;
  21505. /**
  21506. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21507. */
  21508. setNormalsForCPUSkinning(): Float32Array;
  21509. /**
  21510. * Updates the vertex buffer by applying transformation from the bones.
  21511. * Returns the Mesh.
  21512. *
  21513. * @param {skeleton} skeleton to apply
  21514. */
  21515. applySkeleton(skeleton: Skeleton): Mesh;
  21516. /**
  21517. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  21518. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  21519. */
  21520. static MinMax(meshes: AbstractMesh[]): {
  21521. min: Vector3;
  21522. max: Vector3;
  21523. };
  21524. /**
  21525. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  21526. */
  21527. static Center(meshesOrMinMaxVector: {
  21528. min: Vector3;
  21529. max: Vector3;
  21530. } | AbstractMesh[]): Vector3;
  21531. /**
  21532. * Merge the array of meshes into a single mesh for performance reasons.
  21533. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  21534. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  21535. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  21536. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21537. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  21538. */
  21539. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  21540. }
  21541. }
  21542. declare module BABYLON {
  21543. /**
  21544. * Define an interface for all classes that will get and set the data on vertices
  21545. */
  21546. interface IGetSetVerticesData {
  21547. isVerticesDataPresent(kind: string): boolean;
  21548. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21549. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  21550. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21551. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21552. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21553. }
  21554. /**
  21555. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21556. */
  21557. class VertexData {
  21558. /**
  21559. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21560. */
  21561. positions: Nullable<FloatArray>;
  21562. /**
  21563. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21564. */
  21565. normals: Nullable<FloatArray>;
  21566. /**
  21567. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21568. */
  21569. tangents: Nullable<FloatArray>;
  21570. /**
  21571. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21572. */
  21573. uvs: Nullable<FloatArray>;
  21574. /**
  21575. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21576. */
  21577. uvs2: Nullable<FloatArray>;
  21578. /**
  21579. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21580. */
  21581. uvs3: Nullable<FloatArray>;
  21582. /**
  21583. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21584. */
  21585. uvs4: Nullable<FloatArray>;
  21586. /**
  21587. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21588. */
  21589. uvs5: Nullable<FloatArray>;
  21590. /**
  21591. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21592. */
  21593. uvs6: Nullable<FloatArray>;
  21594. /**
  21595. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21596. */
  21597. colors: Nullable<FloatArray>;
  21598. /**
  21599. * 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).
  21600. */
  21601. matricesIndices: Nullable<FloatArray>;
  21602. /**
  21603. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21604. */
  21605. matricesWeights: Nullable<FloatArray>;
  21606. /**
  21607. * An array extending the number of possible indices
  21608. */
  21609. matricesIndicesExtra: Nullable<FloatArray>;
  21610. /**
  21611. * An array extending the number of possible weights when the number of indices is extended
  21612. */
  21613. matricesWeightsExtra: Nullable<FloatArray>;
  21614. /**
  21615. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21616. */
  21617. indices: Nullable<IndicesArray>;
  21618. /**
  21619. * Uses the passed data array to set the set the values for the specified kind of data
  21620. * @param data a linear array of floating numbers
  21621. * @param kind the type of data that is being set, eg positions, colors etc
  21622. */
  21623. set(data: FloatArray, kind: string): void;
  21624. /**
  21625. * Associates the vertexData to the passed Mesh.
  21626. * Sets it as updatable or not (default `false`)
  21627. * @param mesh the mesh the vertexData is applied to
  21628. * @param updatable when used and having the value true allows new data to update the vertexData
  21629. * @returns the VertexData
  21630. */
  21631. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21632. /**
  21633. * Associates the vertexData to the passed Geometry.
  21634. * Sets it as updatable or not (default `false`)
  21635. * @param geometry the geometry the vertexData is applied to
  21636. * @param updatable when used and having the value true allows new data to update the vertexData
  21637. * @returns VertexData
  21638. */
  21639. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21640. /**
  21641. * Updates the associated mesh
  21642. * @param mesh the mesh to be updated
  21643. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21644. * @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
  21645. * @returns VertexData
  21646. */
  21647. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  21648. /**
  21649. * Updates the associated geometry
  21650. * @param geometry the geometry to be updated
  21651. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21652. * @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
  21653. * @returns VertexData.
  21654. */
  21655. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  21656. private _applyTo(meshOrGeometry, updatable?);
  21657. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  21658. /**
  21659. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21660. * @param matrix the transforming matrix
  21661. * @returns the VertexData
  21662. */
  21663. transform(matrix: Matrix): VertexData;
  21664. /**
  21665. * Merges the passed VertexData into the current one
  21666. * @param other the VertexData to be merged into the current one
  21667. * @returns the modified VertexData
  21668. */
  21669. merge(other: VertexData): VertexData;
  21670. private _mergeElement(source, other);
  21671. private _validate();
  21672. /**
  21673. * Serializes the VertexData
  21674. * @returns a serialized object
  21675. */
  21676. serialize(): any;
  21677. /**
  21678. * Extracts the vertexData from a mesh
  21679. * @param mesh the mesh from which to extract the VertexData
  21680. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21681. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21682. * @returns the object VertexData associated to the passed mesh
  21683. */
  21684. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21685. /**
  21686. * Extracts the vertexData from the geometry
  21687. * @param geometry the geometry from which to extract the VertexData
  21688. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21689. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21690. * @returns the object VertexData associated to the passed mesh
  21691. */
  21692. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21693. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  21694. /**
  21695. * Creates the VertexData for a Ribbon
  21696. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21697. * * pathArray array of paths, each of which an array of successive Vector3
  21698. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21699. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21700. * * 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
  21701. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21702. * * 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)
  21703. * * 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)
  21704. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21705. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21706. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21707. * @returns the VertexData of the ribbon
  21708. */
  21709. static CreateRibbon(options: {
  21710. pathArray: Vector3[][];
  21711. closeArray?: boolean;
  21712. closePath?: boolean;
  21713. offset?: number;
  21714. sideOrientation?: number;
  21715. frontUVs?: Vector4;
  21716. backUVs?: Vector4;
  21717. invertUV?: boolean;
  21718. uvs?: Vector2[];
  21719. colors?: Color4[];
  21720. }): VertexData;
  21721. /**
  21722. * Creates the VertexData for a box
  21723. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21724. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21725. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21726. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21727. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21728. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21729. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21730. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21731. * * 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)
  21732. * * 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)
  21733. * @returns the VertexData of the box
  21734. */
  21735. static CreateBox(options: {
  21736. size?: number;
  21737. width?: number;
  21738. height?: number;
  21739. depth?: number;
  21740. faceUV?: Vector4[];
  21741. faceColors?: Color4[];
  21742. sideOrientation?: number;
  21743. frontUVs?: Vector4;
  21744. backUVs?: Vector4;
  21745. }): VertexData;
  21746. /**
  21747. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21748. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21749. * * segments sets the number of horizontal strips optional, default 32
  21750. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21751. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21752. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21753. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21754. * * 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
  21755. * * 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
  21756. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21757. * * 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)
  21758. * * 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)
  21759. * @returns the VertexData of the ellipsoid
  21760. */
  21761. static CreateSphere(options: {
  21762. segments?: number;
  21763. diameter?: number;
  21764. diameterX?: number;
  21765. diameterY?: number;
  21766. diameterZ?: number;
  21767. arc?: number;
  21768. slice?: number;
  21769. sideOrientation?: number;
  21770. frontUVs?: Vector4;
  21771. backUVs?: Vector4;
  21772. }): VertexData;
  21773. /**
  21774. * Creates the VertexData for a cylinder, cone or prism
  21775. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21776. * * height sets the height (y direction) of the cylinder, optional, default 2
  21777. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21778. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21779. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21780. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21781. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21782. * * 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
  21783. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21784. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21785. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21786. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21787. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21788. * * 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)
  21789. * * 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)
  21790. * @returns the VertexData of the cylinder, cone or prism
  21791. */
  21792. static CreateCylinder(options: {
  21793. height?: number;
  21794. diameterTop?: number;
  21795. diameterBottom?: number;
  21796. diameter?: number;
  21797. tessellation?: number;
  21798. subdivisions?: number;
  21799. arc?: number;
  21800. faceColors?: Color4[];
  21801. faceUV?: Vector4[];
  21802. hasRings?: boolean;
  21803. enclose?: boolean;
  21804. sideOrientation?: number;
  21805. frontUVs?: Vector4;
  21806. backUVs?: Vector4;
  21807. }): VertexData;
  21808. /**
  21809. * Creates the VertexData for a torus
  21810. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21811. * * diameter the diameter of the torus, optional default 1
  21812. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21813. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21814. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21815. * * 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)
  21816. * * 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)
  21817. * @returns the VertexData of the torus
  21818. */
  21819. static CreateTorus(options: {
  21820. diameter?: number;
  21821. thickness?: number;
  21822. tessellation?: number;
  21823. sideOrientation?: number;
  21824. frontUVs?: Vector4;
  21825. backUVs?: Vector4;
  21826. }): VertexData;
  21827. /**
  21828. * Creates the VertexData of the LineSystem
  21829. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21830. * - lines an array of lines, each line being an array of successive Vector3
  21831. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21832. * @returns the VertexData of the LineSystem
  21833. */
  21834. static CreateLineSystem(options: {
  21835. lines: Vector3[][];
  21836. colors?: Nullable<Color4[][]>;
  21837. }): VertexData;
  21838. /**
  21839. * Create the VertexData for a DashedLines
  21840. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21841. * - points an array successive Vector3
  21842. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21843. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21844. * - dashNb the intended total number of dashes, optional, default 200
  21845. * @returns the VertexData for the DashedLines
  21846. */
  21847. static CreateDashedLines(options: {
  21848. points: Vector3[];
  21849. dashSize?: number;
  21850. gapSize?: number;
  21851. dashNb?: number;
  21852. }): VertexData;
  21853. /**
  21854. * Creates the VertexData for a Ground
  21855. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21856. * - width the width (x direction) of the ground, optional, default 1
  21857. * - height the height (z direction) of the ground, optional, default 1
  21858. * - subdivisions the number of subdivisions per side, optional, default 1
  21859. * @returns the VertexData of the Ground
  21860. */
  21861. static CreateGround(options: {
  21862. width?: number;
  21863. height?: number;
  21864. subdivisions?: number;
  21865. subdivisionsX?: number;
  21866. subdivisionsY?: number;
  21867. }): VertexData;
  21868. /**
  21869. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21870. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21871. * * xmin the ground minimum X coordinate, optional, default -1
  21872. * * zmin the ground minimum Z coordinate, optional, default -1
  21873. * * xmax the ground maximum X coordinate, optional, default 1
  21874. * * zmax the ground maximum Z coordinate, optional, default 1
  21875. * * 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}
  21876. * * 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}
  21877. * @returns the VertexData of the TiledGround
  21878. */
  21879. static CreateTiledGround(options: {
  21880. xmin: number;
  21881. zmin: number;
  21882. xmax: number;
  21883. zmax: number;
  21884. subdivisions?: {
  21885. w: number;
  21886. h: number;
  21887. };
  21888. precision?: {
  21889. w: number;
  21890. h: number;
  21891. };
  21892. }): VertexData;
  21893. /**
  21894. * Creates the VertexData of the Ground designed from a heightmap
  21895. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21896. * * width the width (x direction) of the ground
  21897. * * height the height (z direction) of the ground
  21898. * * subdivisions the number of subdivisions per side
  21899. * * minHeight the minimum altitude on the ground, optional, default 0
  21900. * * maxHeight the maximum altitude on the ground, optional default 1
  21901. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21902. * * buffer the array holding the image color data
  21903. * * bufferWidth the width of image
  21904. * * bufferHeight the height of image
  21905. * @returns the VertexData of the Ground designed from a heightmap
  21906. */
  21907. static CreateGroundFromHeightMap(options: {
  21908. width: number;
  21909. height: number;
  21910. subdivisions: number;
  21911. minHeight: number;
  21912. maxHeight: number;
  21913. colorFilter: Color3;
  21914. buffer: Uint8Array;
  21915. bufferWidth: number;
  21916. bufferHeight: number;
  21917. }): VertexData;
  21918. /**
  21919. * Creates the VertexData for a Plane
  21920. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21921. * * size sets the width and height of the plane to the value of size, optional default 1
  21922. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21923. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21924. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21925. * * 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)
  21926. * * 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)
  21927. * @returns the VertexData of the box
  21928. */
  21929. static CreatePlane(options: {
  21930. size?: number;
  21931. width?: number;
  21932. height?: number;
  21933. sideOrientation?: number;
  21934. frontUVs?: Vector4;
  21935. backUVs?: Vector4;
  21936. }): VertexData;
  21937. /**
  21938. * Creates the VertexData of the Disc or regular Polygon
  21939. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21940. * * radius the radius of the disc, optional default 0.5
  21941. * * tessellation the number of polygon sides, optional, default 64
  21942. * * 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
  21943. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21944. * * 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)
  21945. * * 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)
  21946. * @returns the VertexData of the box
  21947. */
  21948. static CreateDisc(options: {
  21949. radius?: number;
  21950. tessellation?: number;
  21951. arc?: number;
  21952. sideOrientation?: number;
  21953. frontUVs?: Vector4;
  21954. backUVs?: Vector4;
  21955. }): VertexData;
  21956. /**
  21957. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21958. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21959. * @param polygon a mesh built from polygonTriangulation.build()
  21960. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21961. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21962. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21963. * @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)
  21964. * @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)
  21965. * @returns the VertexData of the Polygon
  21966. */
  21967. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21968. /**
  21969. * Creates the VertexData of the IcoSphere
  21970. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21971. * * radius the radius of the IcoSphere, optional default 1
  21972. * * radiusX allows stretching in the x direction, optional, default radius
  21973. * * radiusY allows stretching in the y direction, optional, default radius
  21974. * * radiusZ allows stretching in the z direction, optional, default radius
  21975. * * flat when true creates a flat shaded mesh, optional, default true
  21976. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21977. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21978. * * 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)
  21979. * * 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)
  21980. * @returns the VertexData of the IcoSphere
  21981. */
  21982. static CreateIcoSphere(options: {
  21983. radius?: number;
  21984. radiusX?: number;
  21985. radiusY?: number;
  21986. radiusZ?: number;
  21987. flat?: boolean;
  21988. subdivisions?: number;
  21989. sideOrientation?: number;
  21990. frontUVs?: Vector4;
  21991. backUVs?: Vector4;
  21992. }): VertexData;
  21993. /**
  21994. * Creates the VertexData for a Polyhedron
  21995. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21996. * * type provided types are:
  21997. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21998. * * 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)
  21999. * * size the size of the IcoSphere, optional default 1
  22000. * * sizeX allows stretching in the x direction, optional, default size
  22001. * * sizeY allows stretching in the y direction, optional, default size
  22002. * * sizeZ allows stretching in the z direction, optional, default size
  22003. * * 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
  22004. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22005. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22006. * * flat when true creates a flat shaded mesh, optional, default true
  22007. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22008. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22009. * * 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)
  22010. * * 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)
  22011. * @returns the VertexData of the Polyhedron
  22012. */
  22013. static CreatePolyhedron(options: {
  22014. type?: number;
  22015. size?: number;
  22016. sizeX?: number;
  22017. sizeY?: number;
  22018. sizeZ?: number;
  22019. custom?: any;
  22020. faceUV?: Vector4[];
  22021. faceColors?: Color4[];
  22022. flat?: boolean;
  22023. sideOrientation?: number;
  22024. frontUVs?: Vector4;
  22025. backUVs?: Vector4;
  22026. }): VertexData;
  22027. /**
  22028. * Creates the VertexData for a TorusKnot
  22029. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22030. * * radius the radius of the torus knot, optional, default 2
  22031. * * tube the thickness of the tube, optional, default 0.5
  22032. * * radialSegments the number of sides on each tube segments, optional, default 32
  22033. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22034. * * p the number of windings around the z axis, optional, default 2
  22035. * * q the number of windings around the x axis, optional, default 3
  22036. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22037. * * 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)
  22038. * * 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)
  22039. * @returns the VertexData of the Torus Knot
  22040. */
  22041. static CreateTorusKnot(options: {
  22042. radius?: number;
  22043. tube?: number;
  22044. radialSegments?: number;
  22045. tubularSegments?: number;
  22046. p?: number;
  22047. q?: number;
  22048. sideOrientation?: number;
  22049. frontUVs?: Vector4;
  22050. backUVs?: Vector4;
  22051. }): VertexData;
  22052. /**
  22053. * Compute normals for given positions and indices
  22054. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22055. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22056. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22057. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22058. * * facetNormals : optional array of facet normals (vector3)
  22059. * * facetPositions : optional array of facet positions (vector3)
  22060. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22061. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22062. * * bInfo : optional bounding info, required for facetPartitioning computation
  22063. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22064. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22065. * * useRightHandedSystem: optional boolean to for right handed system computation
  22066. * * depthSort : optional boolean to enable the facet depth sort computation
  22067. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22068. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22069. */
  22070. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22071. facetNormals?: any;
  22072. facetPositions?: any;
  22073. facetPartitioning?: any;
  22074. ratio?: number;
  22075. bInfo?: any;
  22076. bbSize?: Vector3;
  22077. subDiv?: any;
  22078. useRightHandedSystem?: boolean;
  22079. depthSort?: boolean;
  22080. distanceTo?: Vector3;
  22081. depthSortedFacets?: any;
  22082. }): void;
  22083. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  22084. /**
  22085. * Applies VertexData created from the imported parameters to the geometry
  22086. * @param parsedVertexData the parsed data from an imported file
  22087. * @param geometry the geometry to apply the VertexData to
  22088. */
  22089. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22090. }
  22091. }
  22092. declare module BABYLON {
  22093. /**
  22094. * Class containing static functions to help procedurally build meshes
  22095. */
  22096. class MeshBuilder {
  22097. private static updateSideOrientation(orientation?);
  22098. /**
  22099. * Creates a box mesh
  22100. * * The parameter `size` sets the size (float) of each box side (default 1)
  22101. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  22102. * * 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)
  22103. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22104. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22105. * * 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/tutorials/02._Discover_Basic_Elements#side-orientation
  22106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22107. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  22108. * @param name defines the name of the mesh
  22109. * @param options defines the options used to create the mesh
  22110. * @param scene defines the hosting scene
  22111. * @returns the box mesh
  22112. */
  22113. static CreateBox(name: string, options: {
  22114. size?: number;
  22115. width?: number;
  22116. height?: number;
  22117. depth?: number;
  22118. faceUV?: Vector4[];
  22119. faceColors?: Color4[];
  22120. sideOrientation?: number;
  22121. frontUVs?: Vector4;
  22122. backUVs?: Vector4;
  22123. updatable?: boolean;
  22124. }, scene?: Nullable<Scene>): Mesh;
  22125. /**
  22126. * Creates a sphere mesh
  22127. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  22128. * * 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`)
  22129. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  22130. * * 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
  22131. * * 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)
  22132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22133. * * 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/tutorials/02._Discover_Basic_Elements#side-orientation
  22134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22135. * @param name defines the name of the mesh
  22136. * @param options defines the options used to create the mesh
  22137. * @param scene defines the hosting scene
  22138. * @returns the sphere mesh
  22139. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  22140. */
  22141. static CreateSphere(name: string, options: {
  22142. segments?: number;
  22143. diameter?: number;
  22144. diameterX?: number;
  22145. diameterY?: number;
  22146. diameterZ?: number;
  22147. arc?: number;
  22148. slice?: number;
  22149. sideOrientation?: number;
  22150. frontUVs?: Vector4;
  22151. backUVs?: Vector4;
  22152. updatable?: boolean;
  22153. }, scene: any): Mesh;
  22154. /**
  22155. * Creates a plane polygonal mesh. By default, this is a disc
  22156. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22157. * * 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
  22158. * * 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
  22159. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22160. * * 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/tutorials/02._Discover_Basic_Elements#side-orientation
  22161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22162. * @param name defines the name of the mesh
  22163. * @param options defines the options used to create the mesh
  22164. * @param scene defines the hosting scene
  22165. * @returns the plane polygonal mesh
  22166. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#disc
  22167. */
  22168. static CreateDisc(name: string, options: {
  22169. radius?: number;
  22170. tessellation?: number;
  22171. arc?: number;
  22172. updatable?: boolean;
  22173. sideOrientation?: number;
  22174. frontUVs?: Vector4;
  22175. backUVs?: Vector4;
  22176. }, scene?: Nullable<Scene>): Mesh;
  22177. /**
  22178. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22179. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22180. * * 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`)
  22181. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22182. * * 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
  22183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22184. * * 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/tutorials/02._Discover_Basic_Elements#side-orientation
  22185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22186. * @param name defines the name of the mesh
  22187. * @param options defines the options used to create the mesh
  22188. * @param scene defines the hosting scene
  22189. * @returns the icosahedron mesh
  22190. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#icosphere
  22191. */
  22192. static CreateIcoSphere(name: string, options: {
  22193. radius?: number;
  22194. radiusX?: number;
  22195. radiusY?: number;
  22196. radiusZ?: number;
  22197. flat?: boolean;
  22198. subdivisions?: number;
  22199. sideOrientation?: number;
  22200. frontUVs?: Vector4;
  22201. backUVs?: Vector4;
  22202. updatable?: boolean;
  22203. }, scene: Scene): Mesh;
  22204. /**
  22205. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22206. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  22207. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  22208. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  22209. * * 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
  22210. * * 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
  22211. * * 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
  22212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22213. * * 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/tutorials/02._Discover_Basic_Elements#side-orientation
  22214. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22215. * * 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
  22216. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  22217. * * 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
  22218. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  22219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22220. * @param name defines the name of the mesh
  22221. * @param options defines the options used to create the mesh
  22222. * @param scene defines the hosting scene
  22223. * @returns the ribbon mesh
  22224. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  22225. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22226. */
  22227. static CreateRibbon(name: string, options: {
  22228. pathArray: Vector3[][];
  22229. closeArray?: boolean;
  22230. closePath?: boolean;
  22231. offset?: number;
  22232. updatable?: boolean;
  22233. sideOrientation?: number;
  22234. frontUVs?: Vector4;
  22235. backUVs?: Vector4;
  22236. instance?: Mesh;
  22237. invertUV?: boolean;
  22238. uvs?: Vector2[];
  22239. colors?: Color4[];
  22240. }, scene?: Nullable<Scene>): Mesh;
  22241. /**
  22242. * Creates a cylinder or a cone mesh
  22243. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  22244. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  22245. * * 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.
  22246. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  22247. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  22248. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  22249. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  22250. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  22251. * * 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).
  22252. * * 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
  22253. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  22254. * * 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
  22255. * * 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.
  22256. * * If `enclose` is false, a ring surface is one element.
  22257. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  22258. * * 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
  22259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22260. * * 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/tutorials/02._Discover_Basic_Elements#side-orientation
  22261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22262. * @param name defines the name of the mesh
  22263. * @param options defines the options used to create the mesh
  22264. * @param scene defines the hosting scene
  22265. * @returns the cylinder mesh
  22266. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  22267. */
  22268. static CreateCylinder(name: string, options: {
  22269. height?: number;
  22270. diameterTop?: number;
  22271. diameterBottom?: number;
  22272. diameter?: number;
  22273. tessellation?: number;
  22274. subdivisions?: number;
  22275. arc?: number;
  22276. faceColors?: Color4[];
  22277. faceUV?: Vector4[];
  22278. updatable?: boolean;
  22279. hasRings?: boolean;
  22280. enclose?: boolean;
  22281. sideOrientation?: number;
  22282. frontUVs?: Vector4;
  22283. backUVs?: Vector4;
  22284. }, scene: any): Mesh;
  22285. /**
  22286. * Creates a torus mesh
  22287. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  22288. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  22289. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  22290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22291. * * 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/tutorials/02._Discover_Basic_Elements#side-orientation
  22292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22293. * @param name defines the name of the mesh
  22294. * @param options defines the options used to create the mesh
  22295. * @param scene defines the hosting scene
  22296. * @returns the torus mesh
  22297. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  22298. */
  22299. static CreateTorus(name: string, options: {
  22300. diameter?: number;
  22301. thickness?: number;
  22302. tessellation?: number;
  22303. updatable?: boolean;
  22304. sideOrientation?: number;
  22305. frontUVs?: Vector4;
  22306. backUVs?: Vector4;
  22307. }, scene: any): Mesh;
  22308. /**
  22309. * Creates a torus knot mesh
  22310. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  22311. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  22312. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  22313. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  22314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22315. * * 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/tutorials/02._Discover_Basic_Elements#side-orientation
  22316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22317. * @param name defines the name of the mesh
  22318. * @param options defines the options used to create the mesh
  22319. * @param scene defines the hosting scene
  22320. * @returns the torus knot mesh
  22321. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  22322. */
  22323. static CreateTorusKnot(name: string, options: {
  22324. radius?: number;
  22325. tube?: number;
  22326. radialSegments?: number;
  22327. tubularSegments?: number;
  22328. p?: number;
  22329. q?: number;
  22330. updatable?: boolean;
  22331. sideOrientation?: number;
  22332. frontUVs?: Vector4;
  22333. backUVs?: Vector4;
  22334. }, scene: any): Mesh;
  22335. /**
  22336. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  22337. * * 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
  22338. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  22339. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  22340. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  22341. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  22342. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  22343. * * 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
  22344. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  22345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22346. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#linesystem
  22347. * @param name defines the name of the new line system
  22348. * @param options defines the options used to create the line system
  22349. * @param scene defines the hosting scene
  22350. * @returns a new line system mesh
  22351. */
  22352. static CreateLineSystem(name: string, options: {
  22353. lines: Vector3[][];
  22354. updatable?: boolean;
  22355. instance?: Nullable<LinesMesh>;
  22356. colors?: Nullable<Color4[][]>;
  22357. useVertexAlpha?: boolean;
  22358. }, scene: Nullable<Scene>): LinesMesh;
  22359. /**
  22360. * Creates a line mesh
  22361. * 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
  22362. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22363. * * The parameter `points` is an array successive Vector3
  22364. * * 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
  22365. * * The optional parameter `colors` is an array of successive Color4, one per line point
  22366. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  22367. * * When updating an instance, remember that only point positions can change, not the number of points
  22368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22369. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lines
  22370. * @param name defines the name of the new line system
  22371. * @param options defines the options used to create the line system
  22372. * @param scene defines the hosting scene
  22373. * @returns a new line mesh
  22374. */
  22375. static CreateLines(name: string, options: {
  22376. points: Vector3[];
  22377. updatable?: boolean;
  22378. instance?: Nullable<LinesMesh>;
  22379. colors?: Color4[];
  22380. useVertexAlpha?: boolean;
  22381. }, scene?: Nullable<Scene>): LinesMesh;
  22382. /**
  22383. * Creates a dashed line mesh
  22384. * * 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
  22385. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22386. * * The parameter `points` is an array successive Vector3
  22387. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  22388. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  22389. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22390. * * 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
  22391. * * When updating an instance, remember that only point positions can change, not the number of points
  22392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22393. * @param name defines the name of the mesh
  22394. * @param options defines the options used to create the mesh
  22395. * @param scene defines the hosting scene
  22396. * @returns the dashed line mesh
  22397. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#dashed-lines
  22398. */
  22399. static CreateDashedLines(name: string, options: {
  22400. points: Vector3[];
  22401. dashSize?: number;
  22402. gapSize?: number;
  22403. dashNb?: number;
  22404. updatable?: boolean;
  22405. instance?: LinesMesh;
  22406. }, scene?: Nullable<Scene>): LinesMesh;
  22407. /**
  22408. * 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.
  22409. * * 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.
  22410. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22411. * * 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.
  22412. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  22413. * * 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
  22414. * * 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
  22415. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22417. * * 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/tutorials/02._Discover_Basic_Elements#side-orientation
  22418. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  22419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22420. * @param name defines the name of the mesh
  22421. * @param options defines the options used to create the mesh
  22422. * @param scene defines the hosting scene
  22423. * @returns the extruded shape mesh
  22424. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22425. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  22426. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#extruded-shapes
  22427. */
  22428. static ExtrudeShape(name: string, options: {
  22429. shape: Vector3[];
  22430. path: Vector3[];
  22431. scale?: number;
  22432. rotation?: number;
  22433. cap?: number;
  22434. updatable?: boolean;
  22435. sideOrientation?: number;
  22436. frontUVs?: Vector4;
  22437. backUVs?: Vector4;
  22438. instance?: Mesh;
  22439. invertUV?: boolean;
  22440. }, scene?: Nullable<Scene>): Mesh;
  22441. /**
  22442. * Creates an custom extruded shape mesh.
  22443. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  22444. * * 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.
  22445. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22446. * * 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
  22447. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  22448. * * 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
  22449. * * It must returns a float value that will be the scale value applied to the shape on each path point
  22450. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22451. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  22452. * * 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
  22453. * * 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
  22454. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  22455. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22456. * * 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/tutorials/02._Discover_Basic_Elements#side-orientation
  22457. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22459. * @param name defines the name of the mesh
  22460. * @param options defines the options used to create the mesh
  22461. * @param scene defines the hosting scene
  22462. * @returns the custom extruded shape mesh
  22463. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#custom-extruded-shapes
  22464. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22465. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  22466. */
  22467. static ExtrudeShapeCustom(name: string, options: {
  22468. shape: Vector3[];
  22469. path: Vector3[];
  22470. scaleFunction?: any;
  22471. rotationFunction?: any;
  22472. ribbonCloseArray?: boolean;
  22473. ribbonClosePath?: boolean;
  22474. cap?: number;
  22475. updatable?: boolean;
  22476. sideOrientation?: number;
  22477. frontUVs?: Vector4;
  22478. backUVs?: Vector4;
  22479. instance?: Mesh;
  22480. invertUV?: boolean;
  22481. }, scene: Scene): Mesh;
  22482. /**
  22483. * Creates lathe mesh.
  22484. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  22485. * * 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
  22486. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  22487. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  22488. * * 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
  22489. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  22490. * * 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
  22491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22492. * * 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/tutorials/02._Discover_Basic_Elements#side-orientation
  22493. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22495. * @param name defines the name of the mesh
  22496. * @param options defines the options used to create the mesh
  22497. * @param scene defines the hosting scene
  22498. * @returns the lathe mesh
  22499. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lathe
  22500. */
  22501. static CreateLathe(name: string, options: {
  22502. shape: Vector3[];
  22503. radius?: number;
  22504. tessellation?: number;
  22505. arc?: number;
  22506. closed?: boolean;
  22507. updatable?: boolean;
  22508. sideOrientation?: number;
  22509. frontUVs?: Vector4;
  22510. backUVs?: Vector4;
  22511. cap?: number;
  22512. invertUV?: boolean;
  22513. }, scene: Scene): Mesh;
  22514. /**
  22515. * Creates a plane mesh
  22516. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  22517. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  22518. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  22519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22520. * * 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/tutorials/02._Discover_Basic_Elements#side-orientation
  22521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22522. * @param name defines the name of the mesh
  22523. * @param options defines the options used to create the mesh
  22524. * @param scene defines the hosting scene
  22525. * @returns the plane mesh
  22526. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22527. */
  22528. static CreatePlane(name: string, options: {
  22529. size?: number;
  22530. width?: number;
  22531. height?: number;
  22532. sideOrientation?: number;
  22533. frontUVs?: Vector4;
  22534. backUVs?: Vector4;
  22535. updatable?: boolean;
  22536. sourcePlane?: Plane;
  22537. }, scene: Scene): Mesh;
  22538. /**
  22539. * Creates a ground mesh
  22540. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  22541. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  22542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22543. * @param name defines the name of the mesh
  22544. * @param options defines the options used to create the mesh
  22545. * @param scene defines the hosting scene
  22546. * @returns the ground mesh
  22547. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22548. */
  22549. static CreateGround(name: string, options: {
  22550. width?: number;
  22551. height?: number;
  22552. subdivisions?: number;
  22553. subdivisionsX?: number;
  22554. subdivisionsY?: number;
  22555. updatable?: boolean;
  22556. }, scene: any): Mesh;
  22557. /**
  22558. * Creates a tiled ground mesh
  22559. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  22560. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  22561. * * 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
  22562. * * 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
  22563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22564. * @param name defines the name of the mesh
  22565. * @param options defines the options used to create the mesh
  22566. * @param scene defines the hosting scene
  22567. * @returns the tiled ground mesh
  22568. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  22569. */
  22570. static CreateTiledGround(name: string, options: {
  22571. xmin: number;
  22572. zmin: number;
  22573. xmax: number;
  22574. zmax: number;
  22575. subdivisions?: {
  22576. w: number;
  22577. h: number;
  22578. };
  22579. precision?: {
  22580. w: number;
  22581. h: number;
  22582. };
  22583. updatable?: boolean;
  22584. }, scene: Scene): Mesh;
  22585. /**
  22586. * Creates a ground mesh from a height map
  22587. * * The parameter `url` sets the URL of the height map image resource.
  22588. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  22589. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  22590. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  22591. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  22592. * * 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.
  22593. * * 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).
  22594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22595. * @param name defines the name of the mesh
  22596. * @param url defines the url to the height map
  22597. * @param options defines the options used to create the mesh
  22598. * @param scene defines the hosting scene
  22599. * @returns the ground mesh
  22600. * @see http://doc.babylonjs.com/tutorials/14._Height_Map
  22601. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  22602. */
  22603. static CreateGroundFromHeightMap(name: string, url: string, options: {
  22604. width?: number;
  22605. height?: number;
  22606. subdivisions?: number;
  22607. minHeight?: number;
  22608. maxHeight?: number;
  22609. colorFilter?: Color3;
  22610. updatable?: boolean;
  22611. onReady?: (mesh: GroundMesh) => void;
  22612. }, scene: Scene): GroundMesh;
  22613. /**
  22614. * Creates a polygon mesh
  22615. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  22616. * * 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
  22617. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22619. * * 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)
  22620. * * Remember you can only change the shape positions, not their number when updating a polygon
  22621. * @param name defines the name of the mesh
  22622. * @param options defines the options used to create the mesh
  22623. * @param scene defines the hosting scene
  22624. * @returns the polygon mesh
  22625. */
  22626. static CreatePolygon(name: string, options: {
  22627. shape: Vector3[];
  22628. holes?: Vector3[][];
  22629. depth?: number;
  22630. faceUV?: Vector4[];
  22631. faceColors?: Color4[];
  22632. updatable?: boolean;
  22633. sideOrientation?: number;
  22634. frontUVs?: Vector4;
  22635. backUVs?: Vector4;
  22636. }, scene: Scene): Mesh;
  22637. /**
  22638. * Creates an extruded polygon mesh, with depth in the Y direction.
  22639. * * 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)
  22640. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22641. * @param name defines the name of the mesh
  22642. * @param options defines the options used to create the mesh
  22643. * @param scene defines the hosting scene
  22644. * @returns the polygon mesh
  22645. */
  22646. static ExtrudePolygon(name: string, options: {
  22647. shape: Vector3[];
  22648. holes?: Vector3[][];
  22649. depth?: number;
  22650. faceUV?: Vector4[];
  22651. faceColors?: Color4[];
  22652. updatable?: boolean;
  22653. sideOrientation?: number;
  22654. frontUVs?: Vector4;
  22655. backUVs?: Vector4;
  22656. }, scene: Scene): Mesh;
  22657. /**
  22658. * Creates a tube mesh.
  22659. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22660. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  22661. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  22662. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  22663. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  22664. * * 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)
  22665. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  22666. * * 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
  22667. * * 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
  22668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22669. * * 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/tutorials/02._Discover_Basic_Elements#side-orientation
  22670. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22672. * @param name defines the name of the mesh
  22673. * @param options defines the options used to create the mesh
  22674. * @param scene defines the hosting scene
  22675. * @returns the tube mesh
  22676. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22677. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  22678. */
  22679. static CreateTube(name: string, options: {
  22680. path: Vector3[];
  22681. radius?: number;
  22682. tessellation?: number;
  22683. radiusFunction?: {
  22684. (i: number, distance: number): number;
  22685. };
  22686. cap?: number;
  22687. arc?: number;
  22688. updatable?: boolean;
  22689. sideOrientation?: number;
  22690. frontUVs?: Vector4;
  22691. backUVs?: Vector4;
  22692. instance?: Mesh;
  22693. invertUV?: boolean;
  22694. }, scene: Scene): Mesh;
  22695. /**
  22696. * Creates a polyhedron mesh
  22697. * * 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
  22698. * * The parameter `size` (positive float, default 1) sets the polygon size
  22699. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22700. * * 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`
  22701. * * 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
  22702. * * 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)`)
  22703. * * 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
  22704. * * 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
  22705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22706. * * 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/tutorials/02._Discover_Basic_Elements#side-orientation
  22707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22708. * @param name defines the name of the mesh
  22709. * @param options defines the options used to create the mesh
  22710. * @param scene defines the hosting scene
  22711. * @returns the polyhedron mesh
  22712. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#polyhedron
  22713. */
  22714. static CreatePolyhedron(name: string, options: {
  22715. type?: number;
  22716. size?: number;
  22717. sizeX?: number;
  22718. sizeY?: number;
  22719. sizeZ?: number;
  22720. custom?: any;
  22721. faceUV?: Vector4[];
  22722. faceColors?: Color4[];
  22723. flat?: boolean;
  22724. updatable?: boolean;
  22725. sideOrientation?: number;
  22726. frontUVs?: Vector4;
  22727. backUVs?: Vector4;
  22728. }, scene: Scene): Mesh;
  22729. /**
  22730. * Creates a decal mesh.
  22731. * 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
  22732. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  22733. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  22734. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  22735. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  22736. * @param name defines the name of the mesh
  22737. * @param sourceMesh defines the mesh where the decal must be applied
  22738. * @param options defines the options used to create the mesh
  22739. * @param scene defines the hosting scene
  22740. * @returns the decal mesh
  22741. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#decals
  22742. */
  22743. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  22744. position?: Vector3;
  22745. normal?: Vector3;
  22746. size?: Vector3;
  22747. angle?: number;
  22748. }): Mesh;
  22749. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  22750. }
  22751. }
  22752. declare module BABYLON {
  22753. class MeshLODLevel {
  22754. distance: number;
  22755. mesh: Mesh;
  22756. constructor(distance: number, mesh: Mesh);
  22757. }
  22758. }
  22759. declare module BABYLON {
  22760. /**
  22761. * A simplifier interface for future simplification implementations.
  22762. */
  22763. interface ISimplifier {
  22764. /**
  22765. * Simplification of a given mesh according to the given settings.
  22766. * Since this requires computation, it is assumed that the function runs async.
  22767. * @param settings The settings of the simplification, including quality and distance
  22768. * @param successCallback A callback that will be called after the mesh was simplified.
  22769. * @param errorCallback in case of an error, this callback will be called. optional.
  22770. */
  22771. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  22772. }
  22773. /**
  22774. * Expected simplification settings.
  22775. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  22776. */
  22777. interface ISimplificationSettings {
  22778. quality: number;
  22779. distance: number;
  22780. optimizeMesh?: boolean;
  22781. }
  22782. class SimplificationSettings implements ISimplificationSettings {
  22783. quality: number;
  22784. distance: number;
  22785. optimizeMesh: boolean | undefined;
  22786. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  22787. }
  22788. interface ISimplificationTask {
  22789. settings: Array<ISimplificationSettings>;
  22790. simplificationType: SimplificationType;
  22791. mesh: Mesh;
  22792. successCallback?: () => void;
  22793. parallelProcessing: boolean;
  22794. }
  22795. class SimplificationQueue {
  22796. private _simplificationArray;
  22797. running: boolean;
  22798. constructor();
  22799. addTask(task: ISimplificationTask): void;
  22800. executeNext(): void;
  22801. runSimplification(task: ISimplificationTask): void;
  22802. private getSimplifier(task);
  22803. }
  22804. /**
  22805. * The implemented types of simplification.
  22806. * At the moment only Quadratic Error Decimation is implemented.
  22807. */
  22808. enum SimplificationType {
  22809. QUADRATIC = 0,
  22810. }
  22811. class DecimationTriangle {
  22812. vertices: Array<DecimationVertex>;
  22813. normal: Vector3;
  22814. error: Array<number>;
  22815. deleted: boolean;
  22816. isDirty: boolean;
  22817. borderFactor: number;
  22818. deletePending: boolean;
  22819. originalOffset: number;
  22820. constructor(vertices: Array<DecimationVertex>);
  22821. }
  22822. class DecimationVertex {
  22823. position: Vector3;
  22824. id: number;
  22825. q: QuadraticMatrix;
  22826. isBorder: boolean;
  22827. triangleStart: number;
  22828. triangleCount: number;
  22829. originalOffsets: Array<number>;
  22830. constructor(position: Vector3, id: number);
  22831. updatePosition(newPosition: Vector3): void;
  22832. }
  22833. class QuadraticMatrix {
  22834. data: Array<number>;
  22835. constructor(data?: Array<number>);
  22836. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  22837. addInPlace(matrix: QuadraticMatrix): void;
  22838. addArrayInPlace(data: Array<number>): void;
  22839. add(matrix: QuadraticMatrix): QuadraticMatrix;
  22840. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  22841. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  22842. }
  22843. class Reference {
  22844. vertexId: number;
  22845. triangleId: number;
  22846. constructor(vertexId: number, triangleId: number);
  22847. }
  22848. /**
  22849. * An implementation of the Quadratic Error simplification algorithm.
  22850. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  22851. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  22852. * @author RaananW
  22853. */
  22854. class QuadraticErrorSimplification implements ISimplifier {
  22855. private _mesh;
  22856. private triangles;
  22857. private vertices;
  22858. private references;
  22859. private _reconstructedMesh;
  22860. syncIterations: number;
  22861. aggressiveness: number;
  22862. decimationIterations: number;
  22863. boundingBoxEpsilon: number;
  22864. constructor(_mesh: Mesh);
  22865. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  22866. private runDecimation(settings, submeshIndex, successCallback);
  22867. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  22868. private init(callback);
  22869. private reconstructMesh(submeshIndex);
  22870. private initDecimatedMesh();
  22871. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  22872. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  22873. private identifyBorder();
  22874. private updateMesh(identifyBorders?);
  22875. private vertexError(q, point);
  22876. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  22877. }
  22878. }
  22879. declare module BABYLON {
  22880. class Polygon {
  22881. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  22882. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  22883. static Parse(input: string): Vector2[];
  22884. static StartingAt(x: number, y: number): Path2;
  22885. }
  22886. class PolygonMeshBuilder {
  22887. private _points;
  22888. private _outlinepoints;
  22889. private _holes;
  22890. private _name;
  22891. private _scene;
  22892. private _epoints;
  22893. private _eholes;
  22894. private _addToepoint(points);
  22895. constructor(name: string, contours: Path2, scene: Scene);
  22896. constructor(name: string, contours: Vector2[], scene: Scene);
  22897. addHole(hole: Vector2[]): PolygonMeshBuilder;
  22898. build(updatable?: boolean, depth?: number): Mesh;
  22899. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  22900. }
  22901. }
  22902. declare module BABYLON {
  22903. class BaseSubMesh {
  22904. _materialDefines: Nullable<MaterialDefines>;
  22905. _materialEffect: Nullable<Effect>;
  22906. readonly effect: Nullable<Effect>;
  22907. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22908. }
  22909. class SubMesh extends BaseSubMesh implements ICullable {
  22910. materialIndex: number;
  22911. verticesStart: number;
  22912. verticesCount: number;
  22913. indexStart: number;
  22914. indexCount: number;
  22915. linesIndexCount: number;
  22916. private _mesh;
  22917. private _renderingMesh;
  22918. private _boundingInfo;
  22919. private _linesIndexBuffer;
  22920. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22921. _trianglePlanes: Plane[];
  22922. _lastColliderTransformMatrix: Matrix;
  22923. _renderId: number;
  22924. _alphaIndex: number;
  22925. _distanceToCamera: number;
  22926. _id: number;
  22927. private _currentMaterial;
  22928. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22929. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22930. readonly IsGlobal: boolean;
  22931. /**
  22932. * Returns the submesh BoudingInfo object.
  22933. */
  22934. getBoundingInfo(): BoundingInfo;
  22935. /**
  22936. * Sets the submesh BoundingInfo.
  22937. * Return the SubMesh.
  22938. */
  22939. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22940. /**
  22941. * Returns the mesh of the current submesh.
  22942. */
  22943. getMesh(): AbstractMesh;
  22944. /**
  22945. * Returns the rendering mesh of the submesh.
  22946. */
  22947. getRenderingMesh(): Mesh;
  22948. /**
  22949. * Returns the submesh material.
  22950. */
  22951. getMaterial(): Nullable<Material>;
  22952. /**
  22953. * Sets a new updated BoundingInfo object to the submesh.
  22954. * Returns the SubMesh.
  22955. */
  22956. refreshBoundingInfo(): SubMesh;
  22957. _checkCollision(collider: Collider): boolean;
  22958. /**
  22959. * Updates the submesh BoundingInfo.
  22960. * Returns the Submesh.
  22961. */
  22962. updateBoundingInfo(world: Matrix): SubMesh;
  22963. /**
  22964. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22965. * Boolean returned.
  22966. */
  22967. isInFrustum(frustumPlanes: Plane[]): boolean;
  22968. /**
  22969. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  22970. * Boolean returned.
  22971. */
  22972. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22973. /**
  22974. * Renders the submesh.
  22975. * Returns it.
  22976. */
  22977. render(enableAlphaMode: boolean): SubMesh;
  22978. /**
  22979. * Returns a new Index Buffer.
  22980. * Type returned : WebGLBuffer.
  22981. */
  22982. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22983. /**
  22984. * True is the passed Ray intersects the submesh bounding box.
  22985. * Boolean returned.
  22986. */
  22987. canIntersects(ray: Ray): boolean;
  22988. /**
  22989. * Returns an object IntersectionInfo.
  22990. */
  22991. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  22992. _rebuild(): void;
  22993. /**
  22994. * Creates a new Submesh from the passed Mesh.
  22995. */
  22996. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22997. /**
  22998. * Disposes the Submesh.
  22999. * Returns nothing.
  23000. */
  23001. dispose(): void;
  23002. /**
  23003. * Creates a new Submesh from the passed parameters :
  23004. * - materialIndex (integer) : the index of the main mesh material.
  23005. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  23006. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  23007. * - mesh (Mesh) : the main mesh to create the submesh from.
  23008. * - renderingMesh (optional Mesh) : rendering mesh.
  23009. */
  23010. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23011. }
  23012. }
  23013. declare module BABYLON {
  23014. class TransformNode extends Node {
  23015. static BILLBOARDMODE_NONE: number;
  23016. static BILLBOARDMODE_X: number;
  23017. static BILLBOARDMODE_Y: number;
  23018. static BILLBOARDMODE_Z: number;
  23019. static BILLBOARDMODE_ALL: number;
  23020. private _forward;
  23021. private _forwardInverted;
  23022. private _up;
  23023. private _right;
  23024. private _rightInverted;
  23025. private _rotation;
  23026. private _rotationQuaternion;
  23027. protected _scaling: Vector3;
  23028. protected _isDirty: boolean;
  23029. private _transformToBoneReferal;
  23030. billboardMode: number;
  23031. scalingDeterminant: number;
  23032. infiniteDistance: boolean;
  23033. position: Vector3;
  23034. _poseMatrix: Matrix;
  23035. private _localWorld;
  23036. _worldMatrix: Matrix;
  23037. _worldMatrixDeterminant: number;
  23038. private _absolutePosition;
  23039. private _pivotMatrix;
  23040. private _pivotMatrixInverse;
  23041. private _postMultiplyPivotMatrix;
  23042. protected _isWorldMatrixFrozen: boolean;
  23043. /**
  23044. * An event triggered after the world matrix is updated
  23045. */
  23046. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  23047. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  23048. /**
  23049. * Gets a string idenfifying the name of the class
  23050. * @returns "TransformNode" string
  23051. */
  23052. getClassName(): string;
  23053. /**
  23054. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  23055. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  23056. * Default : (0.0, 0.0, 0.0)
  23057. */
  23058. rotation: Vector3;
  23059. /**
  23060. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23061. * Default : (1.0, 1.0, 1.0)
  23062. */
  23063. /**
  23064. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23065. * Default : (1.0, 1.0, 1.0)
  23066. */
  23067. scaling: Vector3;
  23068. /**
  23069. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  23070. * It's null by default.
  23071. * If set, only the rotationQuaternion is then used to compute the mesh rotation and its property `.rotation\ is then ignored and set to (0.0, 0.0, 0.0)
  23072. */
  23073. rotationQuaternion: Nullable<Quaternion>;
  23074. /**
  23075. * The forward direction of that transform in world space.
  23076. */
  23077. readonly forward: Vector3;
  23078. /**
  23079. * The up direction of that transform in world space.
  23080. */
  23081. readonly up: Vector3;
  23082. /**
  23083. * The right direction of that transform in world space.
  23084. */
  23085. readonly right: Vector3;
  23086. /**
  23087. * Returns the latest update of the World matrix
  23088. * Returns a Matrix.
  23089. */
  23090. getWorldMatrix(): Matrix;
  23091. /**
  23092. * Returns the latest update of the World matrix determinant.
  23093. */
  23094. protected _getWorldMatrixDeterminant(): number;
  23095. /**
  23096. * Returns directly the latest state of the mesh World matrix.
  23097. * A Matrix is returned.
  23098. */
  23099. readonly worldMatrixFromCache: Matrix;
  23100. /**
  23101. * Copies the paramater passed Matrix into the mesh Pose matrix.
  23102. * Returns the TransformNode.
  23103. */
  23104. updatePoseMatrix(matrix: Matrix): TransformNode;
  23105. /**
  23106. * Returns the mesh Pose matrix.
  23107. * Returned object : Matrix
  23108. */
  23109. getPoseMatrix(): Matrix;
  23110. _isSynchronized(): boolean;
  23111. _initCache(): void;
  23112. markAsDirty(property: string): TransformNode;
  23113. /**
  23114. * Returns the current mesh absolute position.
  23115. * Retuns a Vector3.
  23116. */
  23117. readonly absolutePosition: Vector3;
  23118. /**
  23119. * Sets a new matrix to apply before all other transformation
  23120. * @param matrix defines the transform matrix
  23121. * @returns the current TransformNode
  23122. */
  23123. setPreTransformMatrix(matrix: Matrix): TransformNode;
  23124. /**
  23125. * Sets a new pivot matrix to the current node
  23126. * @param matrix defines the new pivot matrix to use
  23127. * @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
  23128. * @returns the current TransformNode
  23129. */
  23130. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  23131. /**
  23132. * Returns the mesh pivot matrix.
  23133. * Default : Identity.
  23134. * A Matrix is returned.
  23135. */
  23136. getPivotMatrix(): Matrix;
  23137. /**
  23138. * Prevents the World matrix to be computed any longer.
  23139. * Returns the TransformNode.
  23140. */
  23141. freezeWorldMatrix(): TransformNode;
  23142. /**
  23143. * Allows back the World matrix computation.
  23144. * Returns the TransformNode.
  23145. */
  23146. unfreezeWorldMatrix(): this;
  23147. /**
  23148. * True if the World matrix has been frozen.
  23149. * Returns a boolean.
  23150. */
  23151. readonly isWorldMatrixFrozen: boolean;
  23152. /**
  23153. * Retuns the mesh absolute position in the World.
  23154. * Returns a Vector3.
  23155. */
  23156. getAbsolutePosition(): Vector3;
  23157. /**
  23158. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  23159. * Returns the TransformNode.
  23160. */
  23161. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23162. /**
  23163. * Sets the mesh position in its local space.
  23164. * Returns the TransformNode.
  23165. */
  23166. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  23167. /**
  23168. * Returns the mesh position in the local space from the current World matrix values.
  23169. * Returns a new Vector3.
  23170. */
  23171. getPositionExpressedInLocalSpace(): Vector3;
  23172. /**
  23173. * Translates the mesh along the passed Vector3 in its local space.
  23174. * Returns the TransformNode.
  23175. */
  23176. locallyTranslate(vector3: Vector3): TransformNode;
  23177. private static _lookAtVectorCache;
  23178. /**
  23179. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  23180. * @param targetPoint the position (must be in same space as current mesh) to look at
  23181. * @param yawCor optional yaw (y-axis) correction in radians
  23182. * @param pitchCor optional pitch (x-axis) correction in radians
  23183. * @param rollCor optional roll (z-axis) correction in radians
  23184. * @param space the choosen space of the target
  23185. * @returns the TransformNode.
  23186. */
  23187. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  23188. /**
  23189. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  23190. * This Vector3 is expressed in the World space.
  23191. */
  23192. getDirection(localAxis: Vector3): Vector3;
  23193. /**
  23194. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  23195. * localAxis is expressed in the mesh local space.
  23196. * result is computed in the Wordl space from the mesh World matrix.
  23197. * Returns the TransformNode.
  23198. */
  23199. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  23200. /**
  23201. * Sets a new pivot point to the current node
  23202. * @param point defines the new pivot point to use
  23203. * @param space defines if the point is in world or local space (local by default)
  23204. * @returns the current TransformNode
  23205. */
  23206. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  23207. /**
  23208. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  23209. */
  23210. getPivotPoint(): Vector3;
  23211. /**
  23212. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  23213. * Returns the TransformNode.
  23214. */
  23215. getPivotPointToRef(result: Vector3): TransformNode;
  23216. /**
  23217. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  23218. */
  23219. getAbsolutePivotPoint(): Vector3;
  23220. /**
  23221. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  23222. * Returns the TransformNode.
  23223. */
  23224. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  23225. /**
  23226. * Defines the passed node as the parent of the current node.
  23227. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  23228. * Returns the TransformNode.
  23229. */
  23230. setParent(node: Nullable<Node>): TransformNode;
  23231. private _nonUniformScaling;
  23232. readonly nonUniformScaling: boolean;
  23233. _updateNonUniformScalingState(value: boolean): boolean;
  23234. /**
  23235. * Attach the current TransformNode to another TransformNode associated with a bone
  23236. * @param bone Bone affecting the TransformNode
  23237. * @param affectedTransformNode TransformNode associated with the bone
  23238. */
  23239. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  23240. detachFromBone(): TransformNode;
  23241. private static _rotationAxisCache;
  23242. /**
  23243. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  23244. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23245. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23246. * The passed axis is also normalized.
  23247. * Returns the TransformNode.
  23248. */
  23249. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23250. /**
  23251. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  23252. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23253. * The passed axis is also normalized.
  23254. * Returns the TransformNode.
  23255. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  23256. */
  23257. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  23258. /**
  23259. * Translates the mesh along the axis vector for the passed distance in the given space.
  23260. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23261. * Returns the TransformNode.
  23262. */
  23263. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23264. /**
  23265. * Adds a rotation step to the mesh current rotation.
  23266. * x, y, z are Euler angles expressed in radians.
  23267. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  23268. * This means this rotation is made in the mesh local space only.
  23269. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  23270. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  23271. * ```javascript
  23272. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  23273. * ```
  23274. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  23275. * 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.
  23276. * Returns the TransformNode.
  23277. */
  23278. addRotation(x: number, y: number, z: number): TransformNode;
  23279. /**
  23280. * Computes the mesh World matrix and returns it.
  23281. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  23282. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  23283. * If the parameter `force`is set to `true`, the actual computation is done.
  23284. * Returns the mesh World Matrix.
  23285. */
  23286. computeWorldMatrix(force?: boolean): Matrix;
  23287. protected _afterComputeWorldMatrix(): void;
  23288. /**
  23289. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  23290. * @param func: callback function to add
  23291. *
  23292. * Returns the TransformNode.
  23293. */
  23294. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23295. /**
  23296. * Removes a registered callback function.
  23297. * Returns the TransformNode.
  23298. */
  23299. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23300. /**
  23301. * Clone the current transform node
  23302. * Returns the new transform node
  23303. * @param name Name of the new clone
  23304. * @param newParent New parent for the clone
  23305. * @param doNotCloneChildren Do not clone children hierarchy
  23306. */
  23307. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  23308. serialize(currentSerializationObject?: any): any;
  23309. /**
  23310. * Returns a new TransformNode object parsed from the source provided.
  23311. * The parameter `parsedMesh` is the source.
  23312. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  23313. */
  23314. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  23315. /**
  23316. * Releases resources associated with this transform node.
  23317. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23318. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23319. */
  23320. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23321. }
  23322. }
  23323. declare module BABYLON {
  23324. class VertexBuffer {
  23325. private _buffer;
  23326. private _kind;
  23327. private _size;
  23328. private _ownsBuffer;
  23329. private _instanced;
  23330. private _instanceDivisor;
  23331. /**
  23332. * The byte type.
  23333. */
  23334. static readonly BYTE: number;
  23335. /**
  23336. * The unsigned byte type.
  23337. */
  23338. static readonly UNSIGNED_BYTE: number;
  23339. /**
  23340. * The short type.
  23341. */
  23342. static readonly SHORT: number;
  23343. /**
  23344. * The unsigned short type.
  23345. */
  23346. static readonly UNSIGNED_SHORT: number;
  23347. /**
  23348. * The integer type.
  23349. */
  23350. static readonly INT: number;
  23351. /**
  23352. * The unsigned integer type.
  23353. */
  23354. static readonly UNSIGNED_INT: number;
  23355. /**
  23356. * The float type.
  23357. */
  23358. static readonly FLOAT: number;
  23359. /**
  23360. * Gets or sets the instance divisor when in instanced mode
  23361. */
  23362. instanceDivisor: number;
  23363. /**
  23364. * Gets the byte stride.
  23365. */
  23366. readonly byteStride: number;
  23367. /**
  23368. * Gets the byte offset.
  23369. */
  23370. readonly byteOffset: number;
  23371. /**
  23372. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  23373. */
  23374. readonly normalized: boolean;
  23375. /**
  23376. * Gets the data type of each component in the array.
  23377. */
  23378. readonly type: number;
  23379. /**
  23380. * Constructor
  23381. * @param engine the engine
  23382. * @param data the data to use for this vertex buffer
  23383. * @param kind the vertex buffer kind
  23384. * @param updatable whether the data is updatable
  23385. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  23386. * @param stride the stride (optional)
  23387. * @param instanced whether the buffer is instanced (optional)
  23388. * @param offset the offset of the data (optional)
  23389. * @param size the number of components (optional)
  23390. * @param type the type of the component (optional)
  23391. * @param normalized whether the data contains normalized data (optional)
  23392. * @param useBytes set to true if stride and offset are in bytes (optional)
  23393. */
  23394. 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);
  23395. _rebuild(): void;
  23396. /**
  23397. * Returns the kind of the VertexBuffer (string).
  23398. */
  23399. getKind(): string;
  23400. /**
  23401. * Boolean : is the VertexBuffer updatable ?
  23402. */
  23403. isUpdatable(): boolean;
  23404. /**
  23405. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  23406. */
  23407. getData(): Nullable<DataArray>;
  23408. /**
  23409. * Returns the WebGLBuffer associated to the VertexBuffer.
  23410. */
  23411. getBuffer(): Nullable<WebGLBuffer>;
  23412. /**
  23413. * Returns the stride as a multiple of the type byte length.
  23414. * DEPRECATED. Use byteStride instead.
  23415. */
  23416. getStrideSize(): number;
  23417. /**
  23418. * Returns the offset as a multiple of the type byte length.
  23419. * DEPRECATED. Use byteOffset instead.
  23420. */
  23421. getOffset(): number;
  23422. /**
  23423. * Returns the number of components per vertex attribute (integer).
  23424. */
  23425. getSize(): number;
  23426. /**
  23427. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  23428. */
  23429. getIsInstanced(): boolean;
  23430. /**
  23431. * Returns the instancing divisor, zero for non-instanced (integer).
  23432. */
  23433. getInstanceDivisor(): number;
  23434. /**
  23435. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  23436. * Returns the created WebGLBuffer.
  23437. */
  23438. create(data?: DataArray): void;
  23439. /**
  23440. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23441. * This function will create a new buffer if the current one is not updatable
  23442. * Returns the updated WebGLBuffer.
  23443. */
  23444. update(data: DataArray): void;
  23445. /**
  23446. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23447. * Returns the directly updated WebGLBuffer.
  23448. * @param data the new data
  23449. * @param offset the new offset
  23450. * @param useBytes set to true if the offset is in bytes
  23451. */
  23452. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  23453. /**
  23454. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  23455. */
  23456. dispose(): void;
  23457. /**
  23458. * Enumerates each value of this vertex buffer as numbers.
  23459. * @param count the number of values to enumerate
  23460. * @param callback the callback function called for each value
  23461. */
  23462. forEach(count: number, callback: (value: number, index: number) => void): void;
  23463. private static _PositionKind;
  23464. private static _NormalKind;
  23465. private static _TangentKind;
  23466. private static _UVKind;
  23467. private static _UV2Kind;
  23468. private static _UV3Kind;
  23469. private static _UV4Kind;
  23470. private static _UV5Kind;
  23471. private static _UV6Kind;
  23472. private static _ColorKind;
  23473. private static _MatricesIndicesKind;
  23474. private static _MatricesWeightsKind;
  23475. private static _MatricesIndicesExtraKind;
  23476. private static _MatricesWeightsExtraKind;
  23477. static readonly PositionKind: string;
  23478. static readonly NormalKind: string;
  23479. static readonly TangentKind: string;
  23480. static readonly UVKind: string;
  23481. static readonly UV2Kind: string;
  23482. static readonly UV3Kind: string;
  23483. static readonly UV4Kind: string;
  23484. static readonly UV5Kind: string;
  23485. static readonly UV6Kind: string;
  23486. static readonly ColorKind: string;
  23487. static readonly MatricesIndicesKind: string;
  23488. static readonly MatricesWeightsKind: string;
  23489. static readonly MatricesIndicesExtraKind: string;
  23490. static readonly MatricesWeightsExtraKind: string;
  23491. /**
  23492. * Deduces the stride given a kind.
  23493. * @param kind The kind string to deduce
  23494. * @returns The deduced stride
  23495. */
  23496. static DeduceStride(kind: string): number;
  23497. /**
  23498. * Gets the byte length of the given type.
  23499. * @param type the type
  23500. * @returns the number of bytes
  23501. */
  23502. static GetTypeByteLength(type: number): number;
  23503. /**
  23504. * Enumerates each value of the given parameters as numbers.
  23505. * @param data the data to enumerate
  23506. * @param byteOffset the byte offset of the data
  23507. * @param byteStride the byte stride of the data
  23508. * @param componentCount the number of components per element
  23509. * @param componentType the type of the component
  23510. * @param count the total number of components
  23511. * @param normalized whether the data is normalized
  23512. * @param callback the callback function called for each value
  23513. */
  23514. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  23515. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  23516. }
  23517. }
  23518. declare module BABYLON {
  23519. class ReflectionProbe {
  23520. name: string;
  23521. private _scene;
  23522. private _renderTargetTexture;
  23523. private _projectionMatrix;
  23524. private _viewMatrix;
  23525. private _target;
  23526. private _add;
  23527. private _attachedMesh;
  23528. private _invertYAxis;
  23529. position: Vector3;
  23530. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  23531. samples: number;
  23532. refreshRate: number;
  23533. getScene(): Scene;
  23534. readonly cubeTexture: RenderTargetTexture;
  23535. readonly renderList: Nullable<AbstractMesh[]>;
  23536. attachToMesh(mesh: AbstractMesh): void;
  23537. /**
  23538. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23539. *
  23540. * @param renderingGroupId The rendering group id corresponding to its index
  23541. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23542. */
  23543. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23544. dispose(): void;
  23545. }
  23546. }
  23547. declare module BABYLON {
  23548. class BoundingBoxRenderer {
  23549. frontColor: Color3;
  23550. backColor: Color3;
  23551. showBackLines: boolean;
  23552. renderList: SmartArray<BoundingBox>;
  23553. private _scene;
  23554. private _colorShader;
  23555. private _vertexBuffers;
  23556. private _indexBuffer;
  23557. constructor(scene: Scene);
  23558. private _prepareRessources();
  23559. private _createIndexBuffer();
  23560. _rebuild(): void;
  23561. reset(): void;
  23562. render(): void;
  23563. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  23564. dispose(): void;
  23565. }
  23566. }
  23567. declare module BABYLON {
  23568. /**
  23569. * This represents a depth renderer in Babylon.
  23570. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  23571. */
  23572. class DepthRenderer {
  23573. private _scene;
  23574. private _depthMap;
  23575. private _effect;
  23576. private _cachedDefines;
  23577. private _camera;
  23578. /**
  23579. * Instantiates a depth renderer
  23580. * @param scene The scene the renderer belongs to
  23581. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  23582. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  23583. */
  23584. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  23585. /**
  23586. * Creates the depth rendering effect and checks if the effect is ready.
  23587. * @param subMesh The submesh to be used to render the depth map of
  23588. * @param useInstances If multiple world instances should be used
  23589. * @returns if the depth renderer is ready to render the depth map
  23590. */
  23591. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23592. /**
  23593. * Gets the texture which the depth map will be written to.
  23594. * @returns The depth map texture
  23595. */
  23596. getDepthMap(): RenderTargetTexture;
  23597. /**
  23598. * Disposes of the depth renderer.
  23599. */
  23600. dispose(): void;
  23601. }
  23602. }
  23603. declare module BABYLON {
  23604. class EdgesRenderer {
  23605. edgesWidthScalerForOrthographic: number;
  23606. edgesWidthScalerForPerspective: number;
  23607. private _source;
  23608. private _linesPositions;
  23609. private _linesNormals;
  23610. private _linesIndices;
  23611. private _epsilon;
  23612. private _indicesCount;
  23613. private _lineShader;
  23614. private _ib;
  23615. private _buffers;
  23616. private _checkVerticesInsteadOfIndices;
  23617. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  23618. private _prepareRessources();
  23619. _rebuild(): void;
  23620. dispose(): void;
  23621. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  23622. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  23623. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  23624. _generateEdgesLines(): void;
  23625. render(): void;
  23626. }
  23627. }
  23628. declare module BABYLON {
  23629. /**
  23630. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  23631. */
  23632. class GeometryBufferRenderer {
  23633. private _scene;
  23634. private _multiRenderTarget;
  23635. private _ratio;
  23636. private _enablePosition;
  23637. protected _effect: Effect;
  23638. protected _cachedDefines: string;
  23639. /**
  23640. * Set the render list (meshes to be rendered) used in the G buffer.
  23641. */
  23642. renderList: Mesh[];
  23643. /**
  23644. * Gets wether or not G buffer are supported by the running hardware.
  23645. * This requires draw buffer supports
  23646. */
  23647. readonly isSupported: boolean;
  23648. /**
  23649. * Gets wether or not position are enabled for the G buffer.
  23650. */
  23651. /**
  23652. * Sets wether or not position are enabled for the G buffer.
  23653. */
  23654. enablePosition: boolean;
  23655. /**
  23656. * Gets the scene associated with the buffer.
  23657. */
  23658. readonly scene: Scene;
  23659. /**
  23660. * Gets the ratio used by the buffer during its creation.
  23661. * How big is the buffer related to the main canvas.
  23662. */
  23663. readonly ratio: number;
  23664. /**
  23665. * Creates a new G Buffer for the scene
  23666. * @param scene The scene the buffer belongs to
  23667. * @param ratio How big is the buffer related to the main canvas.
  23668. */
  23669. constructor(scene: Scene, ratio?: number);
  23670. /**
  23671. * Checks wether everything is ready to render a submesh to the G buffer.
  23672. * @param subMesh the submesh to check readiness for
  23673. * @param useInstances is the mesh drawn using instance or not
  23674. * @returns true if ready otherwise false
  23675. */
  23676. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23677. /**
  23678. * Gets the current underlying G Buffer.
  23679. * @returns the buffer
  23680. */
  23681. getGBuffer(): MultiRenderTarget;
  23682. /**
  23683. * Gets the number of samples used to render the buffer (anti aliasing).
  23684. */
  23685. /**
  23686. * Sets the number of samples used to render the buffer (anti aliasing).
  23687. */
  23688. samples: number;
  23689. /**
  23690. * Disposes the renderer and frees up associated resources.
  23691. */
  23692. dispose(): void;
  23693. protected _createRenderTargets(): void;
  23694. }
  23695. }
  23696. declare module BABYLON {
  23697. class OutlineRenderer {
  23698. private _scene;
  23699. private _effect;
  23700. private _cachedDefines;
  23701. zOffset: number;
  23702. constructor(scene: Scene);
  23703. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  23704. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23705. }
  23706. }
  23707. declare module BABYLON {
  23708. class RenderingGroup {
  23709. index: number;
  23710. private _scene;
  23711. private _opaqueSubMeshes;
  23712. private _transparentSubMeshes;
  23713. private _alphaTestSubMeshes;
  23714. private _depthOnlySubMeshes;
  23715. private _particleSystems;
  23716. private _spriteManagers;
  23717. private _opaqueSortCompareFn;
  23718. private _alphaTestSortCompareFn;
  23719. private _transparentSortCompareFn;
  23720. private _renderOpaque;
  23721. private _renderAlphaTest;
  23722. private _renderTransparent;
  23723. private _edgesRenderers;
  23724. onBeforeTransparentRendering: () => void;
  23725. /**
  23726. * Set the opaque sort comparison function.
  23727. * If null the sub meshes will be render in the order they were created
  23728. */
  23729. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  23730. /**
  23731. * Set the alpha test sort comparison function.
  23732. * If null the sub meshes will be render in the order they were created
  23733. */
  23734. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  23735. /**
  23736. * Set the transparent sort comparison function.
  23737. * If null the sub meshes will be render in the order they were created
  23738. */
  23739. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  23740. /**
  23741. * Creates a new rendering group.
  23742. * @param index The rendering group index
  23743. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  23744. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  23745. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  23746. */
  23747. 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>);
  23748. /**
  23749. * Render all the sub meshes contained in the group.
  23750. * @param customRenderFunction Used to override the default render behaviour of the group.
  23751. * @returns true if rendered some submeshes.
  23752. */
  23753. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  23754. /**
  23755. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  23756. * @param subMeshes The submeshes to render
  23757. */
  23758. private renderOpaqueSorted(subMeshes);
  23759. /**
  23760. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  23761. * @param subMeshes The submeshes to render
  23762. */
  23763. private renderAlphaTestSorted(subMeshes);
  23764. /**
  23765. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  23766. * @param subMeshes The submeshes to render
  23767. */
  23768. private renderTransparentSorted(subMeshes);
  23769. /**
  23770. * Renders the submeshes in a specified order.
  23771. * @param subMeshes The submeshes to sort before render
  23772. * @param sortCompareFn The comparison function use to sort
  23773. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  23774. * @param transparent Specifies to activate blending if true
  23775. */
  23776. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  23777. /**
  23778. * Renders the submeshes in the order they were dispatched (no sort applied).
  23779. * @param subMeshes The submeshes to render
  23780. */
  23781. private static renderUnsorted(subMeshes);
  23782. /**
  23783. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  23784. * are rendered back to front if in the same alpha index.
  23785. *
  23786. * @param a The first submesh
  23787. * @param b The second submesh
  23788. * @returns The result of the comparison
  23789. */
  23790. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  23791. /**
  23792. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  23793. * are rendered back to front.
  23794. *
  23795. * @param a The first submesh
  23796. * @param b The second submesh
  23797. * @returns The result of the comparison
  23798. */
  23799. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  23800. /**
  23801. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  23802. * are rendered front to back (prevent overdraw).
  23803. *
  23804. * @param a The first submesh
  23805. * @param b The second submesh
  23806. * @returns The result of the comparison
  23807. */
  23808. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  23809. /**
  23810. * Resets the different lists of submeshes to prepare a new frame.
  23811. */
  23812. prepare(): void;
  23813. dispose(): void;
  23814. /**
  23815. * Inserts the submesh in its correct queue depending on its material.
  23816. * @param subMesh The submesh to dispatch
  23817. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  23818. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  23819. */
  23820. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  23821. dispatchSprites(spriteManager: SpriteManager): void;
  23822. dispatchParticles(particleSystem: IParticleSystem): void;
  23823. private _renderParticles(activeMeshes);
  23824. private _renderSprites();
  23825. }
  23826. }
  23827. declare module BABYLON {
  23828. class RenderingManager {
  23829. /**
  23830. * The max id used for rendering groups (not included)
  23831. */
  23832. static MAX_RENDERINGGROUPS: number;
  23833. /**
  23834. * The min id used for rendering groups (included)
  23835. */
  23836. static MIN_RENDERINGGROUPS: number;
  23837. /**
  23838. * Used to globally prevent autoclearing scenes.
  23839. */
  23840. static AUTOCLEAR: boolean;
  23841. private _scene;
  23842. private _renderingGroups;
  23843. private _depthStencilBufferAlreadyCleaned;
  23844. private _autoClearDepthStencil;
  23845. private _customOpaqueSortCompareFn;
  23846. private _customAlphaTestSortCompareFn;
  23847. private _customTransparentSortCompareFn;
  23848. private _renderinGroupInfo;
  23849. constructor(scene: Scene);
  23850. private _clearDepthStencilBuffer(depth?, stencil?);
  23851. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  23852. reset(): void;
  23853. dispose(): void;
  23854. /**
  23855. * Clear the info related to rendering groups preventing retention points during dispose.
  23856. */
  23857. freeRenderingGroups(): void;
  23858. private _prepareRenderingGroup(renderingGroupId);
  23859. dispatchSprites(spriteManager: SpriteManager): void;
  23860. dispatchParticles(particleSystem: IParticleSystem): void;
  23861. /**
  23862. * @param subMesh The submesh to dispatch
  23863. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  23864. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  23865. */
  23866. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  23867. /**
  23868. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23869. * This allowed control for front to back rendering or reversly depending of the special needs.
  23870. *
  23871. * @param renderingGroupId The rendering group id corresponding to its index
  23872. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23873. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23874. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23875. */
  23876. 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;
  23877. /**
  23878. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23879. *
  23880. * @param renderingGroupId The rendering group id corresponding to its index
  23881. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23882. * @param depth Automatically clears depth between groups if true and autoClear is true.
  23883. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  23884. */
  23885. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  23886. }
  23887. }
  23888. declare module BABYLON {
  23889. class Sprite {
  23890. name: string;
  23891. position: Vector3;
  23892. color: Color4;
  23893. width: number;
  23894. height: number;
  23895. angle: number;
  23896. cellIndex: number;
  23897. invertU: number;
  23898. invertV: number;
  23899. disposeWhenFinishedAnimating: boolean;
  23900. animations: Animation[];
  23901. isPickable: boolean;
  23902. actionManager: ActionManager;
  23903. private _animationStarted;
  23904. private _loopAnimation;
  23905. private _fromIndex;
  23906. private _toIndex;
  23907. private _delay;
  23908. private _direction;
  23909. private _manager;
  23910. private _time;
  23911. private _onAnimationEnd;
  23912. size: number;
  23913. constructor(name: string, manager: SpriteManager);
  23914. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  23915. stopAnimation(): void;
  23916. _animate(deltaTime: number): void;
  23917. dispose(): void;
  23918. }
  23919. }
  23920. declare module BABYLON {
  23921. class SpriteManager {
  23922. name: string;
  23923. sprites: Sprite[];
  23924. renderingGroupId: number;
  23925. layerMask: number;
  23926. fogEnabled: boolean;
  23927. isPickable: boolean;
  23928. cellWidth: number;
  23929. cellHeight: number;
  23930. /**
  23931. * An event triggered when the manager is disposed.
  23932. */
  23933. onDisposeObservable: Observable<SpriteManager>;
  23934. private _onDisposeObserver;
  23935. onDispose: () => void;
  23936. private _capacity;
  23937. private _spriteTexture;
  23938. private _epsilon;
  23939. private _scene;
  23940. private _vertexData;
  23941. private _buffer;
  23942. private _vertexBuffers;
  23943. private _indexBuffer;
  23944. private _effectBase;
  23945. private _effectFog;
  23946. texture: Texture;
  23947. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  23948. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  23949. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  23950. render(): void;
  23951. dispose(): void;
  23952. }
  23953. }
  23954. declare module BABYLON {
  23955. class _AlphaState {
  23956. private _isAlphaBlendDirty;
  23957. private _isBlendFunctionParametersDirty;
  23958. private _isBlendEquationParametersDirty;
  23959. private _isBlendConstantsDirty;
  23960. private _alphaBlend;
  23961. private _blendFunctionParameters;
  23962. private _blendEquationParameters;
  23963. private _blendConstants;
  23964. /**
  23965. * Initializes the state.
  23966. */
  23967. constructor();
  23968. readonly isDirty: boolean;
  23969. alphaBlend: boolean;
  23970. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  23971. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  23972. setAlphaEquationParameters(rgb: number, alpha: number): void;
  23973. reset(): void;
  23974. apply(gl: WebGLRenderingContext): void;
  23975. }
  23976. }
  23977. declare module BABYLON {
  23978. class _DepthCullingState {
  23979. private _isDepthTestDirty;
  23980. private _isDepthMaskDirty;
  23981. private _isDepthFuncDirty;
  23982. private _isCullFaceDirty;
  23983. private _isCullDirty;
  23984. private _isZOffsetDirty;
  23985. private _isFrontFaceDirty;
  23986. private _depthTest;
  23987. private _depthMask;
  23988. private _depthFunc;
  23989. private _cull;
  23990. private _cullFace;
  23991. private _zOffset;
  23992. private _frontFace;
  23993. /**
  23994. * Initializes the state.
  23995. */
  23996. constructor();
  23997. readonly isDirty: boolean;
  23998. zOffset: number;
  23999. cullFace: Nullable<number>;
  24000. cull: Nullable<boolean>;
  24001. depthFunc: Nullable<number>;
  24002. depthMask: boolean;
  24003. depthTest: boolean;
  24004. frontFace: Nullable<number>;
  24005. reset(): void;
  24006. apply(gl: WebGLRenderingContext): void;
  24007. }
  24008. }
  24009. declare module BABYLON {
  24010. class _StencilState {
  24011. private _isStencilTestDirty;
  24012. private _isStencilMaskDirty;
  24013. private _isStencilFuncDirty;
  24014. private _isStencilOpDirty;
  24015. private _stencilTest;
  24016. private _stencilMask;
  24017. private _stencilFunc;
  24018. private _stencilFuncRef;
  24019. private _stencilFuncMask;
  24020. private _stencilOpStencilFail;
  24021. private _stencilOpDepthFail;
  24022. private _stencilOpStencilDepthPass;
  24023. readonly isDirty: boolean;
  24024. stencilFunc: number;
  24025. stencilFuncRef: number;
  24026. stencilFuncMask: number;
  24027. stencilOpStencilFail: number;
  24028. stencilOpDepthFail: number;
  24029. stencilOpStencilDepthPass: number;
  24030. stencilMask: number;
  24031. stencilTest: boolean;
  24032. constructor();
  24033. reset(): void;
  24034. apply(gl: WebGLRenderingContext): void;
  24035. }
  24036. }
  24037. declare module BABYLON {
  24038. class AnaglyphPostProcess extends PostProcess {
  24039. private _passedProcess;
  24040. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  24041. }
  24042. }
  24043. declare module BABYLON {
  24044. class BlackAndWhitePostProcess extends PostProcess {
  24045. degree: number;
  24046. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  24047. }
  24048. }
  24049. declare module BABYLON {
  24050. /**
  24051. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  24052. */
  24053. class BloomEffect extends PostProcessRenderEffect {
  24054. private bloomScale;
  24055. /**
  24056. * Internal
  24057. */
  24058. _effects: Array<PostProcess>;
  24059. /**
  24060. * Internal
  24061. */
  24062. _downscale: ExtractHighlightsPostProcess;
  24063. private _blurX;
  24064. private _blurY;
  24065. private _merge;
  24066. /**
  24067. * The luminance threshold to find bright areas of the image to bloom.
  24068. */
  24069. threshold: number;
  24070. /**
  24071. * The strength of the bloom.
  24072. */
  24073. weight: number;
  24074. /**
  24075. * Specifies the size of the bloom blur kernel, relative to the final output size
  24076. */
  24077. kernel: number;
  24078. /**
  24079. * Creates a new instance of @see BloomEffect
  24080. * @param scene The scene the effect belongs to.
  24081. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  24082. * @param bloomKernel The size of the kernel to be used when applying the blur.
  24083. * @param bloomWeight The the strength of bloom.
  24084. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  24085. * @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)
  24086. */
  24087. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  24088. /**
  24089. * Disposes each of the internal effects for a given camera.
  24090. * @param camera The camera to dispose the effect on.
  24091. */
  24092. disposeEffects(camera: Camera): void;
  24093. /**
  24094. * Internal
  24095. */
  24096. _updateEffects(): void;
  24097. /**
  24098. * Internal
  24099. * @returns if all the contained post processes are ready.
  24100. */
  24101. _isReady(): boolean;
  24102. }
  24103. }
  24104. declare module BABYLON {
  24105. /**
  24106. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  24107. */
  24108. class BloomMergePostProcess extends PostProcess {
  24109. /** Weight of the bloom to be added to the original input. */ weight: number;
  24110. /**
  24111. * Creates a new instance of @see BloomMergePostProcess
  24112. * @param name The name of the effect.
  24113. * @param originalFromInput Post process which's input will be used for the merge.
  24114. * @param blurred Blurred highlights post process which's output will be used.
  24115. * @param weight Weight of the bloom to be added to the original input.
  24116. * @param options The required width/height ratio to downsize to before computing the render pass.
  24117. * @param camera The camera to apply the render pass to.
  24118. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24119. * @param engine The engine which the post process will be applied. (default: current engine)
  24120. * @param reusable If the post process can be reused on the same frame. (default: false)
  24121. * @param textureType Type of textures used when performing the post process. (default: 0)
  24122. * @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)
  24123. */
  24124. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess, /** Weight of the bloom to be added to the original input. */ weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  24125. }
  24126. }
  24127. declare module BABYLON {
  24128. /**
  24129. * The Blur Post Process which blurs an image based on a kernel and direction.
  24130. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  24131. */
  24132. class BlurPostProcess extends PostProcess {
  24133. /** The direction in which to blur the image. */ direction: Vector2;
  24134. private blockCompilation;
  24135. protected _kernel: number;
  24136. protected _idealKernel: number;
  24137. protected _packedFloat: boolean;
  24138. private _staticDefines;
  24139. /**
  24140. * Gets the length in pixels of the blur sample region
  24141. */
  24142. /**
  24143. * Sets the length in pixels of the blur sample region
  24144. */
  24145. kernel: number;
  24146. /**
  24147. * Gets wether or not the blur is unpacking/repacking floats
  24148. */
  24149. /**
  24150. * Sets wether or not the blur needs to unpack/repack floats
  24151. */
  24152. packedFloat: boolean;
  24153. /**
  24154. * Creates a new instance BlurPostProcess
  24155. * @param name The name of the effect.
  24156. * @param direction The direction in which to blur the image.
  24157. * @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.
  24158. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24159. * @param camera The camera to apply the render pass to.
  24160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24161. * @param engine The engine which the post process will be applied. (default: current engine)
  24162. * @param reusable If the post process can be reused on the same frame. (default: false)
  24163. * @param textureType Type of textures used when performing the post process. (default: 0)
  24164. * @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)
  24165. */
  24166. constructor(name: string, /** The direction in which to blur the image. */ direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  24167. /**
  24168. * Updates the effect with the current post process compile time values and recompiles the shader.
  24169. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24170. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24171. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24172. * @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
  24173. * @param onCompiled Called when the shader has been compiled.
  24174. * @param onError Called if there is an error when compiling a shader.
  24175. */
  24176. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24177. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24178. /**
  24179. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  24180. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  24181. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  24182. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  24183. * The gaps between physical kernels are compensated for in the weighting of the samples
  24184. * @param idealKernel Ideal blur kernel.
  24185. * @return Nearest best kernel.
  24186. */
  24187. protected _nearestBestKernel(idealKernel: number): number;
  24188. /**
  24189. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  24190. * @param x The point on the Gaussian distribution to sample.
  24191. * @return the value of the Gaussian function at x.
  24192. */
  24193. protected _gaussianWeight(x: number): number;
  24194. /**
  24195. * Generates a string that can be used as a floating point number in GLSL.
  24196. * @param x Value to print.
  24197. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  24198. * @return GLSL float string.
  24199. */
  24200. protected _glslFloat(x: number, decimalFigures?: number): string;
  24201. }
  24202. }
  24203. declare module BABYLON {
  24204. /**
  24205. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  24206. */
  24207. class ChromaticAberrationPostProcess extends PostProcess {
  24208. /**
  24209. * The amount of seperation of rgb channels (default: 30)
  24210. */
  24211. aberrationAmount: number;
  24212. /**
  24213. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  24214. */
  24215. radialIntensity: number;
  24216. /**
  24217. * 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))
  24218. */
  24219. direction: Vector2;
  24220. /**
  24221. * 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))
  24222. */
  24223. centerPosition: Vector2;
  24224. /**
  24225. * Creates a new instance ChromaticAberrationPostProcess
  24226. * @param name The name of the effect.
  24227. * @param screenWidth The width of the screen to apply the effect on.
  24228. * @param screenHeight The height of the screen to apply the effect on.
  24229. * @param options The required width/height ratio to downsize to before computing the render pass.
  24230. * @param camera The camera to apply the render pass to.
  24231. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24232. * @param engine The engine which the post process will be applied. (default: current engine)
  24233. * @param reusable If the post process can be reused on the same frame. (default: false)
  24234. * @param textureType Type of textures used when performing the post process. (default: 0)
  24235. * @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)
  24236. */
  24237. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  24238. }
  24239. }
  24240. declare module BABYLON {
  24241. /**
  24242. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  24243. */
  24244. class CircleOfConfusionPostProcess extends PostProcess {
  24245. /**
  24246. * 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.
  24247. */
  24248. lensSize: number;
  24249. /**
  24250. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  24251. */
  24252. fStop: number;
  24253. /**
  24254. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  24255. */
  24256. focusDistance: number;
  24257. /**
  24258. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  24259. */
  24260. focalLength: number;
  24261. private _depthTexture;
  24262. /**
  24263. * Creates a new instance CircleOfConfusionPostProcess
  24264. * @param name The name of the effect.
  24265. * @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.
  24266. * @param options The required width/height ratio to downsize to before computing the render pass.
  24267. * @param camera The camera to apply the render pass to.
  24268. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24269. * @param engine The engine which the post process will be applied. (default: current engine)
  24270. * @param reusable If the post process can be reused on the same frame. (default: false)
  24271. * @param textureType Type of textures used when performing the post process. (default: 0)
  24272. * @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)
  24273. */
  24274. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  24275. /**
  24276. * 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.
  24277. */
  24278. depthTexture: RenderTargetTexture;
  24279. }
  24280. }
  24281. declare module BABYLON {
  24282. class ColorCorrectionPostProcess extends PostProcess {
  24283. private _colorTableTexture;
  24284. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  24285. }
  24286. }
  24287. declare module BABYLON {
  24288. /**
  24289. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  24290. * input texture to perform effects such as edge detection or sharpening
  24291. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  24292. */
  24293. class ConvolutionPostProcess extends PostProcess {
  24294. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  24295. /**
  24296. * Creates a new instance ConvolutionPostProcess
  24297. * @param name The name of the effect.
  24298. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  24299. * @param options The required width/height ratio to downsize to before computing the render pass.
  24300. * @param camera The camera to apply the render pass to.
  24301. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24302. * @param engine The engine which the post process will be applied. (default: current engine)
  24303. * @param reusable If the post process can be reused on the same frame. (default: false)
  24304. * @param textureType Type of textures used when performing the post process. (default: 0)
  24305. */
  24306. constructor(name: string, /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24307. /**
  24308. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  24309. */
  24310. static EdgeDetect0Kernel: number[];
  24311. /**
  24312. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  24313. */
  24314. static EdgeDetect1Kernel: number[];
  24315. /**
  24316. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  24317. */
  24318. static EdgeDetect2Kernel: number[];
  24319. /**
  24320. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  24321. */
  24322. static SharpenKernel: number[];
  24323. /**
  24324. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  24325. */
  24326. static EmbossKernel: number[];
  24327. /**
  24328. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  24329. */
  24330. static GaussianKernel: number[];
  24331. }
  24332. }
  24333. declare module BABYLON {
  24334. /**
  24335. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  24336. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  24337. * based on samples that have a large difference in distance than the center pixel.
  24338. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  24339. */
  24340. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  24341. direction: Vector2;
  24342. /**
  24343. * Creates a new instance CircleOfConfusionPostProcess
  24344. * @param name The name of the effect.
  24345. * @param scene The scene the effect belongs to.
  24346. * @param direction The direction the blur should be applied.
  24347. * @param kernel The size of the kernel used to blur.
  24348. * @param options The required width/height ratio to downsize to before computing the render pass.
  24349. * @param camera The camera to apply the render pass to.
  24350. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  24351. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  24352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24353. * @param engine The engine which the post process will be applied. (default: current engine)
  24354. * @param reusable If the post process can be reused on the same frame. (default: false)
  24355. * @param textureType Type of textures used when performing the post process. (default: 0)
  24356. * @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)
  24357. */
  24358. 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);
  24359. }
  24360. }
  24361. declare module BABYLON {
  24362. /**
  24363. * Specifies the level of max blur that should be applied when using the depth of field effect
  24364. */
  24365. enum DepthOfFieldEffectBlurLevel {
  24366. /**
  24367. * Subtle blur
  24368. */
  24369. Low = 0,
  24370. /**
  24371. * Medium blur
  24372. */
  24373. Medium = 1,
  24374. /**
  24375. * Large blur
  24376. */
  24377. High = 2,
  24378. }
  24379. /**
  24380. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  24381. */
  24382. class DepthOfFieldEffect extends PostProcessRenderEffect {
  24383. private _circleOfConfusion;
  24384. /**
  24385. * Internal, blurs from high to low
  24386. */
  24387. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  24388. private _depthOfFieldBlurY;
  24389. private _dofMerge;
  24390. /**
  24391. * Internal post processes in depth of field effect
  24392. */
  24393. _effects: Array<PostProcess>;
  24394. /**
  24395. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  24396. */
  24397. focalLength: number;
  24398. /**
  24399. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  24400. */
  24401. fStop: number;
  24402. /**
  24403. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  24404. */
  24405. focusDistance: number;
  24406. /**
  24407. * 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.
  24408. */
  24409. lensSize: number;
  24410. /**
  24411. * Creates a new instance DepthOfFieldEffect
  24412. * @param scene The scene the effect belongs to.
  24413. * @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.
  24414. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  24415. * @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)
  24416. */
  24417. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  24418. /**
  24419. * 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.
  24420. */
  24421. depthTexture: RenderTargetTexture;
  24422. /**
  24423. * Disposes each of the internal effects for a given camera.
  24424. * @param camera The camera to dispose the effect on.
  24425. */
  24426. disposeEffects(camera: Camera): void;
  24427. /**
  24428. * Internal
  24429. */
  24430. _updateEffects(): void;
  24431. /**
  24432. * Internal
  24433. * @returns if all the contained post processes are ready.
  24434. */
  24435. _isReady(): boolean;
  24436. }
  24437. }
  24438. declare module BABYLON {
  24439. /**
  24440. * Options to be set when merging outputs from the default pipeline.
  24441. */
  24442. class DepthOfFieldMergePostProcessOptions {
  24443. /**
  24444. * The original image to merge on top of
  24445. */
  24446. originalFromInput: PostProcess;
  24447. /**
  24448. * Parameters to perform the merge of the depth of field effect
  24449. */
  24450. depthOfField?: {
  24451. circleOfConfusion: PostProcess;
  24452. blurSteps: Array<PostProcess>;
  24453. };
  24454. /**
  24455. * Parameters to perform the merge of bloom effect
  24456. */
  24457. bloom?: {
  24458. blurred: PostProcess;
  24459. weight: number;
  24460. };
  24461. }
  24462. /**
  24463. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  24464. */
  24465. class DepthOfFieldMergePostProcess extends PostProcess {
  24466. private blurSteps;
  24467. /**
  24468. * Creates a new instance of DepthOfFieldMergePostProcess
  24469. * @param name The name of the effect.
  24470. * @param originalFromInput Post process which's input will be used for the merge.
  24471. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  24472. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  24473. * @param options The required width/height ratio to downsize to before computing the render pass.
  24474. * @param camera The camera to apply the render pass to.
  24475. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24476. * @param engine The engine which the post process will be applied. (default: current engine)
  24477. * @param reusable If the post process can be reused on the same frame. (default: false)
  24478. * @param textureType Type of textures used when performing the post process. (default: 0)
  24479. * @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)
  24480. */
  24481. 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);
  24482. /**
  24483. * Updates the effect with the current post process compile time values and recompiles the shader.
  24484. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24485. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24486. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24487. * @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
  24488. * @param onCompiled Called when the shader has been compiled.
  24489. * @param onError Called if there is an error when compiling a shader.
  24490. */
  24491. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24492. }
  24493. }
  24494. declare module BABYLON {
  24495. class DisplayPassPostProcess extends PostProcess {
  24496. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  24497. }
  24498. }
  24499. declare module BABYLON {
  24500. /**
  24501. * 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.
  24502. */
  24503. class ExtractHighlightsPostProcess extends PostProcess {
  24504. /**
  24505. * The luminance threshold, pixels below this value will be set to black.
  24506. */
  24507. threshold: number;
  24508. /**
  24509. * Internal
  24510. */
  24511. _exposure: number;
  24512. /**
  24513. * Post process which has the input texture to be used when performing highlight extraction
  24514. */
  24515. _inputPostProcess: Nullable<PostProcess>;
  24516. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  24517. }
  24518. }
  24519. declare module BABYLON {
  24520. class FilterPostProcess extends PostProcess {
  24521. kernelMatrix: Matrix;
  24522. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  24523. }
  24524. }
  24525. declare module BABYLON {
  24526. class FxaaPostProcess extends PostProcess {
  24527. texelWidth: number;
  24528. texelHeight: number;
  24529. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24530. }
  24531. }
  24532. declare module BABYLON {
  24533. /**
  24534. * The GrainPostProcess adds noise to the image at mid luminance levels
  24535. */
  24536. class GrainPostProcess extends PostProcess {
  24537. /**
  24538. * The intensity of the grain added (default: 30)
  24539. */
  24540. intensity: number;
  24541. /**
  24542. * If the grain should be randomized on every frame
  24543. */
  24544. animated: boolean;
  24545. /**
  24546. * Creates a new instance of @see GrainPostProcess
  24547. * @param name The name of the effect.
  24548. * @param options The required width/height ratio to downsize to before computing the render pass.
  24549. * @param camera The camera to apply the render pass to.
  24550. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24551. * @param engine The engine which the post process will be applied. (default: current engine)
  24552. * @param reusable If the post process can be reused on the same frame. (default: false)
  24553. * @param textureType Type of textures used when performing the post process. (default: 0)
  24554. * @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)
  24555. */
  24556. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  24557. }
  24558. }
  24559. declare module BABYLON {
  24560. class HighlightsPostProcess extends PostProcess {
  24561. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24562. }
  24563. }
  24564. declare module BABYLON {
  24565. class ImageProcessingPostProcess extends PostProcess {
  24566. /**
  24567. * Default configuration related to image processing available in the PBR Material.
  24568. */
  24569. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24570. /**
  24571. * Gets the image processing configuration used either in this material.
  24572. */
  24573. /**
  24574. * Sets the Default image processing configuration used either in the this material.
  24575. *
  24576. * If sets to null, the scene one is in use.
  24577. */
  24578. imageProcessingConfiguration: ImageProcessingConfiguration;
  24579. /**
  24580. * Keep track of the image processing observer to allow dispose and replace.
  24581. */
  24582. private _imageProcessingObserver;
  24583. /**
  24584. * Attaches a new image processing configuration to the PBR Material.
  24585. * @param configuration
  24586. */
  24587. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24588. /**
  24589. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24590. */
  24591. /**
  24592. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24593. */
  24594. colorCurves: Nullable<ColorCurves>;
  24595. /**
  24596. * Gets wether the color curves effect is enabled.
  24597. */
  24598. /**
  24599. * Sets wether the color curves effect is enabled.
  24600. */
  24601. colorCurvesEnabled: boolean;
  24602. /**
  24603. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24604. */
  24605. /**
  24606. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24607. */
  24608. colorGradingTexture: Nullable<BaseTexture>;
  24609. /**
  24610. * Gets wether the color grading effect is enabled.
  24611. */
  24612. /**
  24613. * Gets wether the color grading effect is enabled.
  24614. */
  24615. colorGradingEnabled: boolean;
  24616. /**
  24617. * Gets exposure used in the effect.
  24618. */
  24619. /**
  24620. * Sets exposure used in the effect.
  24621. */
  24622. exposure: number;
  24623. /**
  24624. * Gets wether tonemapping is enabled or not.
  24625. */
  24626. /**
  24627. * Sets wether tonemapping is enabled or not
  24628. */
  24629. toneMappingEnabled: boolean;
  24630. /**
  24631. * Gets contrast used in the effect.
  24632. */
  24633. /**
  24634. * Sets contrast used in the effect.
  24635. */
  24636. contrast: number;
  24637. /**
  24638. * Gets Vignette stretch size.
  24639. */
  24640. /**
  24641. * Sets Vignette stretch size.
  24642. */
  24643. vignetteStretch: number;
  24644. /**
  24645. * Gets Vignette centre X Offset.
  24646. */
  24647. /**
  24648. * Sets Vignette centre X Offset.
  24649. */
  24650. vignetteCentreX: number;
  24651. /**
  24652. * Gets Vignette centre Y Offset.
  24653. */
  24654. /**
  24655. * Sets Vignette centre Y Offset.
  24656. */
  24657. vignetteCentreY: number;
  24658. /**
  24659. * Gets Vignette weight or intensity of the vignette effect.
  24660. */
  24661. /**
  24662. * Sets Vignette weight or intensity of the vignette effect.
  24663. */
  24664. vignetteWeight: number;
  24665. /**
  24666. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24667. * if vignetteEnabled is set to true.
  24668. */
  24669. /**
  24670. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24671. * if vignetteEnabled is set to true.
  24672. */
  24673. vignetteColor: Color4;
  24674. /**
  24675. * Gets Camera field of view used by the Vignette effect.
  24676. */
  24677. /**
  24678. * Sets Camera field of view used by the Vignette effect.
  24679. */
  24680. vignetteCameraFov: number;
  24681. /**
  24682. * Gets the vignette blend mode allowing different kind of effect.
  24683. */
  24684. /**
  24685. * Sets the vignette blend mode allowing different kind of effect.
  24686. */
  24687. vignetteBlendMode: number;
  24688. /**
  24689. * Gets wether the vignette effect is enabled.
  24690. */
  24691. /**
  24692. * Sets wether the vignette effect is enabled.
  24693. */
  24694. vignetteEnabled: boolean;
  24695. private _fromLinearSpace;
  24696. /**
  24697. * Gets wether the input of the processing is in Gamma or Linear Space.
  24698. */
  24699. /**
  24700. * Sets wether the input of the processing is in Gamma or Linear Space.
  24701. */
  24702. fromLinearSpace: boolean;
  24703. /**
  24704. * Defines cache preventing GC.
  24705. */
  24706. private _defines;
  24707. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24708. getClassName(): string;
  24709. protected _updateParameters(): void;
  24710. dispose(camera?: Camera): void;
  24711. }
  24712. }
  24713. declare module BABYLON {
  24714. class PassPostProcess extends PostProcess {
  24715. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  24716. }
  24717. }
  24718. declare module BABYLON {
  24719. type PostProcessOptions = {
  24720. width: number;
  24721. height: number;
  24722. };
  24723. /**
  24724. * PostProcess can be used to apply a shader to a texture after it has been rendered
  24725. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24726. */
  24727. class PostProcess {
  24728. /** Name of the PostProcess. */ name: string;
  24729. /**
  24730. * Width of the texture to apply the post process on
  24731. */
  24732. width: number;
  24733. /**
  24734. * Height of the texture to apply the post process on
  24735. */
  24736. height: number;
  24737. /**
  24738. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  24739. */
  24740. _outputTexture: Nullable<InternalTexture>;
  24741. /**
  24742. * Sampling mode used by the shader
  24743. * See https://doc.babylonjs.com/classes/3.1/texture
  24744. */
  24745. renderTargetSamplingMode: number;
  24746. /**
  24747. * Clear color to use when screen clearing
  24748. */
  24749. clearColor: Color4;
  24750. /**
  24751. * If the buffer needs to be cleared before applying the post process. (default: true)
  24752. * Should be set to false if shader will overwrite all previous pixels.
  24753. */
  24754. autoClear: boolean;
  24755. /**
  24756. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  24757. */
  24758. alphaMode: number;
  24759. /**
  24760. * Sets the setAlphaBlendConstants of the babylon engine
  24761. */
  24762. alphaConstants: Color4;
  24763. /**
  24764. * Animations to be used for the post processing
  24765. */
  24766. animations: Animation[];
  24767. /**
  24768. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  24769. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  24770. */
  24771. enablePixelPerfectMode: boolean;
  24772. /**
  24773. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  24774. */
  24775. scaleMode: number;
  24776. /**
  24777. * Force textures to be a power of two (default: false)
  24778. */
  24779. alwaysForcePOT: boolean;
  24780. /**
  24781. * Number of sample textures (default: 1)
  24782. */
  24783. samples: number;
  24784. /**
  24785. * Modify the scale of the post process to be the same as the viewport (default: false)
  24786. */
  24787. adaptScaleToCurrentViewport: boolean;
  24788. private _camera;
  24789. private _scene;
  24790. private _engine;
  24791. private _options;
  24792. private _reusable;
  24793. private _textureType;
  24794. /**
  24795. * Smart array of input and output textures for the post process.
  24796. */
  24797. _textures: SmartArray<InternalTexture>;
  24798. /**
  24799. * The index in _textures that corresponds to the output texture.
  24800. */
  24801. _currentRenderTextureInd: number;
  24802. private _effect;
  24803. private _samplers;
  24804. private _fragmentUrl;
  24805. private _vertexUrl;
  24806. private _parameters;
  24807. private _scaleRatio;
  24808. protected _indexParameters: any;
  24809. private _shareOutputWithPostProcess;
  24810. private _texelSize;
  24811. private _forcedOutputTexture;
  24812. /**
  24813. * An event triggered when the postprocess is activated.
  24814. */
  24815. onActivateObservable: Observable<Camera>;
  24816. private _onActivateObserver;
  24817. /**
  24818. * A function that is added to the onActivateObservable
  24819. */
  24820. onActivate: Nullable<(camera: Camera) => void>;
  24821. /**
  24822. * An event triggered when the postprocess changes its size.
  24823. */
  24824. onSizeChangedObservable: Observable<PostProcess>;
  24825. private _onSizeChangedObserver;
  24826. /**
  24827. * A function that is added to the onSizeChangedObservable
  24828. */
  24829. onSizeChanged: (postProcess: PostProcess) => void;
  24830. /**
  24831. * An event triggered when the postprocess applies its effect.
  24832. */
  24833. onApplyObservable: Observable<Effect>;
  24834. private _onApplyObserver;
  24835. /**
  24836. * A function that is added to the onApplyObservable
  24837. */
  24838. onApply: (effect: Effect) => void;
  24839. /**
  24840. * An event triggered before rendering the postprocess
  24841. */
  24842. onBeforeRenderObservable: Observable<Effect>;
  24843. private _onBeforeRenderObserver;
  24844. /**
  24845. * A function that is added to the onBeforeRenderObservable
  24846. */
  24847. onBeforeRender: (effect: Effect) => void;
  24848. /**
  24849. * An event triggered after rendering the postprocess
  24850. */
  24851. onAfterRenderObservable: Observable<Effect>;
  24852. private _onAfterRenderObserver;
  24853. /**
  24854. * A function that is added to the onAfterRenderObservable
  24855. */
  24856. onAfterRender: (efect: Effect) => void;
  24857. /**
  24858. * 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
  24859. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  24860. */
  24861. inputTexture: InternalTexture;
  24862. /**
  24863. * Gets the camera which post process is applied to.
  24864. * @returns The camera the post process is applied to.
  24865. */
  24866. getCamera(): Camera;
  24867. /**
  24868. * Gets the texel size of the postprocess.
  24869. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  24870. */
  24871. readonly texelSize: Vector2;
  24872. /**
  24873. * Creates a new instance PostProcess
  24874. * @param name The name of the PostProcess.
  24875. * @param fragmentUrl The url of the fragment shader to be used.
  24876. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  24877. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  24878. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24879. * @param camera The camera to apply the render pass to.
  24880. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24881. * @param engine The engine which the post process will be applied. (default: current engine)
  24882. * @param reusable If the post process can be reused on the same frame. (default: false)
  24883. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  24884. * @param textureType Type of textures used when performing the post process. (default: 0)
  24885. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  24886. * @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
  24887. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  24888. */
  24889. constructor(/** Name of the PostProcess. */ 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);
  24890. /**
  24891. * Gets the engine which this post process belongs to.
  24892. * @returns The engine the post process was enabled with.
  24893. */
  24894. getEngine(): Engine;
  24895. /**
  24896. * The effect that is created when initializing the post process.
  24897. * @returns The created effect corrisponding the the postprocess.
  24898. */
  24899. getEffect(): Effect;
  24900. /**
  24901. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  24902. * @param postProcess The post process to share the output with.
  24903. * @returns This post process.
  24904. */
  24905. shareOutputWith(postProcess: PostProcess): PostProcess;
  24906. /**
  24907. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  24908. * This should be called if the post process that shares output with this post process is disabled/disposed.
  24909. */
  24910. useOwnOutput(): void;
  24911. /**
  24912. * Updates the effect with the current post process compile time values and recompiles the shader.
  24913. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24914. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24915. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24916. * @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
  24917. * @param onCompiled Called when the shader has been compiled.
  24918. * @param onError Called if there is an error when compiling a shader.
  24919. */
  24920. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24921. /**
  24922. * The post process is reusable if it can be used multiple times within one frame.
  24923. * @returns If the post process is reusable
  24924. */
  24925. isReusable(): boolean;
  24926. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  24927. markTextureDirty(): void;
  24928. /**
  24929. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  24930. * 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.
  24931. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  24932. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  24933. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  24934. * @returns The target texture that was bound to be written to.
  24935. */
  24936. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  24937. /**
  24938. * If the post process is supported.
  24939. */
  24940. readonly isSupported: boolean;
  24941. /**
  24942. * The aspect ratio of the output texture.
  24943. */
  24944. readonly aspectRatio: number;
  24945. /**
  24946. * Get a value indicating if the post-process is ready to be used
  24947. * @returns true if the post-process is ready (shader is compiled)
  24948. */
  24949. isReady(): boolean;
  24950. /**
  24951. * Binds all textures and uniforms to the shader, this will be run on every pass.
  24952. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  24953. */
  24954. apply(): Nullable<Effect>;
  24955. private _disposeTextures();
  24956. /**
  24957. * Disposes the post process.
  24958. * @param camera The camera to dispose the post process on.
  24959. */
  24960. dispose(camera?: Camera): void;
  24961. }
  24962. }
  24963. declare module BABYLON {
  24964. /**
  24965. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24966. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24967. */
  24968. class PostProcessManager {
  24969. private _scene;
  24970. private _indexBuffer;
  24971. private _vertexBuffers;
  24972. /**
  24973. * Creates a new instance PostProcess
  24974. * @param scene The scene that the post process is associated with.
  24975. */
  24976. constructor(scene: Scene);
  24977. private _prepareBuffers();
  24978. private _buildIndexBuffer();
  24979. /**
  24980. * Rebuilds the vertex buffers of the manager.
  24981. */
  24982. _rebuild(): void;
  24983. /**
  24984. * Prepares a frame to be run through a post process.
  24985. * @param sourceTexture The input texture to the post procesess. (default: null)
  24986. * @param postProcesses An array of post processes to be run. (default: null)
  24987. * @returns True if the post processes were able to be run.
  24988. */
  24989. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24990. /**
  24991. * Manually render a set of post processes to a texture.
  24992. * @param postProcesses An array of post processes to be run.
  24993. * @param targetTexture The target texture to render to.
  24994. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24995. */
  24996. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  24997. /**
  24998. * Finalize the result of the output of the postprocesses.
  24999. * @param doNotPresent If true the result will not be displayed to the screen.
  25000. * @param targetTexture The target texture to render to.
  25001. * @param faceIndex The index of the face to bind the target texture to.
  25002. * @param postProcesses The array of post processes to render.
  25003. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  25004. */
  25005. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  25006. /**
  25007. * Disposes of the post process manager.
  25008. */
  25009. dispose(): void;
  25010. }
  25011. }
  25012. declare module BABYLON {
  25013. class RefractionPostProcess extends PostProcess {
  25014. color: Color3;
  25015. depth: number;
  25016. colorLevel: number;
  25017. private _refTexture;
  25018. private _ownRefractionTexture;
  25019. /**
  25020. * Gets or sets the refraction texture
  25021. * Please note that you are responsible for disposing the texture if you set it manually
  25022. */
  25023. refractionTexture: Texture;
  25024. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25025. dispose(camera: Camera): void;
  25026. }
  25027. }
  25028. declare module BABYLON {
  25029. /**
  25030. * The SharpenPostProcess applies a sharpen kernel to every pixel
  25031. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  25032. */
  25033. class SharpenPostProcess extends PostProcess {
  25034. /**
  25035. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  25036. */
  25037. colorAmount: number;
  25038. /**
  25039. * How much sharpness should be applied (default: 0.3)
  25040. */
  25041. edgeAmount: number;
  25042. /**
  25043. * Creates a new instance ConvolutionPostProcess
  25044. * @param name The name of the effect.
  25045. * @param options The required width/height ratio to downsize to before computing the render pass.
  25046. * @param camera The camera to apply the render pass to.
  25047. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25048. * @param engine The engine which the post process will be applied. (default: current engine)
  25049. * @param reusable If the post process can be reused on the same frame. (default: false)
  25050. * @param textureType Type of textures used when performing the post process. (default: 0)
  25051. * @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)
  25052. */
  25053. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25054. }
  25055. }
  25056. declare module BABYLON {
  25057. class StereoscopicInterlacePostProcess extends PostProcess {
  25058. private _stepSize;
  25059. private _passedProcess;
  25060. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25061. }
  25062. }
  25063. declare module BABYLON {
  25064. enum TonemappingOperator {
  25065. Hable = 0,
  25066. Reinhard = 1,
  25067. HejiDawson = 2,
  25068. Photographic = 3,
  25069. }
  25070. class TonemapPostProcess extends PostProcess {
  25071. private _operator;
  25072. exposureAdjustment: number;
  25073. constructor(name: string, _operator: TonemappingOperator, exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  25074. }
  25075. }
  25076. declare module BABYLON {
  25077. class VolumetricLightScatteringPostProcess extends PostProcess {
  25078. private _volumetricLightScatteringPass;
  25079. private _volumetricLightScatteringRTT;
  25080. private _viewPort;
  25081. private _screenCoordinates;
  25082. private _cachedDefines;
  25083. /**
  25084. * If not undefined, the mesh position is computed from the attached node position
  25085. */
  25086. attachedNode: {
  25087. position: Vector3;
  25088. };
  25089. /**
  25090. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  25091. */
  25092. customMeshPosition: Vector3;
  25093. /**
  25094. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  25095. */
  25096. useCustomMeshPosition: boolean;
  25097. /**
  25098. * If the post-process should inverse the light scattering direction
  25099. */
  25100. invert: boolean;
  25101. /**
  25102. * The internal mesh used by the post-process
  25103. */
  25104. mesh: Mesh;
  25105. useDiffuseColor: boolean;
  25106. /**
  25107. * Array containing the excluded meshes not rendered in the internal pass
  25108. */
  25109. excludedMeshes: AbstractMesh[];
  25110. /**
  25111. * Controls the overall intensity of the post-process
  25112. */
  25113. exposure: number;
  25114. /**
  25115. * Dissipates each sample's contribution in range [0, 1]
  25116. */
  25117. decay: number;
  25118. /**
  25119. * Controls the overall intensity of each sample
  25120. */
  25121. weight: number;
  25122. /**
  25123. * Controls the density of each sample
  25124. */
  25125. density: number;
  25126. /**
  25127. * @constructor
  25128. * @param {string} name - The post-process name
  25129. * @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)
  25130. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  25131. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  25132. * @param {number} samples - The post-process quality, default 100
  25133. * @param {number} samplingMode - The post-process filtering mode
  25134. * @param {BABYLON.Engine} engine - The babylon engine
  25135. * @param {boolean} reusable - If the post-process is reusable
  25136. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  25137. */
  25138. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  25139. getClassName(): string;
  25140. private _isReady(subMesh, useInstances);
  25141. /**
  25142. * Sets the new light position for light scattering effect
  25143. * @param {BABYLON.Vector3} The new custom light position
  25144. */
  25145. setCustomMeshPosition(position: Vector3): void;
  25146. /**
  25147. * Returns the light position for light scattering effect
  25148. * @return {BABYLON.Vector3} The custom light position
  25149. */
  25150. getCustomMeshPosition(): Vector3;
  25151. /**
  25152. * Disposes the internal assets and detaches the post-process from the camera
  25153. */
  25154. dispose(camera: Camera): void;
  25155. /**
  25156. * Returns the render target texture used by the post-process
  25157. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  25158. */
  25159. getPass(): RenderTargetTexture;
  25160. private _meshExcluded(mesh);
  25161. private _createPass(scene, ratio);
  25162. private _updateMeshScreenCoordinates(scene);
  25163. /**
  25164. * Creates a default mesh for the Volumeric Light Scattering post-process
  25165. * @param {string} The mesh name
  25166. * @param {BABYLON.Scene} The scene where to create the mesh
  25167. * @return {BABYLON.Mesh} the default mesh
  25168. */
  25169. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  25170. }
  25171. }
  25172. declare module BABYLON {
  25173. class VRDistortionCorrectionPostProcess extends PostProcess {
  25174. private _isRightEye;
  25175. private _distortionFactors;
  25176. private _postProcessScaleFactor;
  25177. private _lensCenterOffset;
  25178. private _scaleIn;
  25179. private _scaleFactor;
  25180. private _lensCenter;
  25181. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  25182. }
  25183. }
  25184. declare module BABYLON {
  25185. class AndOrNotEvaluator {
  25186. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  25187. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  25188. private static _SimplifyNegation(booleanString);
  25189. }
  25190. }
  25191. declare module BABYLON {
  25192. /**
  25193. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  25194. */
  25195. enum AssetTaskState {
  25196. /**
  25197. * Initialization
  25198. */
  25199. INIT = 0,
  25200. /**
  25201. * Running
  25202. */
  25203. RUNNING = 1,
  25204. /**
  25205. * Done
  25206. */
  25207. DONE = 2,
  25208. /**
  25209. * Error
  25210. */
  25211. ERROR = 3,
  25212. }
  25213. /**
  25214. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  25215. */
  25216. abstract class AbstractAssetTask {
  25217. /**
  25218. * Task name
  25219. */ name: string;
  25220. /**
  25221. * Callback called when the task is successful
  25222. */
  25223. onSuccess: (task: any) => void;
  25224. /**
  25225. * Callback called when the task is not successful
  25226. */
  25227. onError: (task: any, message?: string, exception?: any) => void;
  25228. /**
  25229. * Creates a new {BABYLON.AssetsManager}
  25230. * @param name defines the name of the task
  25231. */
  25232. constructor(
  25233. /**
  25234. * Task name
  25235. */ name: string);
  25236. private _isCompleted;
  25237. private _taskState;
  25238. private _errorObject;
  25239. /**
  25240. * Get if the task is completed
  25241. */
  25242. readonly isCompleted: boolean;
  25243. /**
  25244. * Gets the current state of the task
  25245. */
  25246. readonly taskState: AssetTaskState;
  25247. /**
  25248. * Gets the current error object (if task is in error)
  25249. */
  25250. readonly errorObject: {
  25251. message?: string;
  25252. exception?: any;
  25253. };
  25254. /**
  25255. * Internal only
  25256. * @ignore
  25257. */
  25258. _setErrorObject(message?: string, exception?: any): void;
  25259. /**
  25260. * Execute the current task
  25261. * @param scene defines the scene where you want your assets to be loaded
  25262. * @param onSuccess is a callback called when the task is successfully executed
  25263. * @param onError is a callback called if an error occurs
  25264. */
  25265. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  25266. /**
  25267. * Execute the current task
  25268. * @param scene defines the scene where you want your assets to be loaded
  25269. * @param onSuccess is a callback called when the task is successfully executed
  25270. * @param onError is a callback called if an error occurs
  25271. */
  25272. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  25273. private onErrorCallback(onError, message?, exception?);
  25274. private onDoneCallback(onSuccess, onError);
  25275. }
  25276. /**
  25277. * Define the interface used by progress events raised during assets loading
  25278. */
  25279. interface IAssetsProgressEvent {
  25280. /**
  25281. * Defines the number of remaining tasks to process
  25282. */
  25283. remainingCount: number;
  25284. /**
  25285. * Defines the total number of tasks
  25286. */
  25287. totalCount: number;
  25288. /**
  25289. * Defines the task that was just processed
  25290. */
  25291. task: AbstractAssetTask;
  25292. }
  25293. /**
  25294. * Class used to share progress information about assets loading
  25295. */
  25296. class AssetsProgressEvent implements IAssetsProgressEvent {
  25297. /**
  25298. * Defines the number of remaining tasks to process
  25299. */
  25300. remainingCount: number;
  25301. /**
  25302. * Defines the total number of tasks
  25303. */
  25304. totalCount: number;
  25305. /**
  25306. * Defines the task that was just processed
  25307. */
  25308. task: AbstractAssetTask;
  25309. /**
  25310. * Creates a {BABYLON.AssetsProgressEvent}
  25311. * @param remainingCount defines the number of remaining tasks to process
  25312. * @param totalCount defines the total number of tasks
  25313. * @param task defines the task that was just processed
  25314. */
  25315. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  25316. }
  25317. /**
  25318. * Define a task used by {BABYLON.AssetsManager} to load meshes
  25319. */
  25320. class MeshAssetTask extends AbstractAssetTask {
  25321. /**
  25322. * Defines the name of the task
  25323. */
  25324. name: string;
  25325. /**
  25326. * Defines the list of mesh's names you want to load
  25327. */
  25328. meshesNames: any;
  25329. /**
  25330. * Defines the root url to use as a base to load your meshes and associated resources
  25331. */
  25332. rootUrl: string;
  25333. /**
  25334. * Defines the filename of the scene to load from
  25335. */
  25336. sceneFilename: string;
  25337. /**
  25338. * Gets the list of loaded meshes
  25339. */
  25340. loadedMeshes: Array<AbstractMesh>;
  25341. /**
  25342. * Gets the list of loaded particle systems
  25343. */
  25344. loadedParticleSystems: Array<ParticleSystem>;
  25345. /**
  25346. * Gets the list of loaded skeletons
  25347. */
  25348. loadedSkeletons: Array<Skeleton>;
  25349. /**
  25350. * Callback called when the task is successful
  25351. */
  25352. onSuccess: (task: MeshAssetTask) => void;
  25353. /**
  25354. * Callback called when the task is successful
  25355. */
  25356. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  25357. /**
  25358. * Creates a new {BABYLON.MeshAssetTask}
  25359. * @param name defines the name of the task
  25360. * @param meshesNames defines the list of mesh's names you want to load
  25361. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  25362. * @param sceneFilename defines the filename of the scene to load from
  25363. */
  25364. constructor(
  25365. /**
  25366. * Defines the name of the task
  25367. */
  25368. name: string,
  25369. /**
  25370. * Defines the list of mesh's names you want to load
  25371. */
  25372. meshesNames: any,
  25373. /**
  25374. * Defines the root url to use as a base to load your meshes and associated resources
  25375. */
  25376. rootUrl: string,
  25377. /**
  25378. * Defines the filename of the scene to load from
  25379. */
  25380. sceneFilename: string);
  25381. /**
  25382. * Execute the current task
  25383. * @param scene defines the scene where you want your assets to be loaded
  25384. * @param onSuccess is a callback called when the task is successfully executed
  25385. * @param onError is a callback called if an error occurs
  25386. */
  25387. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  25388. }
  25389. /**
  25390. * Define a task used by {BABYLON.AssetsManager} to load text content
  25391. */
  25392. class TextFileAssetTask extends AbstractAssetTask {
  25393. /**
  25394. * Defines the name of the task
  25395. */
  25396. name: string;
  25397. /**
  25398. * Defines the location of the file to load
  25399. */
  25400. url: string;
  25401. /**
  25402. * Gets the loaded text string
  25403. */
  25404. text: string;
  25405. /**
  25406. * Callback called when the task is successful
  25407. */
  25408. onSuccess: (task: TextFileAssetTask) => void;
  25409. /**
  25410. * Callback called when the task is successful
  25411. */
  25412. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  25413. /**
  25414. * Creates a new TextFileAssetTask object
  25415. * @param name defines the name of the task
  25416. * @param url defines the location of the file to load
  25417. */
  25418. constructor(
  25419. /**
  25420. * Defines the name of the task
  25421. */
  25422. name: string,
  25423. /**
  25424. * Defines the location of the file to load
  25425. */
  25426. url: string);
  25427. /**
  25428. * Execute the current task
  25429. * @param scene defines the scene where you want your assets to be loaded
  25430. * @param onSuccess is a callback called when the task is successfully executed
  25431. * @param onError is a callback called if an error occurs
  25432. */
  25433. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  25434. }
  25435. /**
  25436. * Define a task used by {BABYLON.AssetsManager} to load binary data
  25437. */
  25438. class BinaryFileAssetTask extends AbstractAssetTask {
  25439. /**
  25440. * Defines the name of the task
  25441. */
  25442. name: string;
  25443. /**
  25444. * Defines the location of the file to load
  25445. */
  25446. url: string;
  25447. /**
  25448. * Gets the lodaded data (as an array buffer)
  25449. */
  25450. data: ArrayBuffer;
  25451. /**
  25452. * Callback called when the task is successful
  25453. */
  25454. onSuccess: (task: BinaryFileAssetTask) => void;
  25455. /**
  25456. * Callback called when the task is successful
  25457. */
  25458. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  25459. /**
  25460. * Creates a new BinaryFileAssetTask object
  25461. * @param name defines the name of the new task
  25462. * @param url defines the location of the file to load
  25463. */
  25464. constructor(
  25465. /**
  25466. * Defines the name of the task
  25467. */
  25468. name: string,
  25469. /**
  25470. * Defines the location of the file to load
  25471. */
  25472. url: string);
  25473. /**
  25474. * Execute the current task
  25475. * @param scene defines the scene where you want your assets to be loaded
  25476. * @param onSuccess is a callback called when the task is successfully executed
  25477. * @param onError is a callback called if an error occurs
  25478. */
  25479. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  25480. }
  25481. /**
  25482. * Define a task used by {BABYLON.AssetsManager} to load images
  25483. */
  25484. class ImageAssetTask extends AbstractAssetTask {
  25485. /**
  25486. * Defines the name of the task
  25487. */
  25488. name: string;
  25489. /**
  25490. * Defines the location of the image to load
  25491. */
  25492. url: string;
  25493. /**
  25494. * Gets the loaded images
  25495. */
  25496. image: HTMLImageElement;
  25497. /**
  25498. * Callback called when the task is successful
  25499. */
  25500. onSuccess: (task: ImageAssetTask) => void;
  25501. /**
  25502. * Callback called when the task is successful
  25503. */
  25504. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  25505. /**
  25506. * Creates a new ImageAssetTask
  25507. * @param name defines the name of the task
  25508. * @param url defines the location of the image to load
  25509. */
  25510. constructor(
  25511. /**
  25512. * Defines the name of the task
  25513. */
  25514. name: string,
  25515. /**
  25516. * Defines the location of the image to load
  25517. */
  25518. url: string);
  25519. /**
  25520. * Execute the current task
  25521. * @param scene defines the scene where you want your assets to be loaded
  25522. * @param onSuccess is a callback called when the task is successfully executed
  25523. * @param onError is a callback called if an error occurs
  25524. */
  25525. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  25526. }
  25527. /**
  25528. * Defines the interface used by texture loading tasks
  25529. */
  25530. interface ITextureAssetTask<TEX extends BaseTexture> {
  25531. /**
  25532. * Gets the loaded texture
  25533. */
  25534. texture: TEX;
  25535. }
  25536. /**
  25537. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  25538. */
  25539. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  25540. /**
  25541. * Defines the name of the task
  25542. */
  25543. name: string;
  25544. /**
  25545. * Defines the location of the file to load
  25546. */
  25547. url: string;
  25548. /**
  25549. * Defines if mipmap should not be generated (default is false)
  25550. */
  25551. noMipmap: boolean | undefined;
  25552. /**
  25553. * Defines if texture must be inverted on Y axis (default is false)
  25554. */
  25555. invertY: boolean | undefined;
  25556. /**
  25557. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  25558. */
  25559. samplingMode: number;
  25560. /**
  25561. * Gets the loaded texture
  25562. */
  25563. texture: Texture;
  25564. /**
  25565. * Callback called when the task is successful
  25566. */
  25567. onSuccess: (task: TextureAssetTask) => void;
  25568. /**
  25569. * Callback called when the task is successful
  25570. */
  25571. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  25572. /**
  25573. * Creates a new TextureAssetTask object
  25574. * @param name defines the name of the task
  25575. * @param url defines the location of the file to load
  25576. * @param noMipmap defines if mipmap should not be generated (default is false)
  25577. * @param invertY defines if texture must be inverted on Y axis (default is false)
  25578. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  25579. */
  25580. constructor(
  25581. /**
  25582. * Defines the name of the task
  25583. */
  25584. name: string,
  25585. /**
  25586. * Defines the location of the file to load
  25587. */
  25588. url: string,
  25589. /**
  25590. * Defines if mipmap should not be generated (default is false)
  25591. */
  25592. noMipmap?: boolean | undefined,
  25593. /**
  25594. * Defines if texture must be inverted on Y axis (default is false)
  25595. */
  25596. invertY?: boolean | undefined,
  25597. /**
  25598. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  25599. */
  25600. samplingMode?: number);
  25601. /**
  25602. * Execute the current task
  25603. * @param scene defines the scene where you want your assets to be loaded
  25604. * @param onSuccess is a callback called when the task is successfully executed
  25605. * @param onError is a callback called if an error occurs
  25606. */
  25607. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  25608. }
  25609. /**
  25610. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  25611. */
  25612. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  25613. /**
  25614. * Defines the name of the task
  25615. */
  25616. name: string;
  25617. /**
  25618. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  25619. */
  25620. url: string;
  25621. /**
  25622. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  25623. */
  25624. extensions: string[] | undefined;
  25625. /**
  25626. * Defines if mipmaps should not be generated (default is false)
  25627. */
  25628. noMipmap: boolean | undefined;
  25629. /**
  25630. * Defines the explicit list of files (undefined by default)
  25631. */
  25632. files: string[] | undefined;
  25633. /**
  25634. * Gets the loaded texture
  25635. */
  25636. texture: CubeTexture;
  25637. /**
  25638. * Callback called when the task is successful
  25639. */
  25640. onSuccess: (task: CubeTextureAssetTask) => void;
  25641. /**
  25642. * Callback called when the task is successful
  25643. */
  25644. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  25645. /**
  25646. * Creates a new CubeTextureAssetTask
  25647. * @param name defines the name of the task
  25648. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  25649. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  25650. * @param noMipmap defines if mipmaps should not be generated (default is false)
  25651. * @param files defines the explicit list of files (undefined by default)
  25652. */
  25653. constructor(
  25654. /**
  25655. * Defines the name of the task
  25656. */
  25657. name: string,
  25658. /**
  25659. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  25660. */
  25661. url: string,
  25662. /**
  25663. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  25664. */
  25665. extensions?: string[] | undefined,
  25666. /**
  25667. * Defines if mipmaps should not be generated (default is false)
  25668. */
  25669. noMipmap?: boolean | undefined,
  25670. /**
  25671. * Defines the explicit list of files (undefined by default)
  25672. */
  25673. files?: string[] | undefined);
  25674. /**
  25675. * Execute the current task
  25676. * @param scene defines the scene where you want your assets to be loaded
  25677. * @param onSuccess is a callback called when the task is successfully executed
  25678. * @param onError is a callback called if an error occurs
  25679. */
  25680. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  25681. }
  25682. /**
  25683. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  25684. */
  25685. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  25686. /**
  25687. * Defines the name of the task
  25688. */
  25689. name: string;
  25690. /**
  25691. * Defines the location of the file to load
  25692. */
  25693. url: string;
  25694. /**
  25695. * 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.
  25696. */
  25697. size: number | undefined;
  25698. /**
  25699. * Defines if mipmaps should not be generated (default is false)
  25700. */
  25701. noMipmap: boolean;
  25702. /**
  25703. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  25704. */
  25705. generateHarmonics: boolean;
  25706. /**
  25707. * 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)
  25708. */
  25709. useInGammaSpace: boolean;
  25710. /**
  25711. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  25712. */
  25713. usePMREMGenerator: boolean;
  25714. /**
  25715. * Gets the loaded texture
  25716. */
  25717. texture: HDRCubeTexture;
  25718. /**
  25719. * Callback called when the task is successful
  25720. */
  25721. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  25722. /**
  25723. * Callback called when the task is successful
  25724. */
  25725. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  25726. /**
  25727. * Creates a new HDRCubeTextureAssetTask object
  25728. * @param name defines the name of the task
  25729. * @param url defines the location of the file to load
  25730. * @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.
  25731. * @param noMipmap defines if mipmaps should not be generated (default is false)
  25732. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  25733. * @param useInGammaSpace 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)
  25734. * @param usePMREMGenerator specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  25735. */
  25736. constructor(
  25737. /**
  25738. * Defines the name of the task
  25739. */
  25740. name: string,
  25741. /**
  25742. * Defines the location of the file to load
  25743. */
  25744. url: string,
  25745. /**
  25746. * 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.
  25747. */
  25748. size?: number | undefined,
  25749. /**
  25750. * Defines if mipmaps should not be generated (default is false)
  25751. */
  25752. noMipmap?: boolean,
  25753. /**
  25754. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  25755. */
  25756. generateHarmonics?: boolean,
  25757. /**
  25758. * 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)
  25759. */
  25760. useInGammaSpace?: boolean,
  25761. /**
  25762. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  25763. */
  25764. usePMREMGenerator?: boolean);
  25765. /**
  25766. * Execute the current task
  25767. * @param scene defines the scene where you want your assets to be loaded
  25768. * @param onSuccess is a callback called when the task is successfully executed
  25769. * @param onError is a callback called if an error occurs
  25770. */
  25771. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  25772. }
  25773. /**
  25774. * This class can be used to easily import assets into a scene
  25775. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  25776. */
  25777. class AssetsManager {
  25778. private _scene;
  25779. private _isLoading;
  25780. protected _tasks: AbstractAssetTask[];
  25781. protected _waitingTasksCount: number;
  25782. protected _totalTasksCount: number;
  25783. /**
  25784. * Callback called when all tasks are processed
  25785. */
  25786. onFinish: (tasks: AbstractAssetTask[]) => void;
  25787. /**
  25788. * Callback called when a task is successful
  25789. */
  25790. onTaskSuccess: (task: AbstractAssetTask) => void;
  25791. /**
  25792. * Callback called when a task had an error
  25793. */
  25794. onTaskError: (task: AbstractAssetTask) => void;
  25795. /**
  25796. * Callback called when a task is done (whatever the result is)
  25797. */
  25798. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  25799. /**
  25800. * Observable called when all tasks are processed
  25801. */
  25802. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  25803. /**
  25804. * Observable called when a task had an error
  25805. */
  25806. onTaskErrorObservable: Observable<AbstractAssetTask>;
  25807. /**
  25808. * Observable called when a task is successful
  25809. */
  25810. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  25811. /**
  25812. * Observable called when a task is done (whatever the result is)
  25813. */
  25814. onProgressObservable: Observable<IAssetsProgressEvent>;
  25815. /**
  25816. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  25817. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  25818. */
  25819. useDefaultLoadingScreen: boolean;
  25820. /**
  25821. * Creates a new AssetsManager
  25822. * @param scene defines the scene to work on
  25823. */
  25824. constructor(scene: Scene);
  25825. /**
  25826. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  25827. * @param taskName defines the name of the new task
  25828. * @param meshesNames defines the name of meshes to load
  25829. * @param rootUrl defines the root url to use to locate files
  25830. * @param sceneFilename defines the filename of the scene file
  25831. * @returns a new {BABYLON.MeshAssetTask} object
  25832. */
  25833. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  25834. /**
  25835. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  25836. * @param taskName defines the name of the new task
  25837. * @param url defines the url of the file to load
  25838. * @returns a new {BABYLON.TextFileAssetTask} object
  25839. */
  25840. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  25841. /**
  25842. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  25843. * @param taskName defines the name of the new task
  25844. * @param url defines the url of the file to load
  25845. * @returns a new {BABYLON.BinaryFileAssetTask} object
  25846. */
  25847. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  25848. /**
  25849. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  25850. * @param taskName defines the name of the new task
  25851. * @param url defines the url of the file to load
  25852. * @returns a new {BABYLON.ImageAssetTask} object
  25853. */
  25854. addImageTask(taskName: string, url: string): ImageAssetTask;
  25855. /**
  25856. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  25857. * @param taskName defines the name of the new task
  25858. * @param url defines the url of the file to load
  25859. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  25860. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  25861. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  25862. * @returns a new {BABYLON.TextureAssetTask} object
  25863. */
  25864. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  25865. /**
  25866. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  25867. * @param taskName defines the name of the new task
  25868. * @param url defines the url of the file to load
  25869. * @param extensions defines the extension to use to load the cube map (can be null)
  25870. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  25871. * @param files defines the list of files to load (can be null)
  25872. * @returns a new {BABYLON.CubeTextureAssetTask} object
  25873. */
  25874. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  25875. /**
  25876. *
  25877. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  25878. * @param taskName defines the name of the new task
  25879. * @param url defines the url of the file to load
  25880. * @param size defines the size you want for the cubemap (can be null)
  25881. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  25882. * @param generateHarmonics defines if you want to automatically generate (true by default)
  25883. * @param useInGammaSpace defines if the texture must be considered in gamma space (false by default)
  25884. * @param usePMREMGenerator is a reserved parameter and must be set to false or ignored
  25885. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  25886. */
  25887. addHDRCubeTextureTask(taskName: string, url: string, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean): HDRCubeTextureAssetTask;
  25888. private _decreaseWaitingTasksCount(task);
  25889. private _runTask(task);
  25890. /**
  25891. * Reset the {BABYLON.AssetsManager} and remove all tasks
  25892. * @return the current instance of the {BABYLON.AssetsManager}
  25893. */
  25894. reset(): AssetsManager;
  25895. /**
  25896. * Start the loading process
  25897. * @return the current instance of the {BABYLON.AssetsManager}
  25898. */
  25899. load(): AssetsManager;
  25900. }
  25901. }
  25902. declare module BABYLON {
  25903. class Database {
  25904. private callbackManifestChecked;
  25905. private currentSceneUrl;
  25906. private db;
  25907. private _enableSceneOffline;
  25908. private _enableTexturesOffline;
  25909. private manifestVersionFound;
  25910. private mustUpdateRessources;
  25911. private hasReachedQuota;
  25912. private isSupported;
  25913. private idbFactory;
  25914. static IsUASupportingBlobStorage: boolean;
  25915. static IDBStorageEnabled: boolean;
  25916. readonly enableSceneOffline: boolean;
  25917. readonly enableTexturesOffline: boolean;
  25918. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any);
  25919. static parseURL: (url: string) => string;
  25920. static ReturnFullUrlLocation: (url: string) => string;
  25921. checkManifestFile(): void;
  25922. openAsync(successCallback: () => void, errorCallback: () => void): void;
  25923. loadImageFromDB(url: string, image: HTMLImageElement): void;
  25924. private _loadImageFromDBAsync(url, image, notInDBCallback);
  25925. private _saveImageIntoDBAsync(url, image);
  25926. private _checkVersionFromDB(url, versionLoaded);
  25927. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  25928. private _saveVersionIntoDBAsync(url, callback);
  25929. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  25930. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  25931. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  25932. }
  25933. }
  25934. declare module BABYLON {
  25935. interface DDSInfo {
  25936. width: number;
  25937. height: number;
  25938. mipmapCount: number;
  25939. isFourCC: boolean;
  25940. isRGB: boolean;
  25941. isLuminance: boolean;
  25942. isCube: boolean;
  25943. isCompressed: boolean;
  25944. dxgiFormat: number;
  25945. textureType: number;
  25946. }
  25947. class DDSTools {
  25948. static StoreLODInAlphaChannel: boolean;
  25949. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  25950. private static _FloatView;
  25951. private static _Int32View;
  25952. private static _ToHalfFloat(value);
  25953. private static _FromHalfFloat(value);
  25954. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  25955. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  25956. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  25957. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  25958. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  25959. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  25960. private static _ExtractLongWordOrder(value);
  25961. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  25962. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  25963. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  25964. }
  25965. }
  25966. declare module BABYLON {
  25967. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  25968. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  25969. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  25970. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  25971. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  25972. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  25973. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  25974. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  25975. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  25976. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  25977. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  25978. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  25979. /**
  25980. * Decorator used to define property that can be serialized as reference to a camera
  25981. * @param sourceName defines the name of the property to decorate
  25982. */
  25983. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  25984. class SerializationHelper {
  25985. static Serialize<T>(entity: T, serializationObject?: any): any;
  25986. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  25987. static Clone<T>(creationFunction: () => T, source: T): T;
  25988. static Instanciate<T>(creationFunction: () => T, source: T): T;
  25989. }
  25990. }
  25991. declare module BABYLON {
  25992. /**
  25993. * Wrapper class for promise with external resolve and reject.
  25994. */
  25995. class Deferred<T> {
  25996. /**
  25997. * The promise associated with this deferred object.
  25998. */
  25999. readonly promise: Promise<T>;
  26000. private _resolve;
  26001. private _reject;
  26002. /**
  26003. * The resolve method of the promise associated with this deferred object.
  26004. */
  26005. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  26006. /**
  26007. * The reject method of the promise associated with this deferred object.
  26008. */
  26009. readonly reject: (reason?: any) => void;
  26010. /**
  26011. * Constructor for this deferred object.
  26012. */
  26013. constructor();
  26014. }
  26015. }
  26016. declare module BABYLON {
  26017. class FilesInput {
  26018. static FilesToLoad: {
  26019. [key: string]: File;
  26020. };
  26021. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  26022. private _engine;
  26023. private _currentScene;
  26024. private _sceneLoadedCallback;
  26025. private _progressCallback;
  26026. private _additionalRenderLoopLogicCallback;
  26027. private _textureLoadingCallback;
  26028. private _startingProcessingFilesCallback;
  26029. private _onReloadCallback;
  26030. private _errorCallback;
  26031. private _elementToMonitor;
  26032. private _sceneFileToLoad;
  26033. private _filesToLoad;
  26034. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: () => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  26035. private _dragEnterHandler;
  26036. private _dragOverHandler;
  26037. private _dropHandler;
  26038. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  26039. dispose(): void;
  26040. private renderFunction();
  26041. private drag(e);
  26042. private drop(eventDrop);
  26043. private _traverseFolder(folder, files, remaining, callback);
  26044. private _processFiles(files);
  26045. loadFiles(event: any): void;
  26046. private _processReload();
  26047. reload(): void;
  26048. }
  26049. }
  26050. declare module BABYLON {
  26051. /**
  26052. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  26053. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  26054. */
  26055. class KhronosTextureContainer {
  26056. arrayBuffer: any;
  26057. static HEADER_LEN: number;
  26058. static COMPRESSED_2D: number;
  26059. static COMPRESSED_3D: number;
  26060. static TEX_2D: number;
  26061. static TEX_3D: number;
  26062. glType: number;
  26063. glTypeSize: number;
  26064. glFormat: number;
  26065. glInternalFormat: number;
  26066. glBaseInternalFormat: number;
  26067. pixelWidth: number;
  26068. pixelHeight: number;
  26069. pixelDepth: number;
  26070. numberOfArrayElements: number;
  26071. numberOfFaces: number;
  26072. numberOfMipmapLevels: number;
  26073. bytesOfKeyValueData: number;
  26074. loadType: number;
  26075. /**
  26076. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  26077. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  26078. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  26079. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  26080. */
  26081. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  26082. switchEndainness(val: number): number;
  26083. /**
  26084. * It is assumed that the texture has already been created & is currently bound
  26085. */
  26086. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  26087. private _upload2DCompressedLevels(gl, loadMipmaps);
  26088. }
  26089. }
  26090. declare module BABYLON {
  26091. /**
  26092. * A class serves as a medium between the observable and its observers
  26093. */
  26094. class EventState {
  26095. /**
  26096. * Create a new EventState
  26097. * @param mask defines the mask associated with this state
  26098. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  26099. * @param target defines the original target of the state
  26100. * @param currentTarget defines the current target of the state
  26101. */
  26102. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  26103. /**
  26104. * Initialize the current event state
  26105. * @param mask defines the mask associated with this state
  26106. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  26107. * @param target defines the original target of the state
  26108. * @param currentTarget defines the current target of the state
  26109. * @returns the current event state
  26110. */
  26111. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  26112. /**
  26113. * An Observer can set this property to true to prevent subsequent observers of being notified
  26114. */
  26115. skipNextObservers: boolean;
  26116. /**
  26117. * Get the mask value that were used to trigger the event corresponding to this EventState object
  26118. */
  26119. mask: number;
  26120. /**
  26121. * The object that originally notified the event
  26122. */
  26123. target?: any;
  26124. /**
  26125. * The current object in the bubbling phase
  26126. */
  26127. currentTarget?: any;
  26128. /**
  26129. * This will be populated with the return value of the last function that was executed.
  26130. * If it is the first function in the callback chain it will be the event data.
  26131. */
  26132. lastReturnValue?: any;
  26133. }
  26134. /**
  26135. * Represent an Observer registered to a given Observable object.
  26136. */
  26137. class Observer<T> {
  26138. /**
  26139. * Defines the callback to call when the observer is notified
  26140. */
  26141. callback: (eventData: T, eventState: EventState) => void;
  26142. /**
  26143. * Defines the mask of the observer (used to filter notifications)
  26144. */
  26145. mask: number;
  26146. /**
  26147. * Defines the current scope used to restore the JS context
  26148. */
  26149. scope: any;
  26150. /** @ignore */
  26151. _willBeUnregistered: boolean;
  26152. /**
  26153. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  26154. */
  26155. unregisterOnNextCall: boolean;
  26156. /**
  26157. * Creates a new observer
  26158. * @param callback defines the callback to call when the observer is notified
  26159. * @param mask defines the mask of the observer (used to filter notifications)
  26160. * @param scope defines the current scope used to restore the JS context
  26161. */
  26162. constructor(
  26163. /**
  26164. * Defines the callback to call when the observer is notified
  26165. */
  26166. callback: (eventData: T, eventState: EventState) => void,
  26167. /**
  26168. * Defines the mask of the observer (used to filter notifications)
  26169. */
  26170. mask: number,
  26171. /**
  26172. * Defines the current scope used to restore the JS context
  26173. */
  26174. scope?: any);
  26175. }
  26176. /**
  26177. * Represent a list of observers registered to multiple Observables object.
  26178. */
  26179. class MultiObserver<T> {
  26180. private _observers;
  26181. private _observables;
  26182. /**
  26183. * Release associated resources
  26184. */
  26185. dispose(): void;
  26186. /**
  26187. * Raise a callback when one of the observable will notify
  26188. * @param observables defines a list of observables to watch
  26189. * @param callback defines the callback to call on notification
  26190. * @param mask defines the mask used to filter notifications
  26191. * @param scope defines the current scope used to restore the JS context
  26192. * @returns the new MultiObserver
  26193. */
  26194. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  26195. }
  26196. /**
  26197. * The Observable class is a simple implementation of the Observable pattern.
  26198. *
  26199. * 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.
  26200. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  26201. * 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).
  26202. * 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.
  26203. */
  26204. class Observable<T> {
  26205. private _observers;
  26206. private _eventState;
  26207. private _onObserverAdded;
  26208. /**
  26209. * Creates a new observable
  26210. * @param onObserverAdded defines a callback to call when a new observer is added
  26211. */
  26212. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  26213. /**
  26214. * Create a new Observer with the specified callback
  26215. * @param callback the callback that will be executed for that Observer
  26216. * @param mask the mask used to filter observers
  26217. * @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.
  26218. * @param scope optional scope for the callback to be called from
  26219. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  26220. * @returns the new observer created for the callback
  26221. */
  26222. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  26223. /**
  26224. * Remove an Observer from the Observable object
  26225. * @param observer the instance of the Observer to remove
  26226. * @returns false if it doesn't belong to this Observable
  26227. */
  26228. remove(observer: Nullable<Observer<T>>): boolean;
  26229. /**
  26230. * Remove a callback from the Observable object
  26231. * @param callback the callback to remove
  26232. * @param scope optional scope. If used only the callbacks with this scope will be removed
  26233. * @returns false if it doesn't belong to this Observable
  26234. */
  26235. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  26236. private _deferUnregister(observer);
  26237. /**
  26238. * Notify all Observers by calling their respective callback with the given data
  26239. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  26240. * @param eventData defines the data to send to all observers
  26241. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  26242. * @param target defines the original target of the state
  26243. * @param currentTarget defines the current target of the state
  26244. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  26245. */
  26246. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  26247. /**
  26248. * Calling this will execute each callback, expecting it to be a promise or return a value.
  26249. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  26250. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  26251. * and it is crucial that all callbacks will be executed.
  26252. * The order of the callbacks is kept, callbacks are not executed parallel.
  26253. *
  26254. * @param eventData The data to be sent to each callback
  26255. * @param mask is used to filter observers defaults to -1
  26256. * @param target defines the callback target (see EventState)
  26257. * @param currentTarget defines he current object in the bubbling phase
  26258. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  26259. */
  26260. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  26261. /**
  26262. * Notify a specific observer
  26263. * @param observer defines the observer to notify
  26264. * @param eventData defines the data to be sent to each callback
  26265. * @param mask is used to filter observers defaults to -1
  26266. */
  26267. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  26268. /**
  26269. * Gets a boolean indicating if the observable has at least one observer
  26270. * @returns true is the Observable has at least one Observer registered
  26271. */
  26272. hasObservers(): boolean;
  26273. /**
  26274. * Clear the list of observers
  26275. */
  26276. clear(): void;
  26277. /**
  26278. * Clone the current observable
  26279. * @returns a new observable
  26280. */
  26281. clone(): Observable<T>;
  26282. /**
  26283. * Does this observable handles observer registered with a given mask
  26284. * @param mask defines the mask to be tested
  26285. * @return whether or not one observer registered with the given mask is handeled
  26286. **/
  26287. hasSpecificMask(mask?: number): boolean;
  26288. }
  26289. }
  26290. declare module BABYLON {
  26291. /**
  26292. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  26293. */
  26294. class PerformanceMonitor {
  26295. private _enabled;
  26296. private _rollingFrameTime;
  26297. private _lastFrameTimeMs;
  26298. /**
  26299. * constructor
  26300. * @param frameSampleSize The number of samples required to saturate the sliding window
  26301. */
  26302. constructor(frameSampleSize?: number);
  26303. /**
  26304. * Samples current frame
  26305. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  26306. */
  26307. sampleFrame(timeMs?: number): void;
  26308. /**
  26309. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  26310. * @return Average frame time in milliseconds
  26311. */
  26312. readonly averageFrameTime: number;
  26313. /**
  26314. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  26315. * @return Frame time variance in milliseconds squared
  26316. */
  26317. readonly averageFrameTimeVariance: number;
  26318. /**
  26319. * Returns the frame time of the most recent frame
  26320. * @return Frame time in milliseconds
  26321. */
  26322. readonly instantaneousFrameTime: number;
  26323. /**
  26324. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  26325. * @return Framerate in frames per second
  26326. */
  26327. readonly averageFPS: number;
  26328. /**
  26329. * Returns the average framerate in frames per second using the most recent frame time
  26330. * @return Framerate in frames per second
  26331. */
  26332. readonly instantaneousFPS: number;
  26333. /**
  26334. * Returns true if enough samples have been taken to completely fill the sliding window
  26335. * @return true if saturated
  26336. */
  26337. readonly isSaturated: boolean;
  26338. /**
  26339. * Enables contributions to the sliding window sample set
  26340. */
  26341. enable(): void;
  26342. /**
  26343. * Disables contributions to the sliding window sample set
  26344. * Samples will not be interpolated over the disabled period
  26345. */
  26346. disable(): void;
  26347. /**
  26348. * Returns true if sampling is enabled
  26349. * @return true if enabled
  26350. */
  26351. readonly isEnabled: boolean;
  26352. /**
  26353. * Resets performance monitor
  26354. */
  26355. reset(): void;
  26356. }
  26357. /**
  26358. * RollingAverage
  26359. *
  26360. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  26361. */
  26362. class RollingAverage {
  26363. /**
  26364. * Current average
  26365. */
  26366. average: number;
  26367. /**
  26368. * Current variance
  26369. */
  26370. variance: number;
  26371. protected _samples: Array<number>;
  26372. protected _sampleCount: number;
  26373. protected _pos: number;
  26374. protected _m2: number;
  26375. /**
  26376. * constructor
  26377. * @param length The number of samples required to saturate the sliding window
  26378. */
  26379. constructor(length: number);
  26380. /**
  26381. * Adds a sample to the sample set
  26382. * @param v The sample value
  26383. */
  26384. add(v: number): void;
  26385. /**
  26386. * Returns previously added values or null if outside of history or outside the sliding window domain
  26387. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  26388. * @return Value previously recorded with add() or null if outside of range
  26389. */
  26390. history(i: number): number;
  26391. /**
  26392. * Returns true if enough samples have been taken to completely fill the sliding window
  26393. * @return true if sample-set saturated
  26394. */
  26395. isSaturated(): boolean;
  26396. /**
  26397. * Resets the rolling average (equivalent to 0 samples taken so far)
  26398. */
  26399. reset(): void;
  26400. /**
  26401. * Wraps a value around the sample range boundaries
  26402. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  26403. * @return Wrapped position in sample range
  26404. */
  26405. protected _wrapPosition(i: number): number;
  26406. }
  26407. }
  26408. declare module BABYLON {
  26409. /**
  26410. * Helper class that provides a small promise polyfill
  26411. */
  26412. class PromisePolyfill {
  26413. /**
  26414. * Static function used to check if the polyfill is required
  26415. * If this is the case then the function will inject the polyfill to window.Promise
  26416. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  26417. */
  26418. static Apply(force?: boolean): void;
  26419. }
  26420. }
  26421. declare module BABYLON {
  26422. /**
  26423. * Defines the root class used to create scene optimization to use with SceneOptimizer
  26424. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26425. */
  26426. class SceneOptimization {
  26427. /**
  26428. * Defines the priority of this optimization (0 by default which means first in the list)
  26429. */
  26430. priority: number;
  26431. /**
  26432. * Gets a string describing the action executed by the current optimization
  26433. * @returns description string
  26434. */
  26435. getDescription(): string;
  26436. /**
  26437. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  26438. * @param scene defines the current scene where to apply this optimization
  26439. * @param optimizer defines the current optimizer
  26440. * @returns true if everything that can be done was applied
  26441. */
  26442. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  26443. /**
  26444. * Creates the SceneOptimization object
  26445. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  26446. * @param desc defines the description associated with the optimization
  26447. */
  26448. constructor(
  26449. /**
  26450. * Defines the priority of this optimization (0 by default which means first in the list)
  26451. */
  26452. priority?: number);
  26453. }
  26454. /**
  26455. * Defines an optimization used to reduce the size of render target textures
  26456. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26457. */
  26458. class TextureOptimization extends SceneOptimization {
  26459. /**
  26460. * Defines the priority of this optimization (0 by default which means first in the list)
  26461. */
  26462. priority: number;
  26463. /**
  26464. * 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
  26465. */
  26466. maximumSize: number;
  26467. /**
  26468. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  26469. */
  26470. step: number;
  26471. /**
  26472. * Gets a string describing the action executed by the current optimization
  26473. * @returns description string
  26474. */
  26475. getDescription(): string;
  26476. /**
  26477. * Creates the TextureOptimization object
  26478. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  26479. * @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
  26480. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  26481. */
  26482. constructor(
  26483. /**
  26484. * Defines the priority of this optimization (0 by default which means first in the list)
  26485. */
  26486. priority?: number,
  26487. /**
  26488. * 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
  26489. */
  26490. maximumSize?: number,
  26491. /**
  26492. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  26493. */
  26494. step?: number);
  26495. /**
  26496. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  26497. * @param scene defines the current scene where to apply this optimization
  26498. * @param optimizer defines the current optimizer
  26499. * @returns true if everything that can be done was applied
  26500. */
  26501. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  26502. }
  26503. /**
  26504. * Defines an optimization used to increase or decrease the rendering resolution
  26505. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26506. */
  26507. class HardwareScalingOptimization extends SceneOptimization {
  26508. /**
  26509. * Defines the priority of this optimization (0 by default which means first in the list)
  26510. */
  26511. priority: number;
  26512. /**
  26513. * Defines the maximum scale to use (2 by default)
  26514. */
  26515. maximumScale: number;
  26516. /**
  26517. * Defines the step to use between two passes (0.5 by default)
  26518. */
  26519. step: number;
  26520. private _currentScale;
  26521. private _directionOffset;
  26522. /**
  26523. * Gets a string describing the action executed by the current optimization
  26524. * @return description string
  26525. */
  26526. getDescription(): string;
  26527. /**
  26528. * Creates the HardwareScalingOptimization object
  26529. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  26530. * @param maximumScale defines the maximum scale to use (2 by default)
  26531. * @param step defines the step to use between two passes (0.5 by default)
  26532. */
  26533. constructor(
  26534. /**
  26535. * Defines the priority of this optimization (0 by default which means first in the list)
  26536. */
  26537. priority?: number,
  26538. /**
  26539. * Defines the maximum scale to use (2 by default)
  26540. */
  26541. maximumScale?: number,
  26542. /**
  26543. * Defines the step to use between two passes (0.5 by default)
  26544. */
  26545. step?: number);
  26546. /**
  26547. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  26548. * @param scene defines the current scene where to apply this optimization
  26549. * @param optimizer defines the current optimizer
  26550. * @returns true if everything that can be done was applied
  26551. */
  26552. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  26553. }
  26554. /**
  26555. * Defines an optimization used to remove shadows
  26556. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26557. */
  26558. class ShadowsOptimization extends SceneOptimization {
  26559. /**
  26560. * Gets a string describing the action executed by the current optimization
  26561. * @return description string
  26562. */
  26563. getDescription(): string;
  26564. /**
  26565. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  26566. * @param scene defines the current scene where to apply this optimization
  26567. * @param optimizer defines the current optimizer
  26568. * @returns true if everything that can be done was applied
  26569. */
  26570. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  26571. }
  26572. /**
  26573. * Defines an optimization used to turn post-processes off
  26574. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26575. */
  26576. class PostProcessesOptimization extends SceneOptimization {
  26577. /**
  26578. * Gets a string describing the action executed by the current optimization
  26579. * @return description string
  26580. */
  26581. getDescription(): string;
  26582. /**
  26583. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  26584. * @param scene defines the current scene where to apply this optimization
  26585. * @param optimizer defines the current optimizer
  26586. * @returns true if everything that can be done was applied
  26587. */
  26588. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  26589. }
  26590. /**
  26591. * Defines an optimization used to turn lens flares off
  26592. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26593. */
  26594. class LensFlaresOptimization extends SceneOptimization {
  26595. /**
  26596. * Gets a string describing the action executed by the current optimization
  26597. * @return description string
  26598. */
  26599. getDescription(): string;
  26600. /**
  26601. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  26602. * @param scene defines the current scene where to apply this optimization
  26603. * @param optimizer defines the current optimizer
  26604. * @returns true if everything that can be done was applied
  26605. */
  26606. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  26607. }
  26608. /**
  26609. * Defines an optimization based on user defined callback.
  26610. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26611. */
  26612. class CustomOptimization extends SceneOptimization {
  26613. /**
  26614. * Callback called to apply the custom optimization.
  26615. */
  26616. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  26617. /**
  26618. * Callback called to get custom description
  26619. */
  26620. onGetDescription: () => string;
  26621. /**
  26622. * Gets a string describing the action executed by the current optimization
  26623. * @returns description string
  26624. */
  26625. getDescription(): string;
  26626. /**
  26627. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  26628. * @param scene defines the current scene where to apply this optimization
  26629. * @param optimizer defines the current optimizer
  26630. * @returns true if everything that can be done was applied
  26631. */
  26632. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  26633. }
  26634. /**
  26635. * Defines an optimization used to turn particles off
  26636. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26637. */
  26638. class ParticlesOptimization extends SceneOptimization {
  26639. /**
  26640. * Gets a string describing the action executed by the current optimization
  26641. * @return description string
  26642. */
  26643. getDescription(): string;
  26644. /**
  26645. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  26646. * @param scene defines the current scene where to apply this optimization
  26647. * @param optimizer defines the current optimizer
  26648. * @returns true if everything that can be done was applied
  26649. */
  26650. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  26651. }
  26652. /**
  26653. * Defines an optimization used to turn render targets off
  26654. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26655. */
  26656. class RenderTargetsOptimization extends SceneOptimization {
  26657. /**
  26658. * Gets a string describing the action executed by the current optimization
  26659. * @return description string
  26660. */
  26661. getDescription(): string;
  26662. /**
  26663. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  26664. * @param scene defines the current scene where to apply this optimization
  26665. * @param optimizer defines the current optimizer
  26666. * @returns true if everything that can be done was applied
  26667. */
  26668. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  26669. }
  26670. /**
  26671. * Defines an optimization used to merge meshes with compatible materials
  26672. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26673. */
  26674. class MergeMeshesOptimization extends SceneOptimization {
  26675. private static _UpdateSelectionTree;
  26676. /**
  26677. * Gets or sets a boolean which defines if optimization octree has to be updated
  26678. */
  26679. /**
  26680. * Gets or sets a boolean which defines if optimization octree has to be updated
  26681. */
  26682. static UpdateSelectionTree: boolean;
  26683. /**
  26684. * Gets a string describing the action executed by the current optimization
  26685. * @return description string
  26686. */
  26687. getDescription(): string;
  26688. private _canBeMerged;
  26689. /**
  26690. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  26691. * @param scene defines the current scene where to apply this optimization
  26692. * @param optimizer defines the current optimizer
  26693. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  26694. * @returns true if everything that can be done was applied
  26695. */
  26696. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  26697. }
  26698. /**
  26699. * Defines a list of options used by SceneOptimizer
  26700. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26701. */
  26702. class SceneOptimizerOptions {
  26703. /**
  26704. * Defines the target frame rate to reach (60 by default)
  26705. */
  26706. targetFrameRate: number;
  26707. /**
  26708. * Defines the interval between two checkes (2000ms by default)
  26709. */
  26710. trackerDuration: number;
  26711. /**
  26712. * Gets the list of optimizations to apply
  26713. */
  26714. optimizations: SceneOptimization[];
  26715. /**
  26716. * Creates a new list of options used by SceneOptimizer
  26717. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  26718. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  26719. */
  26720. constructor(
  26721. /**
  26722. * Defines the target frame rate to reach (60 by default)
  26723. */
  26724. targetFrameRate?: number,
  26725. /**
  26726. * Defines the interval between two checkes (2000ms by default)
  26727. */
  26728. trackerDuration?: number);
  26729. /**
  26730. * Add a new optimization
  26731. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  26732. * @returns the current SceneOptimizerOptions
  26733. */
  26734. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  26735. /**
  26736. * Add a new custom optimization
  26737. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  26738. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  26739. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  26740. * @returns the current SceneOptimizerOptions
  26741. */
  26742. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  26743. /**
  26744. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  26745. * @param targetFrameRate defines the target frame rate (60 by default)
  26746. * @returns a SceneOptimizerOptions object
  26747. */
  26748. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  26749. /**
  26750. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  26751. * @param targetFrameRate defines the target frame rate (60 by default)
  26752. * @returns a SceneOptimizerOptions object
  26753. */
  26754. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  26755. /**
  26756. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  26757. * @param targetFrameRate defines the target frame rate (60 by default)
  26758. * @returns a SceneOptimizerOptions object
  26759. */
  26760. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  26761. }
  26762. /**
  26763. * Class used to run optimizations in order to reach a target frame rate
  26764. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  26765. */
  26766. class SceneOptimizer implements IDisposable {
  26767. private _isRunning;
  26768. private _options;
  26769. private _scene;
  26770. private _currentPriorityLevel;
  26771. private _targetFrameRate;
  26772. private _trackerDuration;
  26773. private _currentFrameRate;
  26774. private _sceneDisposeObserver;
  26775. private _improvementMode;
  26776. /**
  26777. * Defines an observable called when the optimizer reaches the target frame rate
  26778. */
  26779. onSuccessObservable: Observable<SceneOptimizer>;
  26780. /**
  26781. * Defines an observable called when the optimizer enables an optimization
  26782. */
  26783. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  26784. /**
  26785. * Defines an observable called when the optimizer is not able to reach the target frame rate
  26786. */
  26787. onFailureObservable: Observable<SceneOptimizer>;
  26788. /**
  26789. * Gets a boolean indicating if the optimizer is in improvement mode
  26790. */
  26791. readonly isInImprovementMode: boolean;
  26792. /**
  26793. * Gets the current priority level (0 at start)
  26794. */
  26795. readonly currentPriorityLevel: number;
  26796. /**
  26797. * Gets the current frame rate checked by the SceneOptimizer
  26798. */
  26799. readonly currentFrameRate: number;
  26800. /**
  26801. * Gets or sets the current target frame rate (60 by default)
  26802. */
  26803. /**
  26804. * Gets or sets the current target frame rate (60 by default)
  26805. */
  26806. targetFrameRate: number;
  26807. /**
  26808. * Gets or sets the current interval between two checks (every 2000ms by default)
  26809. */
  26810. /**
  26811. * Gets or sets the current interval between two checks (every 2000ms by default)
  26812. */
  26813. trackerDuration: number;
  26814. /**
  26815. * Gets the list of active optimizations
  26816. */
  26817. readonly optimizations: SceneOptimization[];
  26818. /**
  26819. * Creates a new SceneOptimizer
  26820. * @param scene defines the scene to work on
  26821. * @param options defines the options to use with the SceneOptimizer
  26822. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  26823. * @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)
  26824. */
  26825. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  26826. /**
  26827. * Stops the current optimizer
  26828. */
  26829. stop(): void;
  26830. /**
  26831. * Reset the optimizer to initial step (current priority level = 0)
  26832. */
  26833. reset(): void;
  26834. /**
  26835. * Start the optimizer. By default it will try to reach a specific framerate
  26836. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  26837. */
  26838. start(): void;
  26839. private _checkCurrentState();
  26840. /**
  26841. * Release all resources
  26842. */
  26843. dispose(): void;
  26844. /**
  26845. * Helper function to create a SceneOptimizer with one single line of code
  26846. * @param scene defines the scene to work on
  26847. * @param options defines the options to use with the SceneOptimizer
  26848. * @param onSuccess defines a callback to call on success
  26849. * @param onFailure defines a callback to call on failure
  26850. * @returns the new SceneOptimizer object
  26851. */
  26852. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  26853. }
  26854. }
  26855. declare module BABYLON {
  26856. class SceneSerializer {
  26857. static ClearCache(): void;
  26858. static Serialize(scene: Scene): any;
  26859. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  26860. }
  26861. }
  26862. declare module BABYLON {
  26863. class SmartArray<T> {
  26864. data: Array<T>;
  26865. length: number;
  26866. protected _id: number;
  26867. [index: number]: T;
  26868. constructor(capacity: number);
  26869. push(value: T): void;
  26870. forEach(func: (content: T) => void): void;
  26871. sort(compareFn: (a: T, b: T) => number): void;
  26872. reset(): void;
  26873. dispose(): void;
  26874. concat(array: any): void;
  26875. indexOf(value: T): number;
  26876. contains(value: T): boolean;
  26877. private static _GlobalId;
  26878. }
  26879. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  26880. private _duplicateId;
  26881. [index: number]: T;
  26882. push(value: T): void;
  26883. pushNoDuplicate(value: T): boolean;
  26884. reset(): void;
  26885. concatWithNoDuplicate(array: any): void;
  26886. }
  26887. }
  26888. declare module BABYLON {
  26889. /**
  26890. * This class implement a typical dictionary using a string as key and the generic type T as value.
  26891. * The underlying implementation relies on an associative array to ensure the best performances.
  26892. * The value can be anything including 'null' but except 'undefined'
  26893. */
  26894. class StringDictionary<T> {
  26895. /**
  26896. * This will clear this dictionary and copy the content from the 'source' one.
  26897. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  26898. * @param source the dictionary to take the content from and copy to this dictionary
  26899. */
  26900. copyFrom(source: StringDictionary<T>): void;
  26901. /**
  26902. * Get a value based from its key
  26903. * @param key the given key to get the matching value from
  26904. * @return the value if found, otherwise undefined is returned
  26905. */
  26906. get(key: string): T | undefined;
  26907. /**
  26908. * Get a value from its key or add it if it doesn't exist.
  26909. * This method will ensure you that a given key/data will be present in the dictionary.
  26910. * @param key the given key to get the matching value from
  26911. * @param factory the factory that will create the value if the key is not present in the dictionary.
  26912. * The factory will only be invoked if there's no data for the given key.
  26913. * @return the value corresponding to the key.
  26914. */
  26915. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  26916. /**
  26917. * Get a value from its key if present in the dictionary otherwise add it
  26918. * @param key the key to get the value from
  26919. * @param val if there's no such key/value pair in the dictionary add it with this value
  26920. * @return the value corresponding to the key
  26921. */
  26922. getOrAdd(key: string, val: T): T;
  26923. /**
  26924. * Check if there's a given key in the dictionary
  26925. * @param key the key to check for
  26926. * @return true if the key is present, false otherwise
  26927. */
  26928. contains(key: string): boolean;
  26929. /**
  26930. * Add a new key and its corresponding value
  26931. * @param key the key to add
  26932. * @param value the value corresponding to the key
  26933. * @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
  26934. */
  26935. add(key: string, value: T): boolean;
  26936. set(key: string, value: T): boolean;
  26937. /**
  26938. * Get the element of the given key and remove it from the dictionary
  26939. * @param key
  26940. */
  26941. getAndRemove(key: string): Nullable<T>;
  26942. /**
  26943. * Remove a key/value from the dictionary.
  26944. * @param key the key to remove
  26945. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  26946. */
  26947. remove(key: string): boolean;
  26948. /**
  26949. * Clear the whole content of the dictionary
  26950. */
  26951. clear(): void;
  26952. readonly count: number;
  26953. /**
  26954. * Execute a callback on each key/val of the dictionary.
  26955. * Note that you can remove any element in this dictionary in the callback implementation
  26956. * @param callback the callback to execute on a given key/value pair
  26957. */
  26958. forEach(callback: (key: string, val: T) => void): void;
  26959. /**
  26960. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  26961. * If the callback returns null or undefined the method will iterate to the next key/value pair
  26962. * Note that you can remove any element in this dictionary in the callback implementation
  26963. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  26964. */
  26965. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  26966. private _count;
  26967. private _data;
  26968. }
  26969. }
  26970. declare module BABYLON {
  26971. class Tags {
  26972. static EnableFor(obj: any): void;
  26973. static DisableFor(obj: any): void;
  26974. static HasTags(obj: any): boolean;
  26975. static GetTags(obj: any, asString?: boolean): any;
  26976. static AddTagsTo(obj: any, tagsString: string): void;
  26977. static _AddTagTo(obj: any, tag: string): void;
  26978. static RemoveTagsFrom(obj: any, tagsString: string): void;
  26979. static _RemoveTagFrom(obj: any, tag: string): void;
  26980. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  26981. }
  26982. }
  26983. declare module BABYLON {
  26984. class TextureTools {
  26985. /**
  26986. * Uses the GPU to create a copy texture rescaled at a given size
  26987. * @param texture Texture to copy from
  26988. * @param width Desired width
  26989. * @param height Desired height
  26990. * @return Generated texture
  26991. */
  26992. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  26993. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  26994. private static _environmentBRDFBase64Texture;
  26995. }
  26996. }
  26997. declare module BABYLON {
  26998. class TGATools {
  26999. private static _TYPE_INDEXED;
  27000. private static _TYPE_RGB;
  27001. private static _TYPE_GREY;
  27002. private static _TYPE_RLE_INDEXED;
  27003. private static _TYPE_RLE_RGB;
  27004. private static _TYPE_RLE_GREY;
  27005. private static _ORIGIN_MASK;
  27006. private static _ORIGIN_SHIFT;
  27007. private static _ORIGIN_BL;
  27008. private static _ORIGIN_BR;
  27009. private static _ORIGIN_UL;
  27010. private static _ORIGIN_UR;
  27011. static GetTGAHeader(data: Uint8Array): any;
  27012. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  27013. 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;
  27014. 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;
  27015. 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;
  27016. 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;
  27017. 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;
  27018. 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;
  27019. }
  27020. }
  27021. declare module BABYLON {
  27022. interface IAnimatable {
  27023. animations: Array<Animation>;
  27024. }
  27025. class LoadFileError extends Error {
  27026. request: XMLHttpRequest | undefined;
  27027. private static _setPrototypeOf;
  27028. constructor(message: string, request?: XMLHttpRequest | undefined);
  27029. }
  27030. class RetryStrategy {
  27031. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  27032. }
  27033. interface IFileRequest {
  27034. /**
  27035. * Raised when the request is complete (success or error).
  27036. */
  27037. onCompleteObservable: Observable<IFileRequest>;
  27038. /**
  27039. * Aborts the request for a file.
  27040. */
  27041. abort: () => void;
  27042. }
  27043. class Tools {
  27044. static BaseUrl: string;
  27045. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  27046. /**
  27047. * Default behaviour for cors in the application.
  27048. * It can be a string if the expected behavior is identical in the entire app.
  27049. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  27050. */
  27051. static CorsBehavior: string | ((url: string | string[]) => string);
  27052. static UseFallbackTexture: boolean;
  27053. /**
  27054. * Use this object to register external classes like custom textures or material
  27055. * to allow the laoders to instantiate them
  27056. */
  27057. static RegisteredExternalClasses: {
  27058. [key: string]: Object;
  27059. };
  27060. static fallbackTexture: string;
  27061. /**
  27062. * Interpolates between a and b via alpha
  27063. * @param a The lower value (returned when alpha = 0)
  27064. * @param b The upper value (returned when alpha = 1)
  27065. * @param alpha The interpolation-factor
  27066. * @return The mixed value
  27067. */
  27068. static Mix(a: number, b: number, alpha: number): number;
  27069. static Instantiate(className: string): any;
  27070. /**
  27071. * Provides a slice function that will work even on IE
  27072. * @param data defines the array to slice
  27073. * @param start defines the start of the data (optional)
  27074. * @param end defines the end of the data (optional)
  27075. * @returns the new sliced array
  27076. */
  27077. static Slice<T>(data: T, start?: number, end?: number): T;
  27078. static SetImmediate(action: () => void): void;
  27079. static IsExponentOfTwo(value: number): boolean;
  27080. /**
  27081. * Find the next highest power of two.
  27082. * @param x Number to start search from.
  27083. * @return Next highest power of two.
  27084. */
  27085. static CeilingPOT(x: number): number;
  27086. /**
  27087. * Find the next lowest power of two.
  27088. * @param x Number to start search from.
  27089. * @return Next lowest power of two.
  27090. */
  27091. static FloorPOT(x: number): number;
  27092. /**
  27093. * Find the nearest power of two.
  27094. * @param x Number to start search from.
  27095. * @return Next nearest power of two.
  27096. */
  27097. static NearestPOT(x: number): number;
  27098. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  27099. static GetFilename(path: string): string;
  27100. /**
  27101. * Extracts the "folder" part of a path (everything before the filename).
  27102. * @param uri The URI to extract the info from
  27103. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  27104. * @returns The "folder" part of the path
  27105. */
  27106. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  27107. static GetDOMTextContent(element: HTMLElement): string;
  27108. static ToDegrees(angle: number): number;
  27109. static ToRadians(angle: number): number;
  27110. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  27111. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  27112. minimum: Vector3;
  27113. maximum: Vector3;
  27114. };
  27115. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  27116. minimum: Vector3;
  27117. maximum: Vector3;
  27118. };
  27119. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  27120. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  27121. minimum: Vector2;
  27122. maximum: Vector2;
  27123. };
  27124. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  27125. static GetPointerPrefix(): string;
  27126. /**
  27127. * @param func - the function to be called
  27128. * @param requester - the object that will request the next frame. Falls back to window.
  27129. */
  27130. static QueueNewFrame(func: () => void, requester?: any): number;
  27131. static RequestFullscreen(element: HTMLElement): void;
  27132. static ExitFullscreen(): void;
  27133. static SetCorsBehavior(url: string | string[], element: {
  27134. crossOrigin: string | null;
  27135. }): void;
  27136. static CleanUrl(url: string): string;
  27137. static PreprocessUrl: (url: string) => string;
  27138. static LoadImage(url: any, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  27139. 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;
  27140. /**
  27141. * Load a script (identified by an url). When the url returns, the
  27142. * content of this file is added into a new script element, attached to the DOM (body element)
  27143. */
  27144. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  27145. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  27146. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  27147. static FileAsURL(content: string): string;
  27148. static Format(value: number, decimals?: number): string;
  27149. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  27150. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  27151. static IsEmpty(obj: any): boolean;
  27152. static RegisterTopRootEvents(events: {
  27153. name: string;
  27154. handler: Nullable<(e: FocusEvent) => any>;
  27155. }[]): void;
  27156. static UnregisterTopRootEvents(events: {
  27157. name: string;
  27158. handler: Nullable<(e: FocusEvent) => any>;
  27159. }[]): void;
  27160. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  27161. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  27162. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  27163. /**
  27164. * Generates an image screenshot from the specified camera.
  27165. *
  27166. * @param engine The engine to use for rendering
  27167. * @param camera The camera to use for rendering
  27168. * @param size This parameter can be set to a single number or to an object with the
  27169. * following (optional) properties: precision, width, height. If a single number is passed,
  27170. * it will be used for both width and height. If an object is passed, the screenshot size
  27171. * will be derived from the parameters. The precision property is a multiplier allowing
  27172. * rendering at a higher or lower resolution.
  27173. * @param successCallback The callback receives a single parameter which contains the
  27174. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  27175. * src parameter of an <img> to display it.
  27176. * @param mimeType The MIME type of the screenshot image (default: image/png).
  27177. * Check your browser for supported MIME types.
  27178. * @param samples Texture samples (default: 1)
  27179. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  27180. * @param fileName A name for for the downloaded file.
  27181. * @constructor
  27182. */
  27183. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  27184. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  27185. /**
  27186. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27187. * Be aware Math.random() could cause collisions, but:
  27188. * "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"
  27189. */
  27190. static RandomId(): string;
  27191. /**
  27192. * Test if the given uri is a base64 string.
  27193. * @param uri The uri to test
  27194. * @return True if the uri is a base64 string or false otherwise.
  27195. */
  27196. static IsBase64(uri: string): boolean;
  27197. /**
  27198. * Decode the given base64 uri.
  27199. * @param uri The uri to decode
  27200. * @return The decoded base64 data.
  27201. */
  27202. static DecodeBase64(uri: string): ArrayBuffer;
  27203. private static _NoneLogLevel;
  27204. private static _MessageLogLevel;
  27205. private static _WarningLogLevel;
  27206. private static _ErrorLogLevel;
  27207. private static _LogCache;
  27208. static errorsCount: number;
  27209. static OnNewCacheEntry: (entry: string) => void;
  27210. static readonly NoneLogLevel: number;
  27211. static readonly MessageLogLevel: number;
  27212. static readonly WarningLogLevel: number;
  27213. static readonly ErrorLogLevel: number;
  27214. static readonly AllLogLevel: number;
  27215. private static _AddLogEntry(entry);
  27216. private static _FormatMessage(message);
  27217. private static _LogDisabled(message);
  27218. private static _LogEnabled(message);
  27219. private static _WarnDisabled(message);
  27220. private static _WarnEnabled(message);
  27221. private static _ErrorDisabled(message);
  27222. private static _ErrorEnabled(message);
  27223. static Log: (message: string) => void;
  27224. static Warn: (message: string) => void;
  27225. static Error: (message: string) => void;
  27226. static readonly LogCache: string;
  27227. static ClearLogCache(): void;
  27228. static LogLevels: number;
  27229. static IsWindowObjectExist(): boolean;
  27230. private static _PerformanceNoneLogLevel;
  27231. private static _PerformanceUserMarkLogLevel;
  27232. private static _PerformanceConsoleLogLevel;
  27233. private static _performance;
  27234. static readonly PerformanceNoneLogLevel: number;
  27235. static readonly PerformanceUserMarkLogLevel: number;
  27236. static readonly PerformanceConsoleLogLevel: number;
  27237. static PerformanceLogLevel: number;
  27238. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  27239. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  27240. static _StartUserMark(counterName: string, condition?: boolean): void;
  27241. static _EndUserMark(counterName: string, condition?: boolean): void;
  27242. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  27243. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  27244. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  27245. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  27246. static readonly Now: number;
  27247. /**
  27248. * This method will return the name of the class used to create the instance of the given object.
  27249. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  27250. * @param object the object to get the class name from
  27251. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  27252. */
  27253. static GetClassName(object: any, isType?: boolean): string;
  27254. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  27255. /**
  27256. * This method will return the name of the full name of the class, including its owning module (if any).
  27257. * 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).
  27258. * @param object the object to get the class name from
  27259. * @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.
  27260. */
  27261. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  27262. /**
  27263. * 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.
  27264. * @param array
  27265. */
  27266. static arrayOrStringFeeder(array: any): (i: number) => number;
  27267. /**
  27268. * Compute the hashCode of a stream of number
  27269. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  27270. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  27271. * @return the hash code computed
  27272. */
  27273. static hashCodeFromStream(feeder: (index: number) => number): number;
  27274. /**
  27275. * Returns a promise that resolves after the given amount of time.
  27276. * @param delay Number of milliseconds to delay
  27277. * @returns Promise that resolves after the given amount of time
  27278. */
  27279. static DelayAsync(delay: number): Promise<void>;
  27280. }
  27281. /**
  27282. * This class is used to track a performance counter which is number based.
  27283. * The user has access to many properties which give statistics of different nature
  27284. *
  27285. * The implementer can track two kinds of Performance Counter: time and count
  27286. * 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.
  27287. * 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.
  27288. */
  27289. class PerfCounter {
  27290. static Enabled: boolean;
  27291. /**
  27292. * Returns the smallest value ever
  27293. */
  27294. readonly min: number;
  27295. /**
  27296. * Returns the biggest value ever
  27297. */
  27298. readonly max: number;
  27299. /**
  27300. * Returns the average value since the performance counter is running
  27301. */
  27302. readonly average: number;
  27303. /**
  27304. * Returns the average value of the last second the counter was monitored
  27305. */
  27306. readonly lastSecAverage: number;
  27307. /**
  27308. * Returns the current value
  27309. */
  27310. readonly current: number;
  27311. readonly total: number;
  27312. readonly count: number;
  27313. constructor();
  27314. /**
  27315. * Call this method to start monitoring a new frame.
  27316. * 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.
  27317. */
  27318. fetchNewFrame(): void;
  27319. /**
  27320. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  27321. * @param newCount the count value to add to the monitored count
  27322. * @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.
  27323. */
  27324. addCount(newCount: number, fetchResult: boolean): void;
  27325. /**
  27326. * Start monitoring this performance counter
  27327. */
  27328. beginMonitoring(): void;
  27329. /**
  27330. * Compute the time lapsed since the previous beginMonitoring() call.
  27331. * @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
  27332. */
  27333. endMonitoring(newFrame?: boolean): void;
  27334. private _fetchResult();
  27335. private _startMonitoringTime;
  27336. private _min;
  27337. private _max;
  27338. private _average;
  27339. private _current;
  27340. private _totalValueCount;
  27341. private _totalAccumulated;
  27342. private _lastSecAverage;
  27343. private _lastSecAccumulated;
  27344. private _lastSecTime;
  27345. private _lastSecValueCount;
  27346. }
  27347. /**
  27348. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  27349. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  27350. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  27351. * @param name The name of the class, case should be preserved
  27352. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  27353. */
  27354. function className(name: string, module?: string): (target: Object) => void;
  27355. /**
  27356. * An implementation of a loop for asynchronous functions.
  27357. */
  27358. class AsyncLoop {
  27359. iterations: number;
  27360. private _fn;
  27361. private _successCallback;
  27362. index: number;
  27363. private _done;
  27364. /**
  27365. * Constroctor.
  27366. * @param iterations the number of iterations.
  27367. * @param _fn the function to run each iteration
  27368. * @param _successCallback the callback that will be called upon succesful execution
  27369. * @param offset starting offset.
  27370. */
  27371. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  27372. /**
  27373. * Execute the next iteration. Must be called after the last iteration was finished.
  27374. */
  27375. executeNext(): void;
  27376. /**
  27377. * Break the loop and run the success callback.
  27378. */
  27379. breakLoop(): void;
  27380. /**
  27381. * Helper function
  27382. */
  27383. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  27384. /**
  27385. * A for-loop that will run a given number of iterations synchronous and the rest async.
  27386. * @param iterations total number of iterations
  27387. * @param syncedIterations number of synchronous iterations in each async iteration.
  27388. * @param fn the function to call each iteration.
  27389. * @param callback a success call back that will be called when iterating stops.
  27390. * @param breakFunction a break condition (optional)
  27391. * @param timeout timeout settings for the setTimeout function. default - 0.
  27392. * @constructor
  27393. */
  27394. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  27395. }
  27396. }
  27397. declare module BABYLON {
  27398. enum JoystickAxis {
  27399. X = 0,
  27400. Y = 1,
  27401. Z = 2,
  27402. }
  27403. class VirtualJoystick {
  27404. reverseLeftRight: boolean;
  27405. reverseUpDown: boolean;
  27406. deltaPosition: Vector3;
  27407. pressed: boolean;
  27408. private static _globalJoystickIndex;
  27409. private static vjCanvas;
  27410. private static vjCanvasContext;
  27411. private static vjCanvasWidth;
  27412. private static vjCanvasHeight;
  27413. private static halfWidth;
  27414. private _action;
  27415. private _axisTargetedByLeftAndRight;
  27416. private _axisTargetedByUpAndDown;
  27417. private _joystickSensibility;
  27418. private _inversedSensibility;
  27419. private _joystickPointerID;
  27420. private _joystickColor;
  27421. private _joystickPointerPos;
  27422. private _joystickPreviousPointerPos;
  27423. private _joystickPointerStartPos;
  27424. private _deltaJoystickVector;
  27425. private _leftJoystick;
  27426. private _touches;
  27427. private _onPointerDownHandlerRef;
  27428. private _onPointerMoveHandlerRef;
  27429. private _onPointerUpHandlerRef;
  27430. private _onResize;
  27431. constructor(leftJoystick?: boolean);
  27432. setJoystickSensibility(newJoystickSensibility: number): void;
  27433. private _onPointerDown(e);
  27434. private _onPointerMove(e);
  27435. private _onPointerUp(e);
  27436. /**
  27437. * Change the color of the virtual joystick
  27438. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  27439. */
  27440. setJoystickColor(newColor: string): void;
  27441. setActionOnTouch(action: () => any): void;
  27442. setAxisForLeftRight(axis: JoystickAxis): void;
  27443. setAxisForUpDown(axis: JoystickAxis): void;
  27444. private _drawVirtualJoystick();
  27445. releaseCanvas(): void;
  27446. }
  27447. }
  27448. declare module BABYLON {
  27449. /**
  27450. * Helper class to push actions to a pool of workers.
  27451. */
  27452. class WorkerPool implements IDisposable {
  27453. private _workerInfos;
  27454. private _pendingActions;
  27455. /**
  27456. * Constructor
  27457. * @param workers Array of workers to use for actions
  27458. */
  27459. constructor(workers: Array<Worker>);
  27460. /**
  27461. * Terminates all workers and clears any pending actions.
  27462. */
  27463. dispose(): void;
  27464. /**
  27465. * Pushes an action to the worker pool. If all the workers are active, the action will be
  27466. * pended until a worker has completed its action.
  27467. * @param action The action to perform. Call onComplete when the action is complete.
  27468. */
  27469. push(action: (worker: Worker, onComplete: () => void) => void): void;
  27470. private _execute(workerInfo, action);
  27471. }
  27472. }
  27473. declare module BABYLON {
  27474. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  27475. readonly name: string;
  27476. private _zoomStopsAnimation;
  27477. private _idleRotationSpeed;
  27478. private _idleRotationWaitTime;
  27479. private _idleRotationSpinupTime;
  27480. /**
  27481. * Gets the flag that indicates if user zooming should stop animation.
  27482. */
  27483. /**
  27484. * Sets the flag that indicates if user zooming should stop animation.
  27485. */
  27486. zoomStopsAnimation: boolean;
  27487. /**
  27488. * Gets the default speed at which the camera rotates around the model.
  27489. */
  27490. /**
  27491. * Sets the default speed at which the camera rotates around the model.
  27492. */
  27493. idleRotationSpeed: number;
  27494. /**
  27495. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  27496. */
  27497. /**
  27498. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  27499. */
  27500. idleRotationWaitTime: number;
  27501. /**
  27502. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  27503. */
  27504. /**
  27505. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  27506. */
  27507. idleRotationSpinupTime: number;
  27508. /**
  27509. * Gets a value indicating if the camera is currently rotating because of this behavior
  27510. */
  27511. readonly rotationInProgress: boolean;
  27512. private _onPrePointerObservableObserver;
  27513. private _onAfterCheckInputsObserver;
  27514. private _attachedCamera;
  27515. private _isPointerDown;
  27516. private _lastFrameTime;
  27517. private _lastInteractionTime;
  27518. private _cameraRotationSpeed;
  27519. init(): void;
  27520. attach(camera: ArcRotateCamera): void;
  27521. detach(): void;
  27522. /**
  27523. * Returns true if user is scrolling.
  27524. * @return true if user is scrolling.
  27525. */
  27526. private _userIsZooming();
  27527. private _lastFrameRadius;
  27528. private _shouldAnimationStopForInteraction();
  27529. /**
  27530. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  27531. */
  27532. private _applyUserInteraction();
  27533. private _userIsMoving();
  27534. }
  27535. }
  27536. declare module BABYLON {
  27537. /**
  27538. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  27539. */
  27540. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  27541. readonly name: string;
  27542. /**
  27543. * The easing function used by animations
  27544. */
  27545. static EasingFunction: BackEase;
  27546. /**
  27547. * The easing mode used by animations
  27548. */
  27549. static EasingMode: number;
  27550. /**
  27551. * The duration of the animation, in milliseconds
  27552. */
  27553. transitionDuration: number;
  27554. /**
  27555. * Length of the distance animated by the transition when lower radius is reached
  27556. */
  27557. lowerRadiusTransitionRange: number;
  27558. /**
  27559. * Length of the distance animated by the transition when upper radius is reached
  27560. */
  27561. upperRadiusTransitionRange: number;
  27562. private _autoTransitionRange;
  27563. /**
  27564. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  27565. */
  27566. /**
  27567. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  27568. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  27569. */
  27570. autoTransitionRange: boolean;
  27571. private _attachedCamera;
  27572. private _onAfterCheckInputsObserver;
  27573. private _onMeshTargetChangedObserver;
  27574. init(): void;
  27575. attach(camera: ArcRotateCamera): void;
  27576. detach(): void;
  27577. private _radiusIsAnimating;
  27578. private _radiusBounceTransition;
  27579. private _animatables;
  27580. private _cachedWheelPrecision;
  27581. /**
  27582. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  27583. * @param radiusLimit The limit to check against.
  27584. * @return Bool to indicate if at limit.
  27585. */
  27586. private _isRadiusAtLimit(radiusLimit);
  27587. /**
  27588. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  27589. * @param radiusDelta The delta by which to animate to. Can be negative.
  27590. */
  27591. private _applyBoundRadiusAnimation(radiusDelta);
  27592. /**
  27593. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  27594. */
  27595. protected _clearAnimationLocks(): void;
  27596. /**
  27597. * Stops and removes all animations that have been applied to the camera
  27598. */
  27599. stopAllAnimations(): void;
  27600. }
  27601. }
  27602. declare module BABYLON {
  27603. class FramingBehavior implements Behavior<ArcRotateCamera> {
  27604. readonly name: string;
  27605. private _mode;
  27606. private _radiusScale;
  27607. private _positionScale;
  27608. private _defaultElevation;
  27609. private _elevationReturnTime;
  27610. private _elevationReturnWaitTime;
  27611. private _zoomStopsAnimation;
  27612. private _framingTime;
  27613. /**
  27614. * The easing function used by animations
  27615. */
  27616. static EasingFunction: ExponentialEase;
  27617. /**
  27618. * The easing mode used by animations
  27619. */
  27620. static EasingMode: number;
  27621. /**
  27622. * Gets current mode used by the behavior.
  27623. */
  27624. /**
  27625. * Sets the current mode used by the behavior
  27626. */
  27627. mode: number;
  27628. /**
  27629. * Gets the scale applied to the radius
  27630. */
  27631. /**
  27632. * Sets the scale applied to the radius (1 by default)
  27633. */
  27634. radiusScale: number;
  27635. /**
  27636. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  27637. */
  27638. /**
  27639. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  27640. */
  27641. positionScale: number;
  27642. /**
  27643. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  27644. * behaviour is triggered, in radians.
  27645. */
  27646. /**
  27647. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  27648. * behaviour is triggered, in radians.
  27649. */
  27650. defaultElevation: number;
  27651. /**
  27652. * Gets the time (in milliseconds) taken to return to the default beta position.
  27653. * Negative value indicates camera should not return to default.
  27654. */
  27655. /**
  27656. * Sets the time (in milliseconds) taken to return to the default beta position.
  27657. * Negative value indicates camera should not return to default.
  27658. */
  27659. elevationReturnTime: number;
  27660. /**
  27661. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  27662. */
  27663. /**
  27664. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  27665. */
  27666. elevationReturnWaitTime: number;
  27667. /**
  27668. * Gets the flag that indicates if user zooming should stop animation.
  27669. */
  27670. /**
  27671. * Sets the flag that indicates if user zooming should stop animation.
  27672. */
  27673. zoomStopsAnimation: boolean;
  27674. /**
  27675. * Gets the transition time when framing the mesh, in milliseconds
  27676. */
  27677. /**
  27678. * Sets the transition time when framing the mesh, in milliseconds
  27679. */
  27680. framingTime: number;
  27681. private _onPrePointerObservableObserver;
  27682. private _onAfterCheckInputsObserver;
  27683. private _onMeshTargetChangedObserver;
  27684. private _attachedCamera;
  27685. private _isPointerDown;
  27686. private _lastInteractionTime;
  27687. init(): void;
  27688. attach(camera: ArcRotateCamera): void;
  27689. detach(): void;
  27690. private _animatables;
  27691. private _betaIsAnimating;
  27692. private _betaTransition;
  27693. private _radiusTransition;
  27694. private _vectorTransition;
  27695. /**
  27696. * Targets the given mesh and updates zoom level accordingly.
  27697. * @param mesh The mesh to target.
  27698. * @param radius Optional. If a cached radius position already exists, overrides default.
  27699. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  27700. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  27701. * @param onAnimationEnd Callback triggered at the end of the framing animation
  27702. */
  27703. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  27704. /**
  27705. * Targets the given mesh with its children and updates zoom level accordingly.
  27706. * @param mesh The mesh to target.
  27707. * @param radius Optional. If a cached radius position already exists, overrides default.
  27708. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  27709. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  27710. * @param onAnimationEnd Callback triggered at the end of the framing animation
  27711. */
  27712. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  27713. /**
  27714. * Targets the given meshes with their children and updates zoom level accordingly.
  27715. * @param meshes The mesh to target.
  27716. * @param radius Optional. If a cached radius position already exists, overrides default.
  27717. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  27718. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  27719. * @param onAnimationEnd Callback triggered at the end of the framing animation
  27720. */
  27721. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  27722. /**
  27723. * Targets the given mesh and updates zoom level accordingly.
  27724. * @param mesh The mesh to target.
  27725. * @param radius Optional. If a cached radius position already exists, overrides default.
  27726. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  27727. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  27728. * @param onAnimationEnd Callback triggered at the end of the framing animation
  27729. */
  27730. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  27731. /**
  27732. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  27733. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  27734. * frustum width.
  27735. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  27736. * to fully enclose the mesh in the viewing frustum.
  27737. */
  27738. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  27739. /**
  27740. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  27741. * is automatically returned to its default position (expected to be above ground plane).
  27742. */
  27743. private _maintainCameraAboveGround();
  27744. /**
  27745. * Returns the frustum slope based on the canvas ratio and camera FOV
  27746. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  27747. */
  27748. private _getFrustumSlope();
  27749. /**
  27750. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  27751. */
  27752. private _clearAnimationLocks();
  27753. /**
  27754. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  27755. */
  27756. private _applyUserInteraction();
  27757. /**
  27758. * Stops and removes all animations that have been applied to the camera
  27759. */
  27760. stopAllAnimations(): void;
  27761. /**
  27762. * Gets a value indicating if the user is moving the camera
  27763. */
  27764. readonly isUserIsMoving: boolean;
  27765. /**
  27766. * The camera can move all the way towards the mesh.
  27767. */
  27768. static IgnoreBoundsSizeMode: number;
  27769. /**
  27770. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  27771. */
  27772. static FitFrustumSidesMode: number;
  27773. }
  27774. }
  27775. declare module BABYLON {
  27776. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  27777. camera: ArcRotateCamera;
  27778. gamepad: Nullable<Gamepad>;
  27779. private _onGamepadConnectedObserver;
  27780. private _onGamepadDisconnectedObserver;
  27781. gamepadRotationSensibility: number;
  27782. gamepadMoveSensibility: number;
  27783. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27784. detachControl(element: Nullable<HTMLElement>): void;
  27785. checkInputs(): void;
  27786. getClassName(): string;
  27787. getSimpleName(): string;
  27788. }
  27789. }
  27790. declare module BABYLON {
  27791. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  27792. camera: ArcRotateCamera;
  27793. private _keys;
  27794. keysUp: number[];
  27795. keysDown: number[];
  27796. keysLeft: number[];
  27797. keysRight: number[];
  27798. keysReset: number[];
  27799. panningSensibility: number;
  27800. zoomingSensibility: number;
  27801. useAltToZoom: boolean;
  27802. private _ctrlPressed;
  27803. private _altPressed;
  27804. private _onCanvasBlurObserver;
  27805. private _onKeyboardObserver;
  27806. private _engine;
  27807. private _scene;
  27808. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27809. detachControl(element: Nullable<HTMLElement>): void;
  27810. checkInputs(): void;
  27811. getClassName(): string;
  27812. getSimpleName(): string;
  27813. }
  27814. }
  27815. declare module BABYLON {
  27816. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  27817. camera: ArcRotateCamera;
  27818. private _wheel;
  27819. private _observer;
  27820. wheelPrecision: number;
  27821. /**
  27822. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  27823. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  27824. */
  27825. wheelDeltaPercentage: number;
  27826. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27827. detachControl(element: Nullable<HTMLElement>): void;
  27828. getClassName(): string;
  27829. getSimpleName(): string;
  27830. }
  27831. }
  27832. declare module BABYLON {
  27833. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  27834. camera: ArcRotateCamera;
  27835. buttons: number[];
  27836. angularSensibilityX: number;
  27837. angularSensibilityY: number;
  27838. pinchPrecision: number;
  27839. /**
  27840. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  27841. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  27842. */
  27843. pinchDeltaPercentage: number;
  27844. panningSensibility: number;
  27845. multiTouchPanning: boolean;
  27846. multiTouchPanAndZoom: boolean;
  27847. private _isPanClick;
  27848. pinchInwards: boolean;
  27849. private _pointerInput;
  27850. private _observer;
  27851. private _onMouseMove;
  27852. private _onGestureStart;
  27853. private _onGesture;
  27854. private _MSGestureHandler;
  27855. private _onLostFocus;
  27856. private _onContextMenu;
  27857. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27858. detachControl(element: Nullable<HTMLElement>): void;
  27859. getClassName(): string;
  27860. getSimpleName(): string;
  27861. }
  27862. }
  27863. declare module BABYLON {
  27864. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  27865. camera: ArcRotateCamera;
  27866. alphaCorrection: number;
  27867. betaCorrection: number;
  27868. gammaCorrection: number;
  27869. private _alpha;
  27870. private _gamma;
  27871. private _dirty;
  27872. private _deviceOrientationHandler;
  27873. constructor();
  27874. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27875. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  27876. checkInputs(): void;
  27877. detachControl(element: Nullable<HTMLElement>): void;
  27878. getClassName(): string;
  27879. getSimpleName(): string;
  27880. }
  27881. }
  27882. declare module BABYLON {
  27883. /**
  27884. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  27885. * Screen rotation is taken into account.
  27886. */
  27887. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  27888. private _camera;
  27889. private _screenOrientationAngle;
  27890. private _constantTranform;
  27891. private _screenQuaternion;
  27892. private _alpha;
  27893. private _beta;
  27894. private _gamma;
  27895. constructor();
  27896. camera: FreeCamera;
  27897. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27898. private _orientationChanged;
  27899. private _deviceOrientation;
  27900. detachControl(element: Nullable<HTMLElement>): void;
  27901. checkInputs(): void;
  27902. getClassName(): string;
  27903. getSimpleName(): string;
  27904. }
  27905. }
  27906. declare module BABYLON {
  27907. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  27908. camera: FreeCamera;
  27909. gamepad: Nullable<Gamepad>;
  27910. private _onGamepadConnectedObserver;
  27911. private _onGamepadDisconnectedObserver;
  27912. gamepadAngularSensibility: number;
  27913. gamepadMoveSensibility: number;
  27914. private _cameraTransform;
  27915. private _deltaTransform;
  27916. private _vector3;
  27917. private _vector2;
  27918. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27919. detachControl(element: Nullable<HTMLElement>): void;
  27920. checkInputs(): void;
  27921. getClassName(): string;
  27922. getSimpleName(): string;
  27923. }
  27924. }
  27925. declare module BABYLON {
  27926. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  27927. camera: FreeCamera;
  27928. private _keys;
  27929. private _onCanvasBlurObserver;
  27930. private _onKeyboardObserver;
  27931. private _engine;
  27932. private _scene;
  27933. keysUp: number[];
  27934. keysDown: number[];
  27935. keysLeft: number[];
  27936. keysRight: number[];
  27937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27938. detachControl(element: Nullable<HTMLElement>): void;
  27939. checkInputs(): void;
  27940. getClassName(): string;
  27941. _onLostFocus(e: FocusEvent): void;
  27942. getSimpleName(): string;
  27943. }
  27944. }
  27945. declare module BABYLON {
  27946. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  27947. touchEnabled: boolean;
  27948. camera: FreeCamera;
  27949. buttons: number[];
  27950. angularSensibility: number;
  27951. private _pointerInput;
  27952. private _onMouseMove;
  27953. private _observer;
  27954. private previousPosition;
  27955. constructor(touchEnabled?: boolean);
  27956. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27957. detachControl(element: Nullable<HTMLElement>): void;
  27958. getClassName(): string;
  27959. getSimpleName(): string;
  27960. }
  27961. }
  27962. declare module BABYLON {
  27963. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  27964. camera: FreeCamera;
  27965. private _offsetX;
  27966. private _offsetY;
  27967. private _pointerPressed;
  27968. private _pointerInput;
  27969. private _observer;
  27970. private _onLostFocus;
  27971. touchAngularSensibility: number;
  27972. touchMoveSensibility: number;
  27973. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27974. detachControl(element: Nullable<HTMLElement>): void;
  27975. checkInputs(): void;
  27976. getClassName(): string;
  27977. getSimpleName(): string;
  27978. }
  27979. }
  27980. declare module BABYLON {
  27981. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  27982. camera: FreeCamera;
  27983. private _leftjoystick;
  27984. private _rightjoystick;
  27985. getLeftJoystick(): VirtualJoystick;
  27986. getRightJoystick(): VirtualJoystick;
  27987. checkInputs(): void;
  27988. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  27989. detachControl(element: Nullable<HTMLElement>): void;
  27990. getClassName(): string;
  27991. getSimpleName(): string;
  27992. }
  27993. }
  27994. declare module BABYLON {
  27995. class VRCameraMetrics {
  27996. hResolution: number;
  27997. vResolution: number;
  27998. hScreenSize: number;
  27999. vScreenSize: number;
  28000. vScreenCenter: number;
  28001. eyeToScreenDistance: number;
  28002. lensSeparationDistance: number;
  28003. interpupillaryDistance: number;
  28004. distortionK: number[];
  28005. chromaAbCorrection: number[];
  28006. postProcessScaleFactor: number;
  28007. lensCenterOffset: number;
  28008. compensateDistortion: boolean;
  28009. readonly aspectRatio: number;
  28010. readonly aspectRatioFov: number;
  28011. readonly leftHMatrix: Matrix;
  28012. readonly rightHMatrix: Matrix;
  28013. readonly leftPreViewMatrix: Matrix;
  28014. readonly rightPreViewMatrix: Matrix;
  28015. static GetDefault(): VRCameraMetrics;
  28016. }
  28017. }
  28018. declare module BABYLON {
  28019. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  28020. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  28021. getClassName(): string;
  28022. }
  28023. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  28024. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  28025. getClassName(): string;
  28026. }
  28027. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  28028. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  28029. getClassName(): string;
  28030. }
  28031. }
  28032. declare module BABYLON {
  28033. /**
  28034. * Options to modify the vr teleportation behavior.
  28035. */
  28036. interface VRTeleportationOptions {
  28037. /**
  28038. * The name of the mesh which should be used as the teleportation floor. (default: null)
  28039. */
  28040. floorMeshName?: string;
  28041. /**
  28042. * A list of meshes to be used as the teleportation floor. (default: empty)
  28043. */
  28044. floorMeshes?: Mesh[];
  28045. }
  28046. /**
  28047. * Options to modify the vr experience helper's behavior.
  28048. */
  28049. interface VRExperienceHelperOptions extends WebVROptions {
  28050. /**
  28051. * Create a DeviceOrientationCamera to be used as your out of vr camera.
  28052. */
  28053. createDeviceOrientationCamera?: boolean;
  28054. /**
  28055. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found.
  28056. */
  28057. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  28058. }
  28059. /**
  28060. * Helps to quickly add VR support to an existing scene.
  28061. * See http://doc.babylonjs.com/how_to/webvr_helper
  28062. */
  28063. class VRExperienceHelper {
  28064. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  28065. private _scene;
  28066. private _position;
  28067. private _btnVR;
  28068. private _btnVRDisplayed;
  28069. private _webVRsupported;
  28070. private _webVRready;
  28071. private _webVRrequesting;
  28072. private _webVRpresenting;
  28073. private _fullscreenVRpresenting;
  28074. private _canvas;
  28075. private _webVRCamera;
  28076. private _vrDeviceOrientationCamera;
  28077. private _deviceOrientationCamera;
  28078. private _existingCamera;
  28079. private _onKeyDown;
  28080. private _onVrDisplayPresentChange;
  28081. private _onVRDisplayChanged;
  28082. private _onVRRequestPresentStart;
  28083. private _onVRRequestPresentComplete;
  28084. /**
  28085. * Observable raised when entering VR.
  28086. */
  28087. onEnteringVRObservable: Observable<VRExperienceHelper>;
  28088. /**
  28089. * Observable raised when exiting VR.
  28090. */
  28091. onExitingVRObservable: Observable<VRExperienceHelper>;
  28092. /**
  28093. * Observable raised when controller mesh is loaded.
  28094. */
  28095. onControllerMeshLoadedObservable: Observable<WebVRController>;
  28096. /** Return this.onEnteringVRObservable
  28097. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  28098. */
  28099. readonly onEnteringVR: Observable<VRExperienceHelper>;
  28100. /** Return this.onExitingVRObservable
  28101. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  28102. */
  28103. readonly onExitingVR: Observable<VRExperienceHelper>;
  28104. /** Return this.onControllerMeshLoadedObservable
  28105. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  28106. */
  28107. readonly onControllerMeshLoaded: Observable<WebVRController>;
  28108. private _rayLength;
  28109. private _useCustomVRButton;
  28110. private _teleportationRequested;
  28111. private _teleportActive;
  28112. private _floorMeshName;
  28113. private _floorMeshesCollection;
  28114. private _rotationAllowed;
  28115. private _teleportBackwardsVector;
  28116. private _rotationRightAsked;
  28117. private _rotationLeftAsked;
  28118. private _teleportationTarget;
  28119. private _isDefaultTeleportationTarget;
  28120. private _postProcessMove;
  28121. private _teleportationFillColor;
  28122. private _teleportationBorderColor;
  28123. private _rotationAngle;
  28124. private _haloCenter;
  28125. private _cameraGazer;
  28126. private _padSensibilityUp;
  28127. private _padSensibilityDown;
  28128. private leftController;
  28129. private rightController;
  28130. /**
  28131. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  28132. */
  28133. onNewMeshSelected: Observable<AbstractMesh>;
  28134. /**
  28135. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  28136. */
  28137. onNewMeshPicked: Observable<PickingInfo>;
  28138. private _circleEase;
  28139. /**
  28140. * Observable raised before camera teleportation
  28141. */
  28142. onBeforeCameraTeleport: Observable<Vector3>;
  28143. /**
  28144. * Observable raised after camera teleportation
  28145. */
  28146. onAfterCameraTeleport: Observable<Vector3>;
  28147. /**
  28148. * Observable raised when current selected mesh gets unselected
  28149. */
  28150. onSelectedMeshUnselected: Observable<AbstractMesh>;
  28151. private _raySelectionPredicate;
  28152. /**
  28153. * To be optionaly changed by user to define custom ray selection
  28154. */
  28155. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  28156. /**
  28157. * To be optionaly changed by user to define custom selection logic (after ray selection)
  28158. */
  28159. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  28160. /**
  28161. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  28162. */
  28163. teleportationEnabled: boolean;
  28164. private _defaultHeight;
  28165. private _teleportationInitialized;
  28166. private _interactionsEnabled;
  28167. private _interactionsRequested;
  28168. private _displayGaze;
  28169. private _displayLaserPointer;
  28170. /**
  28171. * The mesh used to display where the user is going to teleport.
  28172. */
  28173. /**
  28174. * Sets the mesh to be used to display where the user is going to teleport.
  28175. */
  28176. teleportationTarget: Mesh;
  28177. /**
  28178. * The mesh used to display where the user is selecting,
  28179. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  28180. * See http://doc.babylonjs.com/resources/baking_transformations
  28181. */
  28182. gazeTrackerMesh: Mesh;
  28183. /**
  28184. * If the ray of the gaze should be displayed.
  28185. */
  28186. /**
  28187. * Sets if the ray of the gaze should be displayed.
  28188. */
  28189. displayGaze: boolean;
  28190. /**
  28191. * If the ray of the LaserPointer should be displayed.
  28192. */
  28193. /**
  28194. * Sets if the ray of the LaserPointer should be displayed.
  28195. */
  28196. displayLaserPointer: boolean;
  28197. /**
  28198. * The deviceOrientationCamera used as the camera when not in VR.
  28199. */
  28200. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  28201. /**
  28202. * Based on the current WebVR support, returns the current VR camera used.
  28203. */
  28204. readonly currentVRCamera: Nullable<Camera>;
  28205. /**
  28206. * The webVRCamera which is used when in VR.
  28207. */
  28208. readonly webVRCamera: WebVRFreeCamera;
  28209. /**
  28210. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  28211. */
  28212. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  28213. private readonly _teleportationRequestInitiated;
  28214. /**
  28215. * Instantiates a VRExperienceHelper.
  28216. * Helps to quickly add VR support to an existing scene.
  28217. * @param scene The scene the VRExperienceHelper belongs to.
  28218. * @param webVROptions Options to modify the vr experience helper's behavior.
  28219. */
  28220. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  28221. private _onDefaultMeshLoaded(webVRController);
  28222. private _onResize;
  28223. private _onFullscreenChange;
  28224. /**
  28225. * Gets a value indicating if we are currently in VR mode.
  28226. */
  28227. readonly isInVRMode: boolean;
  28228. private onVrDisplayPresentChange();
  28229. private onVRDisplayChanged(eventArgs);
  28230. private moveButtonToBottomRight();
  28231. private displayVRButton();
  28232. private updateButtonVisibility();
  28233. /**
  28234. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  28235. * Otherwise, will use the fullscreen API.
  28236. */
  28237. enterVR(): void;
  28238. /**
  28239. * Attempt to exit VR, or fullscreen.
  28240. */
  28241. exitVR(): void;
  28242. /**
  28243. * The position of the vr experience helper.
  28244. */
  28245. /**
  28246. * Sets the position of the vr experience helper.
  28247. */
  28248. position: Vector3;
  28249. /**
  28250. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  28251. */
  28252. enableInteractions(): void;
  28253. private beforeRender;
  28254. private _isTeleportationFloor(mesh);
  28255. /**
  28256. * Adds a floor mesh to be used for teleportation.
  28257. * @param floorMesh the mesh to be used for teleportation.
  28258. */
  28259. addFloorMesh(floorMesh: Mesh): void;
  28260. /**
  28261. * Removes a floor mesh from being used for teleportation.
  28262. * @param floorMesh the mesh to be removed.
  28263. */
  28264. removeFloorMesh(floorMesh: Mesh): void;
  28265. /**
  28266. * Enables interactions and teleportation using the VR controllers and gaze.
  28267. * @param vrTeleportationOptions options to modify teleportation behavior.
  28268. */
  28269. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  28270. private _onNewGamepadConnected;
  28271. private _tryEnableInteractionOnController;
  28272. private _onNewGamepadDisconnected;
  28273. private _enableInteractionOnController(controller);
  28274. private _checkTeleportWithRay(stateObject, gazer);
  28275. private _checkRotate(stateObject, gazer);
  28276. private _checkTeleportBackwards(stateObject, gazer);
  28277. private _enableTeleportationOnController(controller);
  28278. private _createTeleportationCircles();
  28279. private _displayTeleportationTarget();
  28280. private _hideTeleportationTarget();
  28281. private _rotateCamera(right);
  28282. private _moveTeleportationSelectorTo(hit, gazer);
  28283. private _workingVector;
  28284. private _workingQuaternion;
  28285. private _workingMatrix;
  28286. private _teleportCamera(location);
  28287. private _castRayAndSelectObject(gazer);
  28288. private _notifySelectedMeshUnselected(mesh);
  28289. /**
  28290. * Sets the color of the laser ray from the vr controllers.
  28291. * @param color new color for the ray.
  28292. */
  28293. changeLaserColor(color: Color3): void;
  28294. /**
  28295. * Sets the color of the ray from the vr headsets gaze.
  28296. * @param color new color for the ray.
  28297. */
  28298. changeGazeColor(color: Color3): void;
  28299. /**
  28300. * Exits VR and disposes of the vr experience helper
  28301. */
  28302. dispose(): void;
  28303. /**
  28304. * Gets the name of the VRExperienceHelper class
  28305. * @returns "VRExperienceHelper"
  28306. */
  28307. getClassName(): string;
  28308. }
  28309. }
  28310. declare module BABYLON {
  28311. /**
  28312. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  28313. * IMPORTANT!! The data is right-hand data.
  28314. * @export
  28315. * @interface DevicePose
  28316. */
  28317. interface DevicePose {
  28318. /**
  28319. * The position of the device, values in array are [x,y,z].
  28320. */
  28321. readonly position: Nullable<Float32Array>;
  28322. /**
  28323. * The linearVelocity of the device, values in array are [x,y,z].
  28324. */
  28325. readonly linearVelocity: Nullable<Float32Array>;
  28326. /**
  28327. * The linearAcceleration of the device, values in array are [x,y,z].
  28328. */
  28329. readonly linearAcceleration: Nullable<Float32Array>;
  28330. /**
  28331. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  28332. */
  28333. readonly orientation: Nullable<Float32Array>;
  28334. /**
  28335. * The angularVelocity of the device, values in array are [x,y,z].
  28336. */
  28337. readonly angularVelocity: Nullable<Float32Array>;
  28338. /**
  28339. * The angularAcceleration of the device, values in array are [x,y,z].
  28340. */
  28341. readonly angularAcceleration: Nullable<Float32Array>;
  28342. }
  28343. /**
  28344. * Interface representing a pose controlled object in Babylon.
  28345. * A pose controlled object has both regular pose values as well as pose values
  28346. * from an external device such as a VR head mounted display
  28347. */
  28348. interface PoseControlled {
  28349. /**
  28350. * The position of the object in babylon space.
  28351. */
  28352. position: Vector3;
  28353. /**
  28354. * The rotation quaternion of the object in babylon space.
  28355. */
  28356. rotationQuaternion: Quaternion;
  28357. /**
  28358. * The position of the device in babylon space.
  28359. */
  28360. devicePosition?: Vector3;
  28361. /**
  28362. * The rotation quaternion of the device in babylon space.
  28363. */
  28364. deviceRotationQuaternion: Quaternion;
  28365. /**
  28366. * The raw pose coming from the device.
  28367. */
  28368. rawPose: Nullable<DevicePose>;
  28369. /**
  28370. * The scale of the device to be used when translating from device space to babylon space.
  28371. */
  28372. deviceScaleFactor: number;
  28373. /**
  28374. * Updates the poseControlled values based on the input device pose.
  28375. * @param poseData the pose data to update the object with
  28376. */
  28377. updateFromDevice(poseData: DevicePose): void;
  28378. }
  28379. /**
  28380. * Set of options to customize the webVRCamera
  28381. */
  28382. interface WebVROptions {
  28383. /**
  28384. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  28385. */
  28386. trackPosition?: boolean;
  28387. /**
  28388. * Sets the scale of the vrDevice in babylon space. (default: 1)
  28389. */
  28390. positionScale?: number;
  28391. /**
  28392. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  28393. */
  28394. displayName?: string;
  28395. /**
  28396. * Should the native controller meshes be initialized. (default: true)
  28397. */
  28398. controllerMeshes?: boolean;
  28399. /**
  28400. * Creating a default HemiLight only on controllers. (default: true)
  28401. */
  28402. defaultLightingOnControllers?: boolean;
  28403. /**
  28404. * If you don't want to use the default VR button of the helper. (default: false)
  28405. */
  28406. useCustomVRButton?: boolean;
  28407. /**
  28408. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  28409. */
  28410. customVRButton?: HTMLButtonElement;
  28411. /**
  28412. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  28413. */
  28414. rayLength?: number;
  28415. /**
  28416. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  28417. */
  28418. defaultHeight?: number;
  28419. }
  28420. /**
  28421. * This represents a WebVR camera.
  28422. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  28423. * @example http://doc.babylonjs.com/how_to/webvr_camera
  28424. */
  28425. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  28426. private webVROptions;
  28427. /**
  28428. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  28429. */
  28430. _vrDevice: any;
  28431. /**
  28432. * The rawPose of the vrDevice.
  28433. */
  28434. rawPose: Nullable<DevicePose>;
  28435. private _onVREnabled;
  28436. private _specsVersion;
  28437. private _attached;
  28438. private _frameData;
  28439. protected _descendants: Array<Node>;
  28440. private _deviceRoomPosition;
  28441. private _deviceRoomRotationQuaternion;
  28442. private _standingMatrix;
  28443. /**
  28444. * Represents device position in babylon space.
  28445. */
  28446. devicePosition: Vector3;
  28447. /**
  28448. * Represents device rotation in babylon space.
  28449. */
  28450. deviceRotationQuaternion: Quaternion;
  28451. /**
  28452. * The scale of the device to be used when translating from device space to babylon space.
  28453. */
  28454. deviceScaleFactor: number;
  28455. private _deviceToWorld;
  28456. private _worldToDevice;
  28457. /**
  28458. * References to the webVR controllers for the vrDevice.
  28459. */
  28460. controllers: Array<WebVRController>;
  28461. /**
  28462. * Emits an event when a controller is attached.
  28463. */
  28464. onControllersAttachedObservable: Observable<WebVRController[]>;
  28465. /**
  28466. * Emits an event when a controller's mesh has been loaded;
  28467. */
  28468. onControllerMeshLoadedObservable: Observable<WebVRController>;
  28469. /**
  28470. * If the rig cameras be used as parent instead of this camera.
  28471. */
  28472. rigParenting: boolean;
  28473. private _lightOnControllers;
  28474. private _defaultHeight?;
  28475. /**
  28476. * Instantiates a WebVRFreeCamera.
  28477. * @param name The name of the WebVRFreeCamera
  28478. * @param position The starting anchor position for the camera
  28479. * @param scene The scene the camera belongs to
  28480. * @param webVROptions a set of customizable options for the webVRCamera
  28481. */
  28482. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  28483. /**
  28484. * Gets the device distance from the ground in meters.
  28485. * @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.
  28486. */
  28487. deviceDistanceToRoomGround(): number;
  28488. /**
  28489. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28490. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  28491. */
  28492. useStandingMatrix(callback?: (bool: boolean) => void): void;
  28493. /**
  28494. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28495. * @returns A promise with a boolean set to if the standing matrix is supported.
  28496. */
  28497. useStandingMatrixAsync(): Promise<boolean>;
  28498. /**
  28499. * Disposes the camera
  28500. */
  28501. dispose(): void;
  28502. /**
  28503. * Gets a vrController by name.
  28504. * @param name The name of the controller to retreive
  28505. * @returns the controller matching the name specified or null if not found
  28506. */
  28507. getControllerByName(name: string): Nullable<WebVRController>;
  28508. private _leftController;
  28509. /**
  28510. * The controller corrisponding to the users left hand.
  28511. */
  28512. readonly leftController: Nullable<WebVRController>;
  28513. private _rightController;
  28514. /**
  28515. * The controller corrisponding to the users right hand.
  28516. */
  28517. readonly rightController: Nullable<WebVRController>;
  28518. /**
  28519. * Casts a ray forward from the vrCamera's gaze.
  28520. * @param length Length of the ray (default: 100)
  28521. * @returns the ray corrisponding to the gaze
  28522. */
  28523. getForwardRay(length?: number): Ray;
  28524. /**
  28525. * Updates the camera based on device's frame data
  28526. */
  28527. _checkInputs(): void;
  28528. /**
  28529. * Updates the poseControlled values based on the input device pose.
  28530. * @param poseData Pose coming from the device
  28531. */
  28532. updateFromDevice(poseData: DevicePose): void;
  28533. /**
  28534. * WebVR's attach control will start broadcasting frames to the device.
  28535. * Note that in certain browsers (chrome for example) this function must be called
  28536. * within a user-interaction callback. Example:
  28537. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  28538. *
  28539. * @param element html element to attach the vrDevice to
  28540. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  28541. */
  28542. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28543. /**
  28544. * Detaches the camera from the html element and disables VR
  28545. *
  28546. * @param element html element to detach from
  28547. */
  28548. detachControl(element: HTMLElement): void;
  28549. /**
  28550. * @returns the name of this class
  28551. */
  28552. getClassName(): string;
  28553. /**
  28554. * Calls resetPose on the vrDisplay
  28555. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  28556. */
  28557. resetToCurrentRotation(): void;
  28558. /**
  28559. * Updates the rig cameras (left and right eye)
  28560. */
  28561. _updateRigCameras(): void;
  28562. private _workingVector;
  28563. private _oneVector;
  28564. private _workingMatrix;
  28565. private updateCacheCalled;
  28566. /**
  28567. * Updates the cached values of the camera
  28568. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  28569. */
  28570. _updateCache(ignoreParentClass?: boolean): void;
  28571. /**
  28572. * Updates the current device position and rotation in the babylon world
  28573. */
  28574. update(): void;
  28575. /**
  28576. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  28577. * @returns an identity matrix
  28578. */
  28579. _getViewMatrix(): Matrix;
  28580. /**
  28581. * This function is called by the two RIG cameras.
  28582. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  28583. */
  28584. protected _getWebVRViewMatrix(): Matrix;
  28585. protected _getWebVRProjectionMatrix(): Matrix;
  28586. private _onGamepadConnectedObserver;
  28587. private _onGamepadDisconnectedObserver;
  28588. /**
  28589. * Initializes the controllers and their meshes
  28590. */
  28591. initControllers(): void;
  28592. }
  28593. }
  28594. declare module BABYLON {
  28595. interface IOctreeContainer<T> {
  28596. blocks: Array<OctreeBlock<T>>;
  28597. }
  28598. class Octree<T> {
  28599. maxDepth: number;
  28600. blocks: Array<OctreeBlock<T>>;
  28601. dynamicContent: T[];
  28602. private _maxBlockCapacity;
  28603. private _selectionContent;
  28604. private _creationFunc;
  28605. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  28606. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  28607. addMesh(entry: T): void;
  28608. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  28609. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  28610. intersectsRay(ray: Ray): SmartArray<T>;
  28611. 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;
  28612. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  28613. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  28614. }
  28615. }
  28616. declare module BABYLON {
  28617. class OctreeBlock<T> {
  28618. entries: T[];
  28619. blocks: Array<OctreeBlock<T>>;
  28620. private _depth;
  28621. private _maxDepth;
  28622. private _capacity;
  28623. private _minPoint;
  28624. private _maxPoint;
  28625. private _boundingVectors;
  28626. private _creationFunc;
  28627. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  28628. readonly capacity: number;
  28629. readonly minPoint: Vector3;
  28630. readonly maxPoint: Vector3;
  28631. addEntry(entry: T): void;
  28632. addEntries(entries: T[]): void;
  28633. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  28634. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  28635. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  28636. createInnerBlocks(): void;
  28637. }
  28638. }
  28639. declare module BABYLON {
  28640. /**
  28641. * Google Daydream controller
  28642. */
  28643. class DaydreamController extends WebVRController {
  28644. /**
  28645. * Base Url for the controller model.
  28646. */
  28647. static MODEL_BASE_URL: string;
  28648. /**
  28649. * File name for the controller model.
  28650. */
  28651. static MODEL_FILENAME: string;
  28652. /**
  28653. * Gamepad Id prefix used to identify Daydream Controller.
  28654. */
  28655. static readonly GAMEPAD_ID_PREFIX: string;
  28656. /**
  28657. * Creates a new DaydreamController from a gamepad
  28658. * @param vrGamepad the gamepad that the controller should be created from
  28659. */
  28660. constructor(vrGamepad: any);
  28661. /**
  28662. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  28663. * @param scene scene in which to add meshes
  28664. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  28665. */
  28666. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  28667. /**
  28668. * Called once for each button that changed state since the last frame
  28669. * @param buttonIdx Which button index changed
  28670. * @param state New state of the button
  28671. * @param changes Which properties on the state changed since last frame
  28672. */
  28673. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  28674. }
  28675. }
  28676. declare module BABYLON {
  28677. /**
  28678. * Gear VR Controller
  28679. */
  28680. class GearVRController extends WebVRController {
  28681. /**
  28682. * Base Url for the controller model.
  28683. */
  28684. static MODEL_BASE_URL: string;
  28685. /**
  28686. * File name for the controller model.
  28687. */
  28688. static MODEL_FILENAME: string;
  28689. /**
  28690. * Gamepad Id prefix used to identify this controller.
  28691. */
  28692. static readonly GAMEPAD_ID_PREFIX: string;
  28693. private readonly _buttonIndexToObservableNameMap;
  28694. /**
  28695. * Creates a new GearVRController from a gamepad
  28696. * @param vrGamepad the gamepad that the controller should be created from
  28697. */
  28698. constructor(vrGamepad: any);
  28699. /**
  28700. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  28701. * @param scene scene in which to add meshes
  28702. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  28703. */
  28704. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  28705. /**
  28706. * Called once for each button that changed state since the last frame
  28707. * @param buttonIdx Which button index changed
  28708. * @param state New state of the button
  28709. * @param changes Which properties on the state changed since last frame
  28710. */
  28711. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  28712. }
  28713. }
  28714. declare module BABYLON {
  28715. /**
  28716. * Generic Controller
  28717. */
  28718. class GenericController extends WebVRController {
  28719. /**
  28720. * Base Url for the controller model.
  28721. */
  28722. static readonly MODEL_BASE_URL: string;
  28723. /**
  28724. * File name for the controller model.
  28725. */
  28726. static readonly MODEL_FILENAME: string;
  28727. /**
  28728. * Creates a new GenericController from a gamepad
  28729. * @param vrGamepad the gamepad that the controller should be created from
  28730. */
  28731. constructor(vrGamepad: any);
  28732. /**
  28733. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  28734. * @param scene scene in which to add meshes
  28735. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  28736. */
  28737. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  28738. /**
  28739. * Called once for each button that changed state since the last frame
  28740. * @param buttonIdx Which button index changed
  28741. * @param state New state of the button
  28742. * @param changes Which properties on the state changed since last frame
  28743. */
  28744. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  28745. }
  28746. }
  28747. declare module BABYLON {
  28748. /**
  28749. * Oculus Touch Controller
  28750. */
  28751. class OculusTouchController extends WebVRController {
  28752. /**
  28753. * Base Url for the controller model.
  28754. */
  28755. static MODEL_BASE_URL: string;
  28756. /**
  28757. * File name for the left controller model.
  28758. */
  28759. static MODEL_LEFT_FILENAME: string;
  28760. /**
  28761. * File name for the right controller model.
  28762. */
  28763. static MODEL_RIGHT_FILENAME: string;
  28764. /**
  28765. * Fired when the secondary trigger on this controller is modified
  28766. */
  28767. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  28768. /**
  28769. * Fired when the thumb rest on this controller is modified
  28770. */
  28771. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  28772. /**
  28773. * Creates a new OculusTouchController from a gamepad
  28774. * @param vrGamepad the gamepad that the controller should be created from
  28775. */
  28776. constructor(vrGamepad: any);
  28777. /**
  28778. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  28779. * @param scene scene in which to add meshes
  28780. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  28781. */
  28782. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  28783. /**
  28784. * Fired when the A button on this controller is modified
  28785. */
  28786. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  28787. /**
  28788. * Fired when the B button on this controller is modified
  28789. */
  28790. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  28791. /**
  28792. * Fired when the X button on this controller is modified
  28793. */
  28794. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  28795. /**
  28796. * Fired when the Y button on this controller is modified
  28797. */
  28798. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  28799. /**
  28800. * Called once for each button that changed state since the last frame
  28801. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  28802. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  28803. * 2) secondary trigger (same)
  28804. * 3) A (right) X (left), touch, pressed = value
  28805. * 4) B / Y
  28806. * 5) thumb rest
  28807. * @param buttonIdx Which button index changed
  28808. * @param state New state of the button
  28809. * @param changes Which properties on the state changed since last frame
  28810. */
  28811. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  28812. }
  28813. }
  28814. declare module BABYLON {
  28815. /**
  28816. * Defines the types of pose enabled controllers that are supported
  28817. */
  28818. enum PoseEnabledControllerType {
  28819. /**
  28820. * HTC Vive
  28821. */
  28822. VIVE = 0,
  28823. /**
  28824. * Oculus Rift
  28825. */
  28826. OCULUS = 1,
  28827. /**
  28828. * Windows mixed reality
  28829. */
  28830. WINDOWS = 2,
  28831. /**
  28832. * Samsung gear VR
  28833. */
  28834. GEAR_VR = 3,
  28835. /**
  28836. * Google Daydream
  28837. */
  28838. DAYDREAM = 4,
  28839. /**
  28840. * Generic
  28841. */
  28842. GENERIC = 5,
  28843. }
  28844. /**
  28845. * Defines the MutableGamepadButton interface for the state of a gamepad button
  28846. */
  28847. interface MutableGamepadButton {
  28848. /**
  28849. * Value of the button/trigger
  28850. */
  28851. value: number;
  28852. /**
  28853. * If the button/trigger is currently touched
  28854. */
  28855. touched: boolean;
  28856. /**
  28857. * If the button/trigger is currently pressed
  28858. */
  28859. pressed: boolean;
  28860. }
  28861. /**
  28862. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  28863. * @ignore
  28864. */
  28865. interface ExtendedGamepadButton extends GamepadButton {
  28866. /**
  28867. * If the button/trigger is currently pressed
  28868. */
  28869. readonly pressed: boolean;
  28870. /**
  28871. * If the button/trigger is currently touched
  28872. */
  28873. readonly touched: boolean;
  28874. /**
  28875. * Value of the button/trigger
  28876. */
  28877. readonly value: number;
  28878. }
  28879. /**
  28880. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  28881. */
  28882. class PoseEnabledControllerHelper {
  28883. /**
  28884. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  28885. * @param vrGamepad the gamepad to initialized
  28886. * @returns a vr controller of the type the gamepad identified as
  28887. */
  28888. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  28889. }
  28890. /**
  28891. * Defines the PoseEnabledController object that contains state of a vr capable controller
  28892. */
  28893. class PoseEnabledController extends Gamepad implements PoseControlled {
  28894. private _deviceRoomPosition;
  28895. private _deviceRoomRotationQuaternion;
  28896. /**
  28897. * The device position in babylon space
  28898. */
  28899. devicePosition: Vector3;
  28900. /**
  28901. * The device rotation in babylon space
  28902. */
  28903. deviceRotationQuaternion: Quaternion;
  28904. /**
  28905. * The scale factor of the device in babylon space
  28906. */
  28907. deviceScaleFactor: number;
  28908. /**
  28909. * (Likely devicePosition should be used instead) The device position in its room space
  28910. */
  28911. position: Vector3;
  28912. /**
  28913. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  28914. */
  28915. rotationQuaternion: Quaternion;
  28916. /**
  28917. * The type of controller (Eg. Windows mixed reality)
  28918. */
  28919. controllerType: PoseEnabledControllerType;
  28920. private _calculatedPosition;
  28921. private _calculatedRotation;
  28922. /**
  28923. * The raw pose from the device
  28924. */
  28925. rawPose: DevicePose;
  28926. /**
  28927. * Internal, the mesh attached to the controller
  28928. */
  28929. _mesh: Nullable<AbstractMesh>;
  28930. private _poseControlledCamera;
  28931. private _leftHandSystemQuaternion;
  28932. /**
  28933. * Internal, matrix used to convert room space to babylon space
  28934. */
  28935. _deviceToWorld: Matrix;
  28936. /**
  28937. * Node to be used when casting a ray from the controller
  28938. */
  28939. _pointingPoseNode: Nullable<AbstractMesh>;
  28940. /**
  28941. * Name of the child mesh that can be used to cast a ray from the controller
  28942. */
  28943. static readonly POINTING_POSE: string;
  28944. /**
  28945. * Creates a new PoseEnabledController from a gamepad
  28946. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  28947. */
  28948. constructor(browserGamepad: any);
  28949. private _workingMatrix;
  28950. /**
  28951. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  28952. */
  28953. update(): void;
  28954. /**
  28955. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  28956. * @param poseData raw pose fromthe device
  28957. */
  28958. updateFromDevice(poseData: DevicePose): void;
  28959. /**
  28960. * Attaches a mesh to the controller
  28961. * @param mesh the mesh to be attached
  28962. */
  28963. attachToMesh(mesh: AbstractMesh): void;
  28964. /**
  28965. * Attaches the controllers mesh to a camera
  28966. * @param camera the camera the mesh should be attached to
  28967. */
  28968. attachToPoseControlledCamera(camera: TargetCamera): void;
  28969. /**
  28970. * Disposes of the controller
  28971. */
  28972. dispose(): void;
  28973. /**
  28974. * The mesh that is attached to the controller
  28975. */
  28976. readonly mesh: Nullable<AbstractMesh>;
  28977. /**
  28978. * Gets the ray of the controller in the direction the controller is pointing
  28979. * @param length the length the resulting ray should be
  28980. * @returns a ray in the direction the controller is pointing
  28981. */
  28982. getForwardRay(length?: number): Ray;
  28983. }
  28984. }
  28985. declare module BABYLON {
  28986. /**
  28987. * Vive Controller
  28988. */
  28989. class ViveController extends WebVRController {
  28990. /**
  28991. * Base Url for the controller model.
  28992. */
  28993. static MODEL_BASE_URL: string;
  28994. /**
  28995. * File name for the controller model.
  28996. */
  28997. static MODEL_FILENAME: string;
  28998. /**
  28999. * Creates a new ViveController from a gamepad
  29000. * @param vrGamepad the gamepad that the controller should be created from
  29001. */
  29002. constructor(vrGamepad: any);
  29003. /**
  29004. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  29005. * @param scene scene in which to add meshes
  29006. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  29007. */
  29008. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  29009. /**
  29010. * Fired when the left button on this controller is modified
  29011. */
  29012. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  29013. /**
  29014. * Fired when the right button on this controller is modified
  29015. */
  29016. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  29017. /**
  29018. * Fired when the menu button on this controller is modified
  29019. */
  29020. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  29021. /**
  29022. * Called once for each button that changed state since the last frame
  29023. * Vive mapping:
  29024. * 0: touchpad
  29025. * 1: trigger
  29026. * 2: left AND right buttons
  29027. * 3: menu button
  29028. * @param buttonIdx Which button index changed
  29029. * @param state New state of the button
  29030. * @param changes Which properties on the state changed since last frame
  29031. */
  29032. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  29033. }
  29034. }
  29035. declare module BABYLON {
  29036. /**
  29037. * Defines the WebVRController object that represents controllers tracked in 3D space
  29038. */
  29039. abstract class WebVRController extends PoseEnabledController {
  29040. /**
  29041. * Internal, the default controller model for the controller
  29042. */
  29043. protected _defaultModel: AbstractMesh;
  29044. /**
  29045. * Fired when the trigger state has changed
  29046. */
  29047. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  29048. /**
  29049. * Fired when the main button state has changed
  29050. */
  29051. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  29052. /**
  29053. * Fired when the secondary button state has changed
  29054. */
  29055. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  29056. /**
  29057. * Fired when the pad state has changed
  29058. */
  29059. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  29060. /**
  29061. * Fired when controllers stick values have changed
  29062. */
  29063. onPadValuesChangedObservable: Observable<StickValues>;
  29064. /**
  29065. * Array of button availible on the controller
  29066. */
  29067. protected _buttons: Array<MutableGamepadButton>;
  29068. private _onButtonStateChange;
  29069. /**
  29070. * Fired when a controller button's state has changed
  29071. * @param callback the callback containing the button that was modified
  29072. */
  29073. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  29074. /**
  29075. * X and Y axis corrisponding to the controllers joystick
  29076. */
  29077. pad: StickValues;
  29078. /**
  29079. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  29080. */
  29081. hand: string;
  29082. /**
  29083. * The default controller model for the controller
  29084. */
  29085. readonly defaultModel: AbstractMesh;
  29086. /**
  29087. * Creates a new WebVRController from a gamepad
  29088. * @param vrGamepad the gamepad that the WebVRController should be created from
  29089. */
  29090. constructor(vrGamepad: any);
  29091. /**
  29092. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  29093. */
  29094. update(): void;
  29095. /**
  29096. * Function to be called when a button is modified
  29097. */
  29098. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  29099. /**
  29100. * Loads a mesh and attaches it to the controller
  29101. * @param scene the scene the mesh should be added to
  29102. * @param meshLoaded callback for when the mesh has been loaded
  29103. */
  29104. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  29105. private _setButtonValue(newState, currentState, buttonIndex);
  29106. private _changes;
  29107. private _checkChanges(newState, currentState);
  29108. /**
  29109. * Disposes of th webVRCOntroller
  29110. */
  29111. dispose(): void;
  29112. }
  29113. }
  29114. declare module BABYLON {
  29115. /**
  29116. * Defines the WindowsMotionController object that the state of the windows motion controller
  29117. */
  29118. class WindowsMotionController extends WebVRController {
  29119. /**
  29120. * The base url used to load the left and right controller models
  29121. */
  29122. static MODEL_BASE_URL: string;
  29123. /**
  29124. * The name of the left controller model file
  29125. */
  29126. static MODEL_LEFT_FILENAME: string;
  29127. /**
  29128. * The name of the right controller model file
  29129. */
  29130. static MODEL_RIGHT_FILENAME: string;
  29131. /**
  29132. * The controller name prefix for this controller type
  29133. */
  29134. static readonly GAMEPAD_ID_PREFIX: string;
  29135. /**
  29136. * The controller id pattern for this controller type
  29137. */
  29138. private static readonly GAMEPAD_ID_PATTERN;
  29139. private _loadedMeshInfo;
  29140. private readonly _mapping;
  29141. /**
  29142. * Fired when the trackpad on this controller is clicked
  29143. */
  29144. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  29145. /**
  29146. * Fired when the trackpad on this controller is modified
  29147. */
  29148. onTrackpadValuesChangedObservable: Observable<StickValues>;
  29149. /**
  29150. * The current x and y values of this controller's trackpad
  29151. */
  29152. trackpad: StickValues;
  29153. /**
  29154. * Creates a new WindowsMotionController from a gamepad
  29155. * @param vrGamepad the gamepad that the controller should be created from
  29156. */
  29157. constructor(vrGamepad: any);
  29158. /**
  29159. * Fired when the trigger on this controller is modified
  29160. */
  29161. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  29162. /**
  29163. * Fired when the menu button on this controller is modified
  29164. */
  29165. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  29166. /**
  29167. * Fired when the grip button on this controller is modified
  29168. */
  29169. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  29170. /**
  29171. * Fired when the thumbstick button on this controller is modified
  29172. */
  29173. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  29174. /**
  29175. * Fired when the touchpad button on this controller is modified
  29176. */
  29177. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  29178. /**
  29179. * Fired when the touchpad values on this controller are modified
  29180. */
  29181. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  29182. /**
  29183. * Called once per frame by the engine.
  29184. */
  29185. update(): void;
  29186. /**
  29187. * Called once for each button that changed state since the last frame
  29188. * @param buttonIdx Which button index changed
  29189. * @param state New state of the button
  29190. * @param changes Which properties on the state changed since last frame
  29191. */
  29192. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  29193. /**
  29194. * Moves the buttons on the controller mesh based on their current state
  29195. * @param buttonName the name of the button to move
  29196. * @param buttonValue the value of the button which determines the buttons new position
  29197. */
  29198. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  29199. /**
  29200. * Moves the axis on the controller mesh based on its current state
  29201. * @param axis the index of the axis
  29202. * @param axisValue the value of the axis which determines the meshes new position
  29203. * @ignore
  29204. */
  29205. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  29206. /**
  29207. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  29208. * @param scene scene in which to add meshes
  29209. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  29210. */
  29211. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  29212. /**
  29213. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  29214. * can be transformed by button presses and axes values, based on this._mapping.
  29215. *
  29216. * @param scene scene in which the meshes exist
  29217. * @param meshes list of meshes that make up the controller model to process
  29218. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  29219. */
  29220. private processModel(scene, meshes);
  29221. private createMeshInfo(rootNode);
  29222. /**
  29223. * Gets the ray of the controller in the direction the controller is pointing
  29224. * @param length the length the resulting ray should be
  29225. * @returns a ray in the direction the controller is pointing
  29226. */
  29227. getForwardRay(length?: number): Ray;
  29228. /**
  29229. * Disposes of the controller
  29230. */
  29231. dispose(): void;
  29232. }
  29233. }
  29234. declare module BABYLON {
  29235. }
  29236. declare module BABYLON {
  29237. /**
  29238. * Interface to implement to create a shadow generator compatible with BJS.
  29239. */
  29240. interface IShadowGenerator {
  29241. /**
  29242. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29243. * @returns The render target texture if present otherwise, null
  29244. */
  29245. getShadowMap(): Nullable<RenderTargetTexture>;
  29246. /**
  29247. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  29248. * @returns The render target texture if the shadow map is present otherwise, null
  29249. */
  29250. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  29251. /**
  29252. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29253. * @param subMesh The submesh we want to render in the shadow map
  29254. * @param useInstances Defines wether will draw in the map using instances
  29255. * @returns true if ready otherwise, false
  29256. */
  29257. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  29258. /**
  29259. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29260. * @param defines Defines of the material we want to update
  29261. * @param lightIndex Index of the light in the enabled light list of the material
  29262. */
  29263. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29264. /**
  29265. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29266. * defined in the generator but impacting the effect).
  29267. * It implies the unifroms available on the materials are the standard BJS ones.
  29268. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29269. * @param effect The effect we are binfing the information for
  29270. */
  29271. bindShadowLight(lightIndex: string, effect: Effect): void;
  29272. /**
  29273. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29274. * (eq to shadow prjection matrix * light transform matrix)
  29275. * @returns The transform matrix used to create the shadow map
  29276. */
  29277. getTransformMatrix(): Matrix;
  29278. /**
  29279. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29280. * Cube and 2D textures for instance.
  29281. */
  29282. recreateShadowMap(): void;
  29283. /**
  29284. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29285. * @param onCompiled Callback triggered at the and of the effects compilation
  29286. * @param options Sets of optional options forcing the compilation with different modes
  29287. */
  29288. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  29289. useInstances: boolean;
  29290. }>): void;
  29291. /**
  29292. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29293. * @param options Sets of optional options forcing the compilation with different modes
  29294. * @returns A promise that resolves when the compilation completes
  29295. */
  29296. forceCompilationAsync(options?: Partial<{
  29297. useInstances: boolean;
  29298. }>): Promise<void>;
  29299. /**
  29300. * Serializes the shadow generator setup to a json object.
  29301. * @returns The serialized JSON object
  29302. */
  29303. serialize(): any;
  29304. /**
  29305. * Disposes the Shadow map and related Textures and effects.
  29306. */
  29307. dispose(): void;
  29308. }
  29309. /**
  29310. * Default implementation IShadowGenerator.
  29311. * This is the main object responsible of generating shadows in the framework.
  29312. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29313. */
  29314. class ShadowGenerator implements IShadowGenerator {
  29315. /**
  29316. * Shadow generator mode None: no filtering applied.
  29317. */
  29318. static readonly FILTER_NONE: number;
  29319. /**
  29320. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29321. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29322. */
  29323. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29324. /**
  29325. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29326. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29327. */
  29328. static readonly FILTER_POISSONSAMPLING: number;
  29329. /**
  29330. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29331. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29332. */
  29333. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29334. /**
  29335. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29336. * edge artifacts on steep falloff.
  29337. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29338. */
  29339. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29340. /**
  29341. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29342. * edge artifacts on steep falloff.
  29343. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29344. */
  29345. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29346. /**
  29347. * Shadow generator mode PCF: Percentage Closer Filtering
  29348. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29349. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29350. */
  29351. static readonly FILTER_PCF: number;
  29352. /**
  29353. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29354. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29355. * Contact Hardening
  29356. */
  29357. static readonly FILTER_PCSS: number;
  29358. /**
  29359. * Reserved for PCF and PCSS
  29360. * Highest Quality.
  29361. *
  29362. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29363. *
  29364. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29365. */
  29366. static readonly QUALITY_HIGH: number;
  29367. /**
  29368. * Reserved for PCF and PCSS
  29369. * Good tradeoff for quality/perf cross devices
  29370. *
  29371. * Execute PCF on a 3*3 kernel.
  29372. *
  29373. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29374. */
  29375. static readonly QUALITY_MEDIUM: number;
  29376. /**
  29377. * Reserved for PCF and PCSS
  29378. * The lowest quality but the fastest.
  29379. *
  29380. * Execute PCF on a 1*1 kernel.
  29381. *
  29382. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  29383. */
  29384. static readonly QUALITY_LOW: number;
  29385. private _bias;
  29386. /**
  29387. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  29388. */
  29389. /**
  29390. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  29391. */
  29392. bias: number;
  29393. private _normalBias;
  29394. /**
  29395. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29396. */
  29397. /**
  29398. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29399. */
  29400. normalBias: number;
  29401. private _blurBoxOffset;
  29402. /**
  29403. * Gets the blur box offset: offset applied during the blur pass.
  29404. * Only usefull if useKernelBlur = false
  29405. */
  29406. /**
  29407. * Sets the blur box offset: offset applied during the blur pass.
  29408. * Only usefull if useKernelBlur = false
  29409. */
  29410. blurBoxOffset: number;
  29411. private _blurScale;
  29412. /**
  29413. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  29414. * 2 means half of the size.
  29415. */
  29416. /**
  29417. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  29418. * 2 means half of the size.
  29419. */
  29420. blurScale: number;
  29421. private _blurKernel;
  29422. /**
  29423. * Gets the blur kernel: kernel size of the blur pass.
  29424. * Only usefull if useKernelBlur = true
  29425. */
  29426. /**
  29427. * Sets the blur kernel: kernel size of the blur pass.
  29428. * Only usefull if useKernelBlur = true
  29429. */
  29430. blurKernel: number;
  29431. private _useKernelBlur;
  29432. /**
  29433. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  29434. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  29435. */
  29436. /**
  29437. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  29438. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  29439. */
  29440. useKernelBlur: boolean;
  29441. private _depthScale;
  29442. /**
  29443. * Gets the depth scale used in ESM mode.
  29444. */
  29445. /**
  29446. * Sets the depth scale used in ESM mode.
  29447. * This can override the scale stored on the light.
  29448. */
  29449. depthScale: number;
  29450. private _filter;
  29451. /**
  29452. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  29453. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29454. */
  29455. /**
  29456. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  29457. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29458. */
  29459. filter: number;
  29460. /**
  29461. * Gets if the current filter is set to Poisson Sampling.
  29462. */
  29463. /**
  29464. * Sets the current filter to Poisson Sampling.
  29465. */
  29466. usePoissonSampling: boolean;
  29467. /**
  29468. * Gets if the current filter is set to VSM.
  29469. * DEPRECATED. Should use useExponentialShadowMap instead.
  29470. */
  29471. /**
  29472. * Sets the current filter is to VSM.
  29473. * DEPRECATED. Should use useExponentialShadowMap instead.
  29474. */
  29475. useVarianceShadowMap: boolean;
  29476. /**
  29477. * Gets if the current filter is set to blurred VSM.
  29478. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  29479. */
  29480. /**
  29481. * Sets the current filter is to blurred VSM.
  29482. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  29483. */
  29484. useBlurVarianceShadowMap: boolean;
  29485. /**
  29486. * Gets if the current filter is set to ESM.
  29487. */
  29488. /**
  29489. * Sets the current filter is to ESM.
  29490. */
  29491. useExponentialShadowMap: boolean;
  29492. /**
  29493. * Gets if the current filter is set to filtered ESM.
  29494. */
  29495. /**
  29496. * Gets if the current filter is set to filtered ESM.
  29497. */
  29498. useBlurExponentialShadowMap: boolean;
  29499. /**
  29500. * Gets if the current filter is set to "close ESM" (using the inverse of the
  29501. * exponential to prevent steep falloff artifacts).
  29502. */
  29503. /**
  29504. * Sets the current filter to "close ESM" (using the inverse of the
  29505. * exponential to prevent steep falloff artifacts).
  29506. */
  29507. useCloseExponentialShadowMap: boolean;
  29508. /**
  29509. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  29510. * exponential to prevent steep falloff artifacts).
  29511. */
  29512. /**
  29513. * Sets the current filter to filtered "close ESM" (using the inverse of the
  29514. * exponential to prevent steep falloff artifacts).
  29515. */
  29516. useBlurCloseExponentialShadowMap: boolean;
  29517. /**
  29518. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  29519. */
  29520. /**
  29521. * Sets the current filter to "PCF" (percentage closer filtering).
  29522. */
  29523. usePercentageCloserFiltering: boolean;
  29524. private _filteringQuality;
  29525. /**
  29526. * Gets the PCF or PCSS Quality.
  29527. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29528. */
  29529. /**
  29530. * Sets the PCF or PCSS Quality.
  29531. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29532. */
  29533. filteringQuality: number;
  29534. /**
  29535. * Gets if the current filter is set to "PCSS" (contact hardening).
  29536. */
  29537. /**
  29538. * Sets the current filter to "PCSS" (contact hardening).
  29539. */
  29540. useContactHardeningShadow: boolean;
  29541. private _contactHardeningLightSizeUVRatio;
  29542. /**
  29543. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29544. * Using a ratio helps keeping shape stability independently of the map size.
  29545. *
  29546. * It does not account for the light projection as it was having too much
  29547. * instability during the light setup or during light position changes.
  29548. *
  29549. * Only valid if useContactHardeningShadow is true.
  29550. */
  29551. /**
  29552. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29553. * Using a ratio helps keeping shape stability independently of the map size.
  29554. *
  29555. * It does not account for the light projection as it was having too much
  29556. * instability during the light setup or during light position changes.
  29557. *
  29558. * Only valid if useContactHardeningShadow is true.
  29559. */
  29560. contactHardeningLightSizeUVRatio: number;
  29561. private _darkness;
  29562. /**
  29563. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  29564. * 0 means strongest and 1 would means no shadow.
  29565. * @returns the darkness.
  29566. */
  29567. getDarkness(): number;
  29568. /**
  29569. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  29570. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  29571. * @returns the shadow generator allowing fluent coding.
  29572. */
  29573. setDarkness(darkness: number): ShadowGenerator;
  29574. private _transparencyShadow;
  29575. /**
  29576. * Sets the ability to have transparent shadow (boolean).
  29577. * @param transparent True if transparent else False
  29578. * @returns the shadow generator allowing fluent coding
  29579. */
  29580. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  29581. private _shadowMap;
  29582. private _shadowMap2;
  29583. /**
  29584. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29585. * @returns The render target texture if present otherwise, null
  29586. */
  29587. getShadowMap(): Nullable<RenderTargetTexture>;
  29588. /**
  29589. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  29590. * @returns The render target texture if the shadow map is present otherwise, null
  29591. */
  29592. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  29593. /**
  29594. * Helper function to add a mesh and its descendants to the list of shadow casters.
  29595. * @param mesh Mesh to add
  29596. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  29597. * @returns the Shadow Generator itself
  29598. */
  29599. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29600. /**
  29601. * Helper function to remove a mesh and its descendants from the list of shadow casters
  29602. * @param mesh Mesh to remove
  29603. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  29604. * @returns the Shadow Generator itself
  29605. */
  29606. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29607. /**
  29608. * Controls the extent to which the shadows fade out at the edge of the frustum
  29609. * Used only by directionals and spots
  29610. */
  29611. frustumEdgeFalloff: number;
  29612. private _light;
  29613. /**
  29614. * Returns the associated light object.
  29615. * @returns the light generating the shadow
  29616. */
  29617. getLight(): IShadowLight;
  29618. /**
  29619. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  29620. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  29621. * It might on the other hand introduce peter panning.
  29622. */
  29623. forceBackFacesOnly: boolean;
  29624. private _scene;
  29625. private _lightDirection;
  29626. private _effect;
  29627. private _viewMatrix;
  29628. private _projectionMatrix;
  29629. private _transformMatrix;
  29630. private _cachedPosition;
  29631. private _cachedDirection;
  29632. private _cachedDefines;
  29633. private _currentRenderID;
  29634. private _boxBlurPostprocess;
  29635. private _kernelBlurXPostprocess;
  29636. private _kernelBlurYPostprocess;
  29637. private _blurPostProcesses;
  29638. private _mapSize;
  29639. private _currentFaceIndex;
  29640. private _currentFaceIndexCache;
  29641. private _textureType;
  29642. private _defaultTextureMatrix;
  29643. /**
  29644. * Creates a ShadowGenerator object.
  29645. * A ShadowGenerator is the required tool to use the shadows.
  29646. * Each light casting shadows needs to use its own ShadowGenerator.
  29647. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  29648. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  29649. * @param light The light object generating the shadows.
  29650. * @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.
  29651. */
  29652. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  29653. private _initializeGenerator();
  29654. private _initializeShadowMap();
  29655. private _initializeBlurRTTAndPostProcesses();
  29656. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  29657. private _renderSubMeshForShadowMap(subMesh);
  29658. private _applyFilterValues();
  29659. /**
  29660. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29661. * @param onCompiled Callback triggered at the and of the effects compilation
  29662. * @param options Sets of optional options forcing the compilation with different modes
  29663. */
  29664. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  29665. useInstances: boolean;
  29666. }>): void;
  29667. /**
  29668. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29669. * @param options Sets of optional options forcing the compilation with different modes
  29670. * @returns A promise that resolves when the compilation completes
  29671. */
  29672. forceCompilationAsync(options?: Partial<{
  29673. useInstances: boolean;
  29674. }>): Promise<void>;
  29675. /**
  29676. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29677. * @param subMesh The submesh we want to render in the shadow map
  29678. * @param useInstances Defines wether will draw in the map using instances
  29679. * @returns true if ready otherwise, false
  29680. */
  29681. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  29682. /**
  29683. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29684. * @param defines Defines of the material we want to update
  29685. * @param lightIndex Index of the light in the enabled light list of the material
  29686. */
  29687. prepareDefines(defines: any, lightIndex: number): void;
  29688. /**
  29689. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29690. * defined in the generator but impacting the effect).
  29691. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29692. * @param effect The effect we are binfing the information for
  29693. */
  29694. bindShadowLight(lightIndex: string, effect: Effect): void;
  29695. /**
  29696. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29697. * (eq to shadow prjection matrix * light transform matrix)
  29698. * @returns The transform matrix used to create the shadow map
  29699. */
  29700. getTransformMatrix(): Matrix;
  29701. /**
  29702. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29703. * Cube and 2D textures for instance.
  29704. */
  29705. recreateShadowMap(): void;
  29706. private _disposeBlurPostProcesses();
  29707. private _disposeRTTandPostProcesses();
  29708. /**
  29709. * Disposes the ShadowGenerator.
  29710. * Returns nothing.
  29711. */
  29712. dispose(): void;
  29713. /**
  29714. * Serializes the shadow generator setup to a json object.
  29715. * @returns The serialized JSON object
  29716. */
  29717. serialize(): any;
  29718. /**
  29719. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  29720. * @param parsedShadowGenerator The JSON object to parse
  29721. * @param scene The scene to create the shadow map for
  29722. * @returns The parsed shadow generator
  29723. */
  29724. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  29725. }
  29726. }
  29727. declare module BABYLON {
  29728. /**
  29729. * Background material used to create an efficient environement around your scene.
  29730. */
  29731. class BackgroundMaterial extends PushMaterial {
  29732. /**
  29733. * Standard reflectance value at parallel view angle.
  29734. */
  29735. static StandardReflectance0: number;
  29736. /**
  29737. * Standard reflectance value at grazing angle.
  29738. */
  29739. static StandardReflectance90: number;
  29740. protected _primaryColor: Color3;
  29741. /**
  29742. * Key light Color (multiply against the environement texture)
  29743. */
  29744. primaryColor: Color3;
  29745. protected _perceptualColor: Nullable<Color3>;
  29746. /**
  29747. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  29748. * This acts as a helper to set the primary color to a more "human friendly" value.
  29749. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  29750. * output color as close as possible from the chosen value.
  29751. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  29752. * part of lighting setup.)
  29753. */
  29754. perceptualColor: Nullable<Color3>;
  29755. protected _primaryColorShadowLevel: float;
  29756. /**
  29757. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  29758. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  29759. */
  29760. primaryColorShadowLevel: float;
  29761. protected _primaryColorHighlightLevel: float;
  29762. /**
  29763. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  29764. * The primary color is used at the level chosen to define what the white area would look.
  29765. */
  29766. primaryColorHighlightLevel: float;
  29767. protected _reflectionTexture: Nullable<BaseTexture>;
  29768. /**
  29769. * Reflection Texture used in the material.
  29770. * Should be author in a specific way for the best result (refer to the documentation).
  29771. */
  29772. reflectionTexture: Nullable<BaseTexture>;
  29773. protected _reflectionBlur: float;
  29774. /**
  29775. * Reflection Texture level of blur.
  29776. *
  29777. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  29778. * texture twice.
  29779. */
  29780. reflectionBlur: float;
  29781. protected _diffuseTexture: Nullable<BaseTexture>;
  29782. /**
  29783. * Diffuse Texture used in the material.
  29784. * Should be author in a specific way for the best result (refer to the documentation).
  29785. */
  29786. diffuseTexture: Nullable<BaseTexture>;
  29787. protected _shadowLights: Nullable<IShadowLight[]>;
  29788. /**
  29789. * Specify the list of lights casting shadow on the material.
  29790. * All scene shadow lights will be included if null.
  29791. */
  29792. shadowLights: Nullable<IShadowLight[]>;
  29793. protected _shadowLevel: float;
  29794. /**
  29795. * Helps adjusting the shadow to a softer level if required.
  29796. * 0 means black shadows and 1 means no shadows.
  29797. */
  29798. shadowLevel: float;
  29799. protected _sceneCenter: Vector3;
  29800. /**
  29801. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  29802. * It is usually zero but might be interesting to modify according to your setup.
  29803. */
  29804. sceneCenter: Vector3;
  29805. protected _opacityFresnel: boolean;
  29806. /**
  29807. * This helps specifying that the material is falling off to the sky box at grazing angle.
  29808. * This helps ensuring a nice transition when the camera goes under the ground.
  29809. */
  29810. opacityFresnel: boolean;
  29811. protected _reflectionFresnel: boolean;
  29812. /**
  29813. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  29814. * This helps adding a mirror texture on the ground.
  29815. */
  29816. reflectionFresnel: boolean;
  29817. protected _reflectionFalloffDistance: number;
  29818. /**
  29819. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  29820. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  29821. */
  29822. reflectionFalloffDistance: number;
  29823. protected _reflectionAmount: number;
  29824. /**
  29825. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  29826. */
  29827. reflectionAmount: number;
  29828. protected _reflectionReflectance0: number;
  29829. /**
  29830. * This specifies the weight of the reflection at grazing angle.
  29831. */
  29832. reflectionReflectance0: number;
  29833. protected _reflectionReflectance90: number;
  29834. /**
  29835. * This specifies the weight of the reflection at a perpendicular point of view.
  29836. */
  29837. reflectionReflectance90: number;
  29838. /**
  29839. * Sets the reflection reflectance fresnel values according to the default standard
  29840. * empirically know to work well :-)
  29841. */
  29842. reflectionStandardFresnelWeight: number;
  29843. protected _useRGBColor: boolean;
  29844. /**
  29845. * Helps to directly use the maps channels instead of their level.
  29846. */
  29847. useRGBColor: boolean;
  29848. protected _enableNoise: boolean;
  29849. /**
  29850. * This helps reducing the banding effect that could occur on the background.
  29851. */
  29852. enableNoise: boolean;
  29853. /**
  29854. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  29855. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  29856. * Recommended to be keep at 1.0 except for special cases.
  29857. */
  29858. fovMultiplier: number;
  29859. private _fovMultiplier;
  29860. /**
  29861. * Enable the FOV adjustment feature controlled by fovMultiplier.
  29862. */
  29863. useEquirectangularFOV: boolean;
  29864. private _maxSimultaneousLights;
  29865. /**
  29866. * Number of Simultaneous lights allowed on the material.
  29867. */
  29868. maxSimultaneousLights: int;
  29869. /**
  29870. * Default configuration related to image processing available in the Background Material.
  29871. */
  29872. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29873. /**
  29874. * Keep track of the image processing observer to allow dispose and replace.
  29875. */
  29876. private _imageProcessingObserver;
  29877. /**
  29878. * Attaches a new image processing configuration to the PBR Material.
  29879. * @param configuration (if null the scene configuration will be use)
  29880. */
  29881. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29882. /**
  29883. * Gets the image processing configuration used either in this material.
  29884. */
  29885. /**
  29886. * Sets the Default image processing configuration used either in the this material.
  29887. *
  29888. * If sets to null, the scene one is in use.
  29889. */
  29890. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  29891. /**
  29892. * Gets wether the color curves effect is enabled.
  29893. */
  29894. /**
  29895. * Sets wether the color curves effect is enabled.
  29896. */
  29897. cameraColorCurvesEnabled: boolean;
  29898. /**
  29899. * Gets wether the color grading effect is enabled.
  29900. */
  29901. /**
  29902. * Gets wether the color grading effect is enabled.
  29903. */
  29904. cameraColorGradingEnabled: boolean;
  29905. /**
  29906. * Gets wether tonemapping is enabled or not.
  29907. */
  29908. /**
  29909. * Sets wether tonemapping is enabled or not
  29910. */
  29911. cameraToneMappingEnabled: boolean;
  29912. /**
  29913. * The camera exposure used on this material.
  29914. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29915. * This corresponds to a photographic exposure.
  29916. */
  29917. /**
  29918. * The camera exposure used on this material.
  29919. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29920. * This corresponds to a photographic exposure.
  29921. */
  29922. cameraExposure: float;
  29923. /**
  29924. * Gets The camera contrast used on this material.
  29925. */
  29926. /**
  29927. * Sets The camera contrast used on this material.
  29928. */
  29929. cameraContrast: float;
  29930. /**
  29931. * Gets the Color Grading 2D Lookup Texture.
  29932. */
  29933. /**
  29934. * Sets the Color Grading 2D Lookup Texture.
  29935. */
  29936. cameraColorGradingTexture: Nullable<BaseTexture>;
  29937. /**
  29938. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29939. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29940. * 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;
  29941. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29942. */
  29943. /**
  29944. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29945. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29946. * 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;
  29947. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29948. */
  29949. cameraColorCurves: Nullable<ColorCurves>;
  29950. /**
  29951. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  29952. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  29953. */
  29954. switchToBGR: boolean;
  29955. private _renderTargets;
  29956. private _reflectionControls;
  29957. private _white;
  29958. private _primaryShadowColor;
  29959. private _primaryHighlightColor;
  29960. /**
  29961. * Instantiates a Background Material in the given scene
  29962. * @param name The friendly name of the material
  29963. * @param scene The scene to add the material to
  29964. */
  29965. constructor(name: string, scene: Scene);
  29966. /**
  29967. * The entire material has been created in order to prevent overdraw.
  29968. * @returns false
  29969. */
  29970. needAlphaTesting(): boolean;
  29971. /**
  29972. * The entire material has been created in order to prevent overdraw.
  29973. * @returns true if blending is enable
  29974. */
  29975. needAlphaBlending(): boolean;
  29976. /**
  29977. * Checks wether the material is ready to be rendered for a given mesh.
  29978. * @param mesh The mesh to render
  29979. * @param subMesh The submesh to check against
  29980. * @param useInstances Specify wether or not the material is used with instances
  29981. * @returns true if all the dependencies are ready (Textures, Effects...)
  29982. */
  29983. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29984. /**
  29985. * Tone Mapping calibration (should match image processing tone mapping calibration value).
  29986. */
  29987. private static readonly _tonemappingCalibration;
  29988. /**
  29989. * Compute the primary color according to the chosen perceptual color.
  29990. */
  29991. private _computePrimaryColorFromPerceptualColor();
  29992. /**
  29993. * Compute the highlights and shadow colors according to their chosen levels.
  29994. */
  29995. private _computePrimaryColors();
  29996. /**
  29997. * Build the uniform buffer used in the material.
  29998. */
  29999. buildUniformLayout(): void;
  30000. /**
  30001. * Unbind the material.
  30002. */
  30003. unbind(): void;
  30004. /**
  30005. * Bind only the world matrix to the material.
  30006. * @param world The world matrix to bind.
  30007. */
  30008. bindOnlyWorldMatrix(world: Matrix): void;
  30009. /**
  30010. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  30011. * @param world The world matrix to bind.
  30012. * @param subMesh The submesh to bind for.
  30013. */
  30014. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30015. /**
  30016. * Dispose the material.
  30017. * @param forceDisposeEffect Force disposal of the associated effect.
  30018. * @param forceDisposeTextures Force disposal of the associated textures.
  30019. */
  30020. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30021. /**
  30022. * Clones the material.
  30023. * @param name The cloned name.
  30024. * @returns The cloned material.
  30025. */
  30026. clone(name: string): BackgroundMaterial;
  30027. /**
  30028. * Serializes the current material to its JSON representation.
  30029. * @returns The JSON representation.
  30030. */
  30031. serialize(): any;
  30032. /**
  30033. * Gets the class name of the material
  30034. * @returns "BackgroundMaterial"
  30035. */
  30036. getClassName(): string;
  30037. /**
  30038. * Parse a JSON input to create back a background material.
  30039. * @param source The JSON data to parse
  30040. * @param scene The scene to create the parsed material in
  30041. * @param rootUrl The root url of the assets the material depends upon
  30042. * @returns the instantiated BackgroundMaterial.
  30043. */
  30044. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  30045. }
  30046. }
  30047. declare module BABYLON {
  30048. /**
  30049. * The Physically based material base class of BJS.
  30050. *
  30051. * This offers the main features of a standard PBR material.
  30052. * For more information, please refer to the documentation :
  30053. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  30054. */
  30055. abstract class PBRBaseMaterial extends PushMaterial {
  30056. /**
  30057. * Intensity of the direct lights e.g. the four lights available in your scene.
  30058. * This impacts both the direct diffuse and specular highlights.
  30059. */
  30060. protected _directIntensity: number;
  30061. /**
  30062. * Intensity of the emissive part of the material.
  30063. * This helps controlling the emissive effect without modifying the emissive color.
  30064. */
  30065. protected _emissiveIntensity: number;
  30066. /**
  30067. * Intensity of the environment e.g. how much the environment will light the object
  30068. * either through harmonics for rough material or through the refelction for shiny ones.
  30069. */
  30070. protected _environmentIntensity: number;
  30071. /**
  30072. * This is a special control allowing the reduction of the specular highlights coming from the
  30073. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  30074. */
  30075. protected _specularIntensity: number;
  30076. /**
  30077. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  30078. */
  30079. private _lightingInfos;
  30080. /**
  30081. * Debug Control allowing disabling the bump map on this material.
  30082. */
  30083. protected _disableBumpMap: boolean;
  30084. /**
  30085. * AKA Diffuse Texture in standard nomenclature.
  30086. */
  30087. protected _albedoTexture: BaseTexture;
  30088. /**
  30089. * AKA Occlusion Texture in other nomenclature.
  30090. */
  30091. protected _ambientTexture: BaseTexture;
  30092. /**
  30093. * AKA Occlusion Texture Intensity in other nomenclature.
  30094. */
  30095. protected _ambientTextureStrength: number;
  30096. /**
  30097. * Stores the alpha values in a texture.
  30098. */
  30099. protected _opacityTexture: BaseTexture;
  30100. /**
  30101. * Stores the reflection values in a texture.
  30102. */
  30103. protected _reflectionTexture: BaseTexture;
  30104. /**
  30105. * Stores the refraction values in a texture.
  30106. */
  30107. protected _refractionTexture: BaseTexture;
  30108. /**
  30109. * Stores the emissive values in a texture.
  30110. */
  30111. protected _emissiveTexture: BaseTexture;
  30112. /**
  30113. * AKA Specular texture in other nomenclature.
  30114. */
  30115. protected _reflectivityTexture: BaseTexture;
  30116. /**
  30117. * Used to switch from specular/glossiness to metallic/roughness workflow.
  30118. */
  30119. protected _metallicTexture: BaseTexture;
  30120. /**
  30121. * Specifies the metallic scalar of the metallic/roughness workflow.
  30122. * Can also be used to scale the metalness values of the metallic texture.
  30123. */
  30124. protected _metallic: number;
  30125. /**
  30126. * Specifies the roughness scalar of the metallic/roughness workflow.
  30127. * Can also be used to scale the roughness values of the metallic texture.
  30128. */
  30129. protected _roughness: number;
  30130. /**
  30131. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  30132. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  30133. */
  30134. protected _microSurfaceTexture: BaseTexture;
  30135. /**
  30136. * Stores surface normal data used to displace a mesh in a texture.
  30137. */
  30138. protected _bumpTexture: BaseTexture;
  30139. /**
  30140. * Stores the pre-calculated light information of a mesh in a texture.
  30141. */
  30142. protected _lightmapTexture: BaseTexture;
  30143. /**
  30144. * The color of a material in ambient lighting.
  30145. */
  30146. protected _ambientColor: Color3;
  30147. /**
  30148. * AKA Diffuse Color in other nomenclature.
  30149. */
  30150. protected _albedoColor: Color3;
  30151. /**
  30152. * AKA Specular Color in other nomenclature.
  30153. */
  30154. protected _reflectivityColor: Color3;
  30155. /**
  30156. * The color applied when light is reflected from a material.
  30157. */
  30158. protected _reflectionColor: Color3;
  30159. /**
  30160. * The color applied when light is emitted from a material.
  30161. */
  30162. protected _emissiveColor: Color3;
  30163. /**
  30164. * AKA Glossiness in other nomenclature.
  30165. */
  30166. protected _microSurface: number;
  30167. /**
  30168. * source material index of refraction (IOR)' / 'destination material IOR.
  30169. */
  30170. protected _indexOfRefraction: number;
  30171. /**
  30172. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  30173. */
  30174. protected _invertRefractionY: boolean;
  30175. /**
  30176. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  30177. * Materials half opaque for instance using refraction could benefit from this control.
  30178. */
  30179. protected _linkRefractionWithTransparency: boolean;
  30180. /**
  30181. * Specifies that the material will use the light map as a show map.
  30182. */
  30183. protected _useLightmapAsShadowmap: boolean;
  30184. /**
  30185. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  30186. * makes the reflect vector face the model (under horizon).
  30187. */
  30188. protected _useHorizonOcclusion: boolean;
  30189. /**
  30190. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  30191. * too much the area relying on ambient texture to define their ambient occlusion.
  30192. */
  30193. protected _useRadianceOcclusion: boolean;
  30194. /**
  30195. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  30196. */
  30197. protected _useAlphaFromAlbedoTexture: boolean;
  30198. /**
  30199. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  30200. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30201. */
  30202. protected _useSpecularOverAlpha: boolean;
  30203. /**
  30204. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  30205. */
  30206. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  30207. /**
  30208. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  30209. */
  30210. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  30211. /**
  30212. * Specifies if the metallic texture contains the roughness information in its green channel.
  30213. */
  30214. protected _useRoughnessFromMetallicTextureGreen: boolean;
  30215. /**
  30216. * Specifies if the metallic texture contains the metallness information in its blue channel.
  30217. */
  30218. protected _useMetallnessFromMetallicTextureBlue: boolean;
  30219. /**
  30220. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  30221. */
  30222. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  30223. /**
  30224. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  30225. */
  30226. protected _useAmbientInGrayScale: boolean;
  30227. /**
  30228. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  30229. * The material will try to infer what glossiness each pixel should be.
  30230. */
  30231. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  30232. /**
  30233. * BJS is using an harcoded light falloff based on a manually sets up range.
  30234. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  30235. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  30236. */
  30237. protected _usePhysicalLightFalloff: boolean;
  30238. /**
  30239. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30240. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30241. */
  30242. protected _useRadianceOverAlpha: boolean;
  30243. /**
  30244. * Allows using an object space normal map (instead of tangent space).
  30245. */
  30246. protected _useObjectSpaceNormalMap: boolean;
  30247. /**
  30248. * Allows using the bump map in parallax mode.
  30249. */
  30250. protected _useParallax: boolean;
  30251. /**
  30252. * Allows using the bump map in parallax occlusion mode.
  30253. */
  30254. protected _useParallaxOcclusion: boolean;
  30255. /**
  30256. * Controls the scale bias of the parallax mode.
  30257. */
  30258. protected _parallaxScaleBias: number;
  30259. /**
  30260. * If sets to true, disables all the lights affecting the material.
  30261. */
  30262. protected _disableLighting: boolean;
  30263. /**
  30264. * Number of Simultaneous lights allowed on the material.
  30265. */
  30266. protected _maxSimultaneousLights: number;
  30267. /**
  30268. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  30269. */
  30270. protected _invertNormalMapX: boolean;
  30271. /**
  30272. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  30273. */
  30274. protected _invertNormalMapY: boolean;
  30275. /**
  30276. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30277. */
  30278. protected _twoSidedLighting: boolean;
  30279. /**
  30280. * Defines the alpha limits in alpha test mode.
  30281. */
  30282. protected _alphaCutOff: number;
  30283. /**
  30284. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30285. */
  30286. protected _forceAlphaTest: boolean;
  30287. /**
  30288. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  30289. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  30290. */
  30291. protected _useAlphaFresnel: boolean;
  30292. /**
  30293. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  30294. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  30295. */
  30296. protected _useLinearAlphaFresnel: boolean;
  30297. /**
  30298. * The transparency mode of the material.
  30299. */
  30300. protected _transparencyMode: Nullable<number>;
  30301. /**
  30302. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  30303. * from cos thetav and roughness:
  30304. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  30305. */
  30306. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  30307. /**
  30308. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  30309. */
  30310. protected _forceIrradianceInFragment: boolean;
  30311. /**
  30312. * Force normal to face away from face.
  30313. */
  30314. protected _forceNormalForward: boolean;
  30315. /**
  30316. * Enables specular anti aliasing in the PBR shader.
  30317. * It will both interacts on the Geometry for analytical and IBL lighting.
  30318. * It also prefilter the roughness map based on the bump values.
  30319. */
  30320. protected _enableSpecularAntiAliasing: boolean;
  30321. /**
  30322. * Default configuration related to image processing available in the PBR Material.
  30323. */
  30324. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30325. /**
  30326. * Keep track of the image processing observer to allow dispose and replace.
  30327. */
  30328. private _imageProcessingObserver;
  30329. /**
  30330. * Attaches a new image processing configuration to the PBR Material.
  30331. * @param configuration
  30332. */
  30333. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30334. /**
  30335. * Stores the available render targets.
  30336. */
  30337. private _renderTargets;
  30338. /**
  30339. * Sets the global ambient color for the material used in lighting calculations.
  30340. */
  30341. private _globalAmbientColor;
  30342. /**
  30343. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  30344. */
  30345. private _useLogarithmicDepth;
  30346. /**
  30347. * If set to true, no lighting calculations will be applied.
  30348. */
  30349. private _unlit;
  30350. /**
  30351. * Instantiates a new PBRMaterial instance.
  30352. *
  30353. * @param name The material name
  30354. * @param scene The scene the material will be use in.
  30355. */
  30356. constructor(name: string, scene: Scene);
  30357. /**
  30358. * Gets the name of the material class.
  30359. */
  30360. getClassName(): string;
  30361. /**
  30362. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  30363. */
  30364. /**
  30365. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  30366. */
  30367. useLogarithmicDepth: boolean;
  30368. /**
  30369. * Gets the current transparency mode.
  30370. */
  30371. /**
  30372. * Sets the transparency mode of the material.
  30373. */
  30374. transparencyMode: Nullable<number>;
  30375. /**
  30376. * Returns true if alpha blending should be disabled.
  30377. */
  30378. private readonly _disableAlphaBlending;
  30379. /**
  30380. * Specifies whether or not this material should be rendered in alpha blend mode.
  30381. */
  30382. needAlphaBlending(): boolean;
  30383. /**
  30384. * Specifies if the mesh will require alpha blending.
  30385. * @param mesh - BJS mesh.
  30386. */
  30387. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30388. /**
  30389. * Specifies whether or not this material should be rendered in alpha test mode.
  30390. */
  30391. needAlphaTesting(): boolean;
  30392. /**
  30393. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  30394. */
  30395. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  30396. /**
  30397. * Gets the texture used for the alpha test.
  30398. */
  30399. getAlphaTestTexture(): BaseTexture;
  30400. /**
  30401. * Stores the reflectivity values based on metallic roughness workflow.
  30402. */
  30403. private static _scaledReflectivity;
  30404. /**
  30405. * Specifies that the submesh is ready to be used.
  30406. * @param mesh - BJS mesh.
  30407. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  30408. * @param useInstances - Specifies that instances should be used.
  30409. * @returns - boolean indicating that the submesh is ready or not.
  30410. */
  30411. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30412. /**
  30413. * Specifies if the material uses metallic roughness workflow.
  30414. * @returns boolean specifiying if the material uses metallic roughness workflow.
  30415. */
  30416. isMetallicWorkflow(): boolean;
  30417. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  30418. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  30419. /**
  30420. * Force shader compilation
  30421. */
  30422. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  30423. clipPlane: boolean;
  30424. }>): void;
  30425. /**
  30426. * Initializes the uniform buffer layout for the shader.
  30427. */
  30428. buildUniformLayout(): void;
  30429. /**
  30430. * Unbinds the textures.
  30431. */
  30432. unbind(): void;
  30433. /**
  30434. * Binds the submesh data.
  30435. * @param world - The world matrix.
  30436. * @param mesh - The BJS mesh.
  30437. * @param subMesh - A submesh of the BJS mesh.
  30438. */
  30439. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30440. /**
  30441. * Returns the animatable textures.
  30442. * @returns - Array of animatable textures.
  30443. */
  30444. getAnimatables(): IAnimatable[];
  30445. /**
  30446. * Returns the texture used for reflections.
  30447. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  30448. */
  30449. private _getReflectionTexture();
  30450. /**
  30451. * Returns the texture used for refraction or null if none is used.
  30452. * @returns - Refection texture if present. If no refraction texture and refraction
  30453. * is linked with transparency, returns environment texture. Otherwise, returns null.
  30454. */
  30455. private _getRefractionTexture();
  30456. /**
  30457. * Disposes the resources of the material.
  30458. * @param forceDisposeEffect - Forces the disposal of effects.
  30459. * @param forceDisposeTextures - Forces the disposal of all textures.
  30460. */
  30461. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30462. }
  30463. }
  30464. declare module BABYLON {
  30465. /**
  30466. * The Physically based simple base material of BJS.
  30467. *
  30468. * This enables better naming and convention enforcements on top of the pbrMaterial.
  30469. * It is used as the base class for both the specGloss and metalRough conventions.
  30470. */
  30471. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  30472. /**
  30473. * Number of Simultaneous lights allowed on the material.
  30474. */
  30475. maxSimultaneousLights: number;
  30476. /**
  30477. * If sets to true, disables all the lights affecting the material.
  30478. */
  30479. disableLighting: boolean;
  30480. /**
  30481. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  30482. */
  30483. environmentTexture: BaseTexture;
  30484. /**
  30485. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30486. */
  30487. invertNormalMapX: boolean;
  30488. /**
  30489. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30490. */
  30491. invertNormalMapY: boolean;
  30492. /**
  30493. * Normal map used in the model.
  30494. */
  30495. normalTexture: BaseTexture;
  30496. /**
  30497. * Emissivie color used to self-illuminate the model.
  30498. */
  30499. emissiveColor: Color3;
  30500. /**
  30501. * Emissivie texture used to self-illuminate the model.
  30502. */
  30503. emissiveTexture: BaseTexture;
  30504. /**
  30505. * Occlusion Channel Strenght.
  30506. */
  30507. occlusionStrength: number;
  30508. /**
  30509. * Occlusion Texture of the material (adding extra occlusion effects).
  30510. */
  30511. occlusionTexture: BaseTexture;
  30512. /**
  30513. * Defines the alpha limits in alpha test mode.
  30514. */
  30515. alphaCutOff: number;
  30516. /**
  30517. * Gets the current double sided mode.
  30518. */
  30519. /**
  30520. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30521. */
  30522. doubleSided: boolean;
  30523. lightmapTexture: BaseTexture;
  30524. useLightmapAsShadowmap: boolean;
  30525. /**
  30526. * Return the active textures of the material.
  30527. */
  30528. getActiveTextures(): BaseTexture[];
  30529. hasTexture(texture: BaseTexture): boolean;
  30530. /**
  30531. * Instantiates a new PBRMaterial instance.
  30532. *
  30533. * @param name The material name
  30534. * @param scene The scene the material will be use in.
  30535. */
  30536. constructor(name: string, scene: Scene);
  30537. getClassName(): string;
  30538. }
  30539. }
  30540. declare module BABYLON {
  30541. /**
  30542. * The Physically based material of BJS.
  30543. *
  30544. * This offers the main features of a standard PBR material.
  30545. * For more information, please refer to the documentation :
  30546. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  30547. */
  30548. class PBRMaterial extends PBRBaseMaterial {
  30549. private static _PBRMATERIAL_OPAQUE;
  30550. /**
  30551. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30552. */
  30553. static readonly PBRMATERIAL_OPAQUE: number;
  30554. /**
  30555. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30556. */
  30557. private static _PBRMATERIAL_ALPHATEST;
  30558. /**
  30559. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30560. */
  30561. static readonly PBRMATERIAL_ALPHATEST: number;
  30562. /**
  30563. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30564. */
  30565. private static _PBRMATERIAL_ALPHABLEND;
  30566. /**
  30567. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30568. */
  30569. static readonly PBRMATERIAL_ALPHABLEND: number;
  30570. /**
  30571. * Represents the value for Alpha Test and Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30572. * They are also discarded below the alpha cutoff threshold to improve performances.
  30573. */
  30574. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  30575. /**
  30576. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30577. * They are also discarded below the alpha cutoff threshold to improve performances.
  30578. */
  30579. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  30580. /**
  30581. * Intensity of the direct lights e.g. the four lights available in your scene.
  30582. * This impacts both the direct diffuse and specular highlights.
  30583. */
  30584. directIntensity: number;
  30585. /**
  30586. * Intensity of the emissive part of the material.
  30587. * This helps controlling the emissive effect without modifying the emissive color.
  30588. */
  30589. emissiveIntensity: number;
  30590. /**
  30591. * Intensity of the environment e.g. how much the environment will light the object
  30592. * either through harmonics for rough material or through the refelction for shiny ones.
  30593. */
  30594. environmentIntensity: number;
  30595. /**
  30596. * This is a special control allowing the reduction of the specular highlights coming from the
  30597. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  30598. */
  30599. specularIntensity: number;
  30600. /**
  30601. * Debug Control allowing disabling the bump map on this material.
  30602. */
  30603. disableBumpMap: boolean;
  30604. /**
  30605. * AKA Diffuse Texture in standard nomenclature.
  30606. */
  30607. albedoTexture: BaseTexture;
  30608. /**
  30609. * AKA Occlusion Texture in other nomenclature.
  30610. */
  30611. ambientTexture: BaseTexture;
  30612. /**
  30613. * AKA Occlusion Texture Intensity in other nomenclature.
  30614. */
  30615. ambientTextureStrength: number;
  30616. /**
  30617. * Stores the alpha values in a texture.
  30618. */
  30619. opacityTexture: BaseTexture;
  30620. /**
  30621. * Stores the reflection values in a texture.
  30622. */
  30623. reflectionTexture: Nullable<BaseTexture>;
  30624. /**
  30625. * Stores the emissive values in a texture.
  30626. */
  30627. emissiveTexture: BaseTexture;
  30628. /**
  30629. * AKA Specular texture in other nomenclature.
  30630. */
  30631. reflectivityTexture: BaseTexture;
  30632. /**
  30633. * Used to switch from specular/glossiness to metallic/roughness workflow.
  30634. */
  30635. metallicTexture: BaseTexture;
  30636. /**
  30637. * Specifies the metallic scalar of the metallic/roughness workflow.
  30638. * Can also be used to scale the metalness values of the metallic texture.
  30639. */
  30640. metallic: number;
  30641. /**
  30642. * Specifies the roughness scalar of the metallic/roughness workflow.
  30643. * Can also be used to scale the roughness values of the metallic texture.
  30644. */
  30645. roughness: number;
  30646. /**
  30647. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  30648. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  30649. */
  30650. microSurfaceTexture: BaseTexture;
  30651. /**
  30652. * Stores surface normal data used to displace a mesh in a texture.
  30653. */
  30654. bumpTexture: BaseTexture;
  30655. /**
  30656. * Stores the pre-calculated light information of a mesh in a texture.
  30657. */
  30658. lightmapTexture: BaseTexture;
  30659. /**
  30660. * Stores the refracted light information in a texture.
  30661. */
  30662. refractionTexture: BaseTexture;
  30663. /**
  30664. * The color of a material in ambient lighting.
  30665. */
  30666. ambientColor: Color3;
  30667. /**
  30668. * AKA Diffuse Color in other nomenclature.
  30669. */
  30670. albedoColor: Color3;
  30671. /**
  30672. * AKA Specular Color in other nomenclature.
  30673. */
  30674. reflectivityColor: Color3;
  30675. /**
  30676. * The color reflected from the material.
  30677. */
  30678. reflectionColor: Color3;
  30679. /**
  30680. * The color emitted from the material.
  30681. */
  30682. emissiveColor: Color3;
  30683. /**
  30684. * AKA Glossiness in other nomenclature.
  30685. */
  30686. microSurface: number;
  30687. /**
  30688. * source material index of refraction (IOR)' / 'destination material IOR.
  30689. */
  30690. indexOfRefraction: number;
  30691. /**
  30692. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  30693. */
  30694. invertRefractionY: boolean;
  30695. /**
  30696. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  30697. * Materials half opaque for instance using refraction could benefit from this control.
  30698. */
  30699. linkRefractionWithTransparency: boolean;
  30700. useLightmapAsShadowmap: boolean;
  30701. /**
  30702. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  30703. */
  30704. useAlphaFromAlbedoTexture: boolean;
  30705. /**
  30706. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30707. */
  30708. forceAlphaTest: boolean;
  30709. /**
  30710. * Defines the alpha limits in alpha test mode.
  30711. */
  30712. alphaCutOff: number;
  30713. /**
  30714. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  30715. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30716. */
  30717. useSpecularOverAlpha: boolean;
  30718. /**
  30719. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  30720. */
  30721. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  30722. /**
  30723. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  30724. */
  30725. useRoughnessFromMetallicTextureAlpha: boolean;
  30726. /**
  30727. * Specifies if the metallic texture contains the roughness information in its green channel.
  30728. */
  30729. useRoughnessFromMetallicTextureGreen: boolean;
  30730. /**
  30731. * Specifies if the metallic texture contains the metallness information in its blue channel.
  30732. */
  30733. useMetallnessFromMetallicTextureBlue: boolean;
  30734. /**
  30735. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  30736. */
  30737. useAmbientOcclusionFromMetallicTextureRed: boolean;
  30738. /**
  30739. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  30740. */
  30741. useAmbientInGrayScale: boolean;
  30742. /**
  30743. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  30744. * The material will try to infer what glossiness each pixel should be.
  30745. */
  30746. useAutoMicroSurfaceFromReflectivityMap: boolean;
  30747. /**
  30748. * BJS is using an harcoded light falloff based on a manually sets up range.
  30749. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  30750. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  30751. */
  30752. usePhysicalLightFalloff: boolean;
  30753. /**
  30754. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30755. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30756. */
  30757. useRadianceOverAlpha: boolean;
  30758. /**
  30759. * Allows using an object space normal map (instead of tangent space).
  30760. */
  30761. useObjectSpaceNormalMap: boolean;
  30762. /**
  30763. * Allows using the bump map in parallax mode.
  30764. */
  30765. useParallax: boolean;
  30766. /**
  30767. * Allows using the bump map in parallax occlusion mode.
  30768. */
  30769. useParallaxOcclusion: boolean;
  30770. /**
  30771. * Controls the scale bias of the parallax mode.
  30772. */
  30773. parallaxScaleBias: number;
  30774. /**
  30775. * If sets to true, disables all the lights affecting the material.
  30776. */
  30777. disableLighting: boolean;
  30778. /**
  30779. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  30780. */
  30781. forceIrradianceInFragment: boolean;
  30782. /**
  30783. * Number of Simultaneous lights allowed on the material.
  30784. */
  30785. maxSimultaneousLights: number;
  30786. /**
  30787. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30788. */
  30789. invertNormalMapX: boolean;
  30790. /**
  30791. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30792. */
  30793. invertNormalMapY: boolean;
  30794. /**
  30795. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30796. */
  30797. twoSidedLighting: boolean;
  30798. /**
  30799. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  30800. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  30801. */
  30802. useAlphaFresnel: boolean;
  30803. /**
  30804. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  30805. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  30806. */
  30807. useLinearAlphaFresnel: boolean;
  30808. /**
  30809. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  30810. * And/Or occlude the blended part.
  30811. */
  30812. environmentBRDFTexture: Nullable<BaseTexture>;
  30813. /**
  30814. * Force normal to face away from face.
  30815. */
  30816. forceNormalForward: boolean;
  30817. /**
  30818. * Enables specular anti aliasing in the PBR shader.
  30819. * It will both interacts on the Geometry for analytical and IBL lighting.
  30820. * It also prefilter the roughness map based on the bump values.
  30821. */
  30822. enableSpecularAntiAliasing: boolean;
  30823. /**
  30824. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  30825. * makes the reflect vector face the model (under horizon).
  30826. */
  30827. useHorizonOcclusion: boolean;
  30828. /**
  30829. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  30830. * too much the area relying on ambient texture to define their ambient occlusion.
  30831. */
  30832. useRadianceOcclusion: boolean;
  30833. /**
  30834. * If set to true, no lighting calculations will be applied.
  30835. */
  30836. unlit: boolean;
  30837. /**
  30838. * Gets the image processing configuration used either in this material.
  30839. */
  30840. /**
  30841. * Sets the Default image processing configuration used either in the this material.
  30842. *
  30843. * If sets to null, the scene one is in use.
  30844. */
  30845. imageProcessingConfiguration: ImageProcessingConfiguration;
  30846. /**
  30847. * Gets wether the color curves effect is enabled.
  30848. */
  30849. /**
  30850. * Sets wether the color curves effect is enabled.
  30851. */
  30852. cameraColorCurvesEnabled: boolean;
  30853. /**
  30854. * Gets wether the color grading effect is enabled.
  30855. */
  30856. /**
  30857. * Gets wether the color grading effect is enabled.
  30858. */
  30859. cameraColorGradingEnabled: boolean;
  30860. /**
  30861. * Gets wether tonemapping is enabled or not.
  30862. */
  30863. /**
  30864. * Sets wether tonemapping is enabled or not
  30865. */
  30866. cameraToneMappingEnabled: boolean;
  30867. /**
  30868. * The camera exposure used on this material.
  30869. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30870. * This corresponds to a photographic exposure.
  30871. */
  30872. /**
  30873. * The camera exposure used on this material.
  30874. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30875. * This corresponds to a photographic exposure.
  30876. */
  30877. cameraExposure: number;
  30878. /**
  30879. * Gets The camera contrast used on this material.
  30880. */
  30881. /**
  30882. * Sets The camera contrast used on this material.
  30883. */
  30884. cameraContrast: number;
  30885. /**
  30886. * Gets the Color Grading 2D Lookup Texture.
  30887. */
  30888. /**
  30889. * Sets the Color Grading 2D Lookup Texture.
  30890. */
  30891. cameraColorGradingTexture: Nullable<BaseTexture>;
  30892. /**
  30893. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30894. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30895. * 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;
  30896. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30897. */
  30898. /**
  30899. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30900. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30901. * 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;
  30902. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30903. */
  30904. cameraColorCurves: Nullable<ColorCurves>;
  30905. /**
  30906. * Instantiates a new PBRMaterial instance.
  30907. *
  30908. * @param name The material name
  30909. * @param scene The scene the material will be use in.
  30910. */
  30911. constructor(name: string, scene: Scene);
  30912. /**
  30913. * Returns the name of this material class.
  30914. */
  30915. getClassName(): string;
  30916. /**
  30917. * Returns an array of the actively used textures.
  30918. * @returns - Array of BaseTextures
  30919. */
  30920. getActiveTextures(): BaseTexture[];
  30921. /**
  30922. * Checks to see if a texture is used in the material.
  30923. * @param texture - Base texture to use.
  30924. * @returns - Boolean specifying if a texture is used in the material.
  30925. */
  30926. hasTexture(texture: BaseTexture): boolean;
  30927. /**
  30928. * Makes a duplicate of the current material.
  30929. * @param name - name to use for the new material.
  30930. */
  30931. clone(name: string): PBRMaterial;
  30932. /**
  30933. * Serializes this PBR Material.
  30934. * @returns - An object with the serialized material.
  30935. */
  30936. serialize(): any;
  30937. /**
  30938. * Parses a PBR Material from a serialized object.
  30939. * @param source - Serialized object.
  30940. * @param scene - BJS scene instance.
  30941. * @param rootUrl - url for the scene object
  30942. * @returns - PBRMaterial
  30943. */
  30944. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  30945. }
  30946. }
  30947. declare module BABYLON {
  30948. /**
  30949. * The PBR material of BJS following the metal roughness convention.
  30950. *
  30951. * This fits to the PBR convention in the GLTF definition:
  30952. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  30953. */
  30954. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  30955. /**
  30956. * The base color has two different interpretations depending on the value of metalness.
  30957. * When the material is a metal, the base color is the specific measured reflectance value
  30958. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  30959. * of the material.
  30960. */
  30961. baseColor: Color3;
  30962. /**
  30963. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  30964. * well as opacity information in the alpha channel.
  30965. */
  30966. baseTexture: BaseTexture;
  30967. /**
  30968. * Specifies the metallic scalar value of the material.
  30969. * Can also be used to scale the metalness values of the metallic texture.
  30970. */
  30971. metallic: number;
  30972. /**
  30973. * Specifies the roughness scalar value of the material.
  30974. * Can also be used to scale the roughness values of the metallic texture.
  30975. */
  30976. roughness: number;
  30977. /**
  30978. * Texture containing both the metallic value in the B channel and the
  30979. * roughness value in the G channel to keep better precision.
  30980. */
  30981. metallicRoughnessTexture: BaseTexture;
  30982. /**
  30983. * Instantiates a new PBRMetalRoughnessMaterial instance.
  30984. *
  30985. * @param name The material name
  30986. * @param scene The scene the material will be use in.
  30987. */
  30988. constructor(name: string, scene: Scene);
  30989. /**
  30990. * Return the currrent class name of the material.
  30991. */
  30992. getClassName(): string;
  30993. /**
  30994. * Return the active textures of the material.
  30995. */
  30996. getActiveTextures(): BaseTexture[];
  30997. /**
  30998. * Checks to see if a texture is used in the material.
  30999. * @param texture - Base texture to use.
  31000. * @returns - Boolean specifying if a texture is used in the material.
  31001. */
  31002. hasTexture(texture: BaseTexture): boolean;
  31003. /**
  31004. * Makes a duplicate of the current material.
  31005. * @param name - name to use for the new material.
  31006. */
  31007. clone(name: string): PBRMetallicRoughnessMaterial;
  31008. /**
  31009. * Serialize the material to a parsable JSON object.
  31010. */
  31011. serialize(): any;
  31012. /**
  31013. * Parses a JSON object correponding to the serialize function.
  31014. */
  31015. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  31016. }
  31017. }
  31018. declare module BABYLON {
  31019. /**
  31020. * The PBR material of BJS following the specular glossiness convention.
  31021. *
  31022. * This fits to the PBR convention in the GLTF definition:
  31023. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  31024. */
  31025. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  31026. /**
  31027. * Specifies the diffuse color of the material.
  31028. */
  31029. diffuseColor: Color3;
  31030. /**
  31031. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  31032. * channel.
  31033. */
  31034. diffuseTexture: BaseTexture;
  31035. /**
  31036. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  31037. */
  31038. specularColor: Color3;
  31039. /**
  31040. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  31041. */
  31042. glossiness: number;
  31043. /**
  31044. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  31045. */
  31046. specularGlossinessTexture: BaseTexture;
  31047. /**
  31048. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  31049. *
  31050. * @param name The material name
  31051. * @param scene The scene the material will be use in.
  31052. */
  31053. constructor(name: string, scene: Scene);
  31054. /**
  31055. * Return the currrent class name of the material.
  31056. */
  31057. getClassName(): string;
  31058. /**
  31059. * Return the active textures of the material.
  31060. */
  31061. getActiveTextures(): BaseTexture[];
  31062. /**
  31063. * Checks to see if a texture is used in the material.
  31064. * @param texture - Base texture to use.
  31065. * @returns - Boolean specifying if a texture is used in the material.
  31066. */
  31067. hasTexture(texture: BaseTexture): boolean;
  31068. /**
  31069. * Makes a duplicate of the current material.
  31070. * @param name - name to use for the new material.
  31071. */
  31072. clone(name: string): PBRSpecularGlossinessMaterial;
  31073. /**
  31074. * Serialize the material to a parsable JSON object.
  31075. */
  31076. serialize(): any;
  31077. /**
  31078. * Parses a JSON object correponding to the serialize function.
  31079. */
  31080. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  31081. }
  31082. }
  31083. declare module BABYLON {
  31084. class BaseTexture {
  31085. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  31086. name: string;
  31087. private _hasAlpha;
  31088. hasAlpha: boolean;
  31089. getAlphaFromRGB: boolean;
  31090. level: number;
  31091. coordinatesIndex: number;
  31092. private _coordinatesMode;
  31093. /**
  31094. * How a texture is mapped.
  31095. *
  31096. * | Value | Type | Description |
  31097. * | ----- | ----------------------------------- | ----------- |
  31098. * | 0 | EXPLICIT_MODE | |
  31099. * | 1 | SPHERICAL_MODE | |
  31100. * | 2 | PLANAR_MODE | |
  31101. * | 3 | CUBIC_MODE | |
  31102. * | 4 | PROJECTION_MODE | |
  31103. * | 5 | SKYBOX_MODE | |
  31104. * | 6 | INVCUBIC_MODE | |
  31105. * | 7 | EQUIRECTANGULAR_MODE | |
  31106. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  31107. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  31108. */
  31109. coordinatesMode: number;
  31110. /**
  31111. * | Value | Type | Description |
  31112. * | ----- | ------------------ | ----------- |
  31113. * | 0 | CLAMP_ADDRESSMODE | |
  31114. * | 1 | WRAP_ADDRESSMODE | |
  31115. * | 2 | MIRROR_ADDRESSMODE | |
  31116. */
  31117. wrapU: number;
  31118. /**
  31119. * | Value | Type | Description |
  31120. * | ----- | ------------------ | ----------- |
  31121. * | 0 | CLAMP_ADDRESSMODE | |
  31122. * | 1 | WRAP_ADDRESSMODE | |
  31123. * | 2 | MIRROR_ADDRESSMODE | |
  31124. */
  31125. wrapV: number;
  31126. /**
  31127. * | Value | Type | Description |
  31128. * | ----- | ------------------ | ----------- |
  31129. * | 0 | CLAMP_ADDRESSMODE | |
  31130. * | 1 | WRAP_ADDRESSMODE | |
  31131. * | 2 | MIRROR_ADDRESSMODE | |
  31132. */
  31133. wrapR: number;
  31134. anisotropicFilteringLevel: number;
  31135. isCube: boolean;
  31136. is3D: boolean;
  31137. gammaSpace: boolean;
  31138. invertZ: boolean;
  31139. lodLevelInAlpha: boolean;
  31140. lodGenerationOffset: number;
  31141. lodGenerationScale: number;
  31142. isRenderTarget: boolean;
  31143. readonly uid: string;
  31144. toString(): string;
  31145. getClassName(): string;
  31146. animations: Animation[];
  31147. /**
  31148. * An event triggered when the texture is disposed.
  31149. */
  31150. onDisposeObservable: Observable<BaseTexture>;
  31151. private _onDisposeObserver;
  31152. onDispose: () => void;
  31153. delayLoadState: number;
  31154. private _scene;
  31155. _texture: Nullable<InternalTexture>;
  31156. private _uid;
  31157. readonly isBlocking: boolean;
  31158. constructor(scene: Nullable<Scene>);
  31159. getScene(): Nullable<Scene>;
  31160. getTextureMatrix(): Matrix;
  31161. getReflectionTextureMatrix(): Matrix;
  31162. getInternalTexture(): Nullable<InternalTexture>;
  31163. isReadyOrNotBlocking(): boolean;
  31164. isReady(): boolean;
  31165. getSize(): ISize;
  31166. getBaseSize(): ISize;
  31167. scale(ratio: number): void;
  31168. readonly canRescale: boolean;
  31169. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  31170. _rebuild(): void;
  31171. delayLoad(): void;
  31172. clone(): Nullable<BaseTexture>;
  31173. readonly textureType: number;
  31174. readonly textureFormat: number;
  31175. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  31176. releaseInternalTexture(): void;
  31177. sphericalPolynomial: Nullable<SphericalPolynomial>;
  31178. readonly _lodTextureHigh: Nullable<BaseTexture>;
  31179. readonly _lodTextureMid: Nullable<BaseTexture>;
  31180. readonly _lodTextureLow: Nullable<BaseTexture>;
  31181. dispose(): void;
  31182. serialize(): any;
  31183. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  31184. }
  31185. }
  31186. declare module BABYLON {
  31187. /**
  31188. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  31189. * It can help converting any input color in a desired output one. This can then be used to create effects
  31190. * from sepia, black and white to sixties or futuristic rendering...
  31191. *
  31192. * The only supported format is currently 3dl.
  31193. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  31194. */
  31195. class ColorGradingTexture extends BaseTexture {
  31196. /**
  31197. * The current texture matrix. (will always be identity in color grading texture)
  31198. */
  31199. private _textureMatrix;
  31200. /**
  31201. * The texture URL.
  31202. */
  31203. url: string;
  31204. /**
  31205. * Empty line regex stored for GC.
  31206. */
  31207. private static _noneEmptyLineRegex;
  31208. private _engine;
  31209. /**
  31210. * Instantiates a ColorGradingTexture from the following parameters.
  31211. *
  31212. * @param url The location of the color gradind data (currently only supporting 3dl)
  31213. * @param scene The scene the texture will be used in
  31214. */
  31215. constructor(url: string, scene: Scene);
  31216. /**
  31217. * Returns the texture matrix used in most of the material.
  31218. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  31219. */
  31220. getTextureMatrix(): Matrix;
  31221. /**
  31222. * Occurs when the file being loaded is a .3dl LUT file.
  31223. */
  31224. private load3dlTexture();
  31225. /**
  31226. * Starts the loading process of the texture.
  31227. */
  31228. private loadTexture();
  31229. /**
  31230. * Clones the color gradind texture.
  31231. */
  31232. clone(): ColorGradingTexture;
  31233. /**
  31234. * Called during delayed load for textures.
  31235. */
  31236. delayLoad(): void;
  31237. /**
  31238. * Parses a color grading texture serialized by Babylon.
  31239. * @param parsedTexture The texture information being parsedTexture
  31240. * @param scene The scene to load the texture in
  31241. * @param rootUrl The root url of the data assets to load
  31242. * @return A color gradind texture
  31243. */
  31244. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  31245. /**
  31246. * Serializes the LUT texture to json format.
  31247. */
  31248. serialize(): any;
  31249. }
  31250. }
  31251. declare module BABYLON {
  31252. class CubeTexture extends BaseTexture {
  31253. url: string;
  31254. coordinatesMode: number;
  31255. /**
  31256. * Gets or sets the center of the bounding box associated with the cube texture
  31257. * It must define where the camera used to render the texture was set
  31258. */
  31259. boundingBoxPosition: Vector3;
  31260. private _boundingBoxSize;
  31261. /**
  31262. * Gets or sets the size of the bounding box associated with the cube texture
  31263. * When defined, the cubemap will switch to local mode
  31264. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  31265. * @example https://www.babylonjs-playground.com/#RNASML
  31266. */
  31267. boundingBoxSize: Vector3;
  31268. protected _rotationY: number;
  31269. /**
  31270. * Gets texture matrix rotation angle around Y axis radians.
  31271. */
  31272. /**
  31273. * Sets texture matrix rotation angle around Y axis in radians.
  31274. */
  31275. rotationY: number;
  31276. private _noMipmap;
  31277. private _files;
  31278. private _extensions;
  31279. private _textureMatrix;
  31280. private _format;
  31281. private _prefiltered;
  31282. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  31283. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any): CubeTexture;
  31284. 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);
  31285. delayLoad(): void;
  31286. getReflectionTextureMatrix(): Matrix;
  31287. setReflectionTextureMatrix(value: Matrix): void;
  31288. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  31289. clone(): CubeTexture;
  31290. }
  31291. }
  31292. declare module BABYLON {
  31293. /**
  31294. * A class extending {BABYLON.Texture} allowing drawing on a texture
  31295. * @see http://doc.babylonjs.com/how_to/dynamictexture
  31296. */
  31297. class DynamicTexture extends Texture {
  31298. private _generateMipMaps;
  31299. private _canvas;
  31300. private _context;
  31301. private _engine;
  31302. /**
  31303. * Creates a {BABYLON.DynamicTexture}
  31304. * @param name defines the name of the texture
  31305. * @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
  31306. * @param scene defines the scene where you want the texture
  31307. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  31308. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  31309. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  31310. */
  31311. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  31312. /**
  31313. * Gets the current state of canRescale
  31314. */
  31315. readonly canRescale: boolean;
  31316. private _recreate(textureSize);
  31317. /**
  31318. * Scales the texture
  31319. * @param ratio the scale factor to apply to both width and height
  31320. */
  31321. scale(ratio: number): void;
  31322. /**
  31323. * Resizes the texture
  31324. * @param width the new width
  31325. * @param height the new height
  31326. */
  31327. scaleTo(width: number, height: number): void;
  31328. /**
  31329. * Gets the context of the canvas used by the texture
  31330. * @returns the canvas context of the dynamic texture
  31331. */
  31332. getContext(): CanvasRenderingContext2D;
  31333. /**
  31334. * Clears the texture
  31335. */
  31336. clear(): void;
  31337. /**
  31338. * Updates the texture
  31339. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  31340. */
  31341. update(invertY?: boolean): void;
  31342. /**
  31343. * Draws text onto the texture
  31344. * @param text defines the text to be drawn
  31345. * @param x defines the placement of the text from the left
  31346. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  31347. * @param font defines the font to be used with font-style, font-size, font-name
  31348. * @param color defines the color used for the text
  31349. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  31350. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  31351. * @param update defines whether texture is immediately update (default is true)
  31352. */
  31353. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  31354. /**
  31355. * Clones the texture
  31356. * @returns the clone of the texture.
  31357. */
  31358. clone(): DynamicTexture;
  31359. /** @ignore */
  31360. _rebuild(): void;
  31361. }
  31362. }
  31363. declare module BABYLON {
  31364. /**
  31365. * This represents a texture coming from an HDR input.
  31366. *
  31367. * The only supported format is currently panorama picture stored in RGBE format.
  31368. * Example of such files can be found on HDRLib: http://hdrlib.com/
  31369. */
  31370. class HDRCubeTexture extends BaseTexture {
  31371. private static _facesMapping;
  31372. private _useInGammaSpace;
  31373. private _generateHarmonics;
  31374. private _noMipmap;
  31375. private _textureMatrix;
  31376. private _size;
  31377. private _usePMREMGenerator;
  31378. private _isBABYLONPreprocessed;
  31379. private _onLoad;
  31380. private _onError;
  31381. /**
  31382. * The texture URL.
  31383. */
  31384. url: string;
  31385. /**
  31386. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  31387. */
  31388. coordinatesMode: number;
  31389. /**
  31390. * Specifies wether the texture has been generated through the PMREMGenerator tool.
  31391. * This is usefull at run time to apply the good shader.
  31392. */
  31393. isPMREM: boolean;
  31394. protected _isBlocking: boolean;
  31395. /**
  31396. * Gets wether or not the texture is blocking during loading.
  31397. */
  31398. /**
  31399. * Sets wether or not the texture is blocking during loading.
  31400. */
  31401. isBlocking: boolean;
  31402. protected _rotationY: number;
  31403. /**
  31404. * Gets texture matrix rotation angle around Y axis radians.
  31405. */
  31406. /**
  31407. * Sets texture matrix rotation angle around Y axis in radians.
  31408. */
  31409. rotationY: number;
  31410. /**
  31411. * Gets or sets the center of the bounding box associated with the cube texture
  31412. * It must define where the camera used to render the texture was set
  31413. */
  31414. boundingBoxPosition: Vector3;
  31415. private _boundingBoxSize;
  31416. /**
  31417. * Gets or sets the size of the bounding box associated with the cube texture
  31418. * When defined, the cubemap will switch to local mode
  31419. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  31420. * @example https://www.babylonjs-playground.com/#RNASML
  31421. */
  31422. boundingBoxSize: Vector3;
  31423. /**
  31424. * Instantiates an HDRTexture from the following parameters.
  31425. *
  31426. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  31427. * @param scene The scene the texture will be used in
  31428. * @param size The cubemap 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.
  31429. * @param noMipmap Forces to not generate the mipmap if true
  31430. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  31431. * @param useInGammaSpace 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)
  31432. * @param usePMREMGenerator Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time.
  31433. */
  31434. constructor(url: string, scene: Scene, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  31435. /**
  31436. * Occurs when the file is a preprocessed .babylon.hdr file.
  31437. */
  31438. private loadBabylonTexture();
  31439. /**
  31440. * Occurs when the file is raw .hdr file.
  31441. */
  31442. private loadHDRTexture();
  31443. /**
  31444. * Starts the loading process of the texture.
  31445. */
  31446. private loadTexture();
  31447. clone(): HDRCubeTexture;
  31448. delayLoad(): void;
  31449. getReflectionTextureMatrix(): Matrix;
  31450. setReflectionTextureMatrix(value: Matrix): void;
  31451. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  31452. serialize(): any;
  31453. /**
  31454. * Saves as a file the data contained in the texture in a binary format.
  31455. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  31456. * as the spherical used in the lighting.
  31457. * @param url The HDR file url.
  31458. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  31459. * @param onError Method called if any error happens during download.
  31460. * @return The packed binary data.
  31461. */
  31462. static generateBabylonHDROnDisk(url: string, size: number, onError?: Nullable<(() => void)>): void;
  31463. /**
  31464. * Serializes the data contained in the texture in a binary format.
  31465. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  31466. * as the spherical used in the lighting.
  31467. * @param url The HDR file url.
  31468. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  31469. * @param onError Method called if any error happens during download.
  31470. * @return The packed binary data.
  31471. */
  31472. static generateBabylonHDR(url: string, size: number, callback: ((ArrayBuffer: ArrayBuffer) => void), onError?: Nullable<(() => void)>): void;
  31473. }
  31474. }
  31475. declare module BABYLON {
  31476. /**
  31477. * Class used to store data associated with WebGL texture data for the engine
  31478. * This class should not be used directly
  31479. */
  31480. class InternalTexture implements IInternalTextureTracker {
  31481. /**
  31482. * The source of the texture data is unknown
  31483. */
  31484. static DATASOURCE_UNKNOWN: number;
  31485. /**
  31486. * Texture data comes from an URL
  31487. */
  31488. static DATASOURCE_URL: number;
  31489. /**
  31490. * Texture data is only used for temporary storage
  31491. */
  31492. static DATASOURCE_TEMP: number;
  31493. /**
  31494. * Texture data comes from raw data (ArrayBuffer)
  31495. */
  31496. static DATASOURCE_RAW: number;
  31497. /**
  31498. * Texture content is dynamic (video or dynamic texture)
  31499. */
  31500. static DATASOURCE_DYNAMIC: number;
  31501. /**
  31502. * Texture content is generated by rendering to it
  31503. */
  31504. static DATASOURCE_RENDERTARGET: number;
  31505. /**
  31506. * Texture content is part of a multi render target process
  31507. */
  31508. static DATASOURCE_MULTIRENDERTARGET: number;
  31509. /**
  31510. * Texture data comes from a cube data file
  31511. */
  31512. static DATASOURCE_CUBE: number;
  31513. /**
  31514. * Texture data comes from a raw cube data
  31515. */
  31516. static DATASOURCE_CUBERAW: number;
  31517. /**
  31518. * Texture data come from a prefiltered cube data file
  31519. */
  31520. static DATASOURCE_CUBEPREFILTERED: number;
  31521. /**
  31522. * Texture content is raw 3D data
  31523. */
  31524. static DATASOURCE_RAW3D: number;
  31525. /**
  31526. * Texture content is a depth texture
  31527. */
  31528. static DATASOURCE_DEPTHTEXTURE: number;
  31529. /**
  31530. * Defines if the texture is ready
  31531. */
  31532. isReady: boolean;
  31533. /**
  31534. * Defines if the texture is a cube texture
  31535. */
  31536. isCube: boolean;
  31537. /**
  31538. * Defines if the texture contains 3D data
  31539. */
  31540. is3D: boolean;
  31541. /**
  31542. * Gets the URL used to load this texture
  31543. */
  31544. url: string;
  31545. /**
  31546. * Gets the sampling mode of the texture
  31547. */
  31548. samplingMode: number;
  31549. /**
  31550. * Gets a boolean indicating if the texture needs mipmaps generation
  31551. */
  31552. generateMipMaps: boolean;
  31553. /**
  31554. * Gets the number of samples used by the texture (WebGL2+ only)
  31555. */
  31556. samples: number;
  31557. /**
  31558. * Gets the type of the texture
  31559. */
  31560. type: number;
  31561. /**
  31562. * Gets the format of the texture
  31563. */
  31564. format: number;
  31565. /**
  31566. * Observable called when the texture is loaded
  31567. */
  31568. onLoadedObservable: Observable<InternalTexture>;
  31569. /**
  31570. * Gets the width of the texture
  31571. */
  31572. width: number;
  31573. /**
  31574. * Gets the height of the texture
  31575. */
  31576. height: number;
  31577. /**
  31578. * Gets the depth of the texture
  31579. */
  31580. depth: number;
  31581. /**
  31582. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31583. */
  31584. baseWidth: number;
  31585. /**
  31586. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31587. */
  31588. baseHeight: number;
  31589. /**
  31590. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31591. */
  31592. baseDepth: number;
  31593. /**
  31594. * Gets a boolean indicating if the texture is inverted on Y axis
  31595. */
  31596. invertY: boolean;
  31597. /**
  31598. * Gets or set the previous tracker in the list
  31599. */
  31600. previous: Nullable<IInternalTextureTracker>;
  31601. /**
  31602. * Gets or set the next tracker in the list
  31603. */
  31604. next: Nullable<IInternalTextureTracker>;
  31605. /** @ignore */
  31606. _initialSlot: number;
  31607. /** @ignore */
  31608. _designatedSlot: number;
  31609. /** @ignore */
  31610. _dataSource: number;
  31611. /** @ignore */
  31612. _buffer: Nullable<ArrayBuffer | HTMLImageElement>;
  31613. /** @ignore */
  31614. _bufferView: Nullable<ArrayBufferView>;
  31615. /** @ignore */
  31616. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31617. /** @ignore */
  31618. _size: number;
  31619. /** @ignore */
  31620. _extension: string;
  31621. /** @ignore */
  31622. _files: Nullable<string[]>;
  31623. /** @ignore */
  31624. _workingCanvas: HTMLCanvasElement;
  31625. /** @ignore */
  31626. _workingContext: CanvasRenderingContext2D;
  31627. /** @ignore */
  31628. _framebuffer: Nullable<WebGLFramebuffer>;
  31629. /** @ignore */
  31630. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31631. /** @ignore */
  31632. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31633. /** @ignore */
  31634. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31635. /** @ignore */
  31636. _attachments: Nullable<number[]>;
  31637. /** @ignore */
  31638. _cachedCoordinatesMode: Nullable<number>;
  31639. /** @ignore */
  31640. _cachedWrapU: Nullable<number>;
  31641. /** @ignore */
  31642. _cachedWrapV: Nullable<number>;
  31643. /** @ignore */
  31644. _cachedWrapR: Nullable<number>;
  31645. /** @ignore */
  31646. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31647. /** @ignore */
  31648. _isDisabled: boolean;
  31649. /** @ignore */
  31650. _compression: Nullable<string>;
  31651. /** @ignore */
  31652. _generateStencilBuffer: boolean;
  31653. /** @ignore */
  31654. _generateDepthBuffer: boolean;
  31655. /** @ignore */
  31656. _comparisonFunction: number;
  31657. /** @ignore */
  31658. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31659. /** @ignore */
  31660. _lodGenerationScale: number;
  31661. /** @ignore */
  31662. _lodGenerationOffset: number;
  31663. /** @ignore */
  31664. _lodTextureHigh: BaseTexture;
  31665. /** @ignore */
  31666. _lodTextureMid: BaseTexture;
  31667. /** @ignore */
  31668. _lodTextureLow: BaseTexture;
  31669. /** @ignore */
  31670. _webGLTexture: Nullable<WebGLTexture>;
  31671. /** @ignore */
  31672. _references: number;
  31673. private _engine;
  31674. /**
  31675. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  31676. */
  31677. readonly dataSource: number;
  31678. /**
  31679. * Creates a new InternalTexture
  31680. * @param engine defines the engine to use
  31681. * @param dataSource defines the type of data that will be used
  31682. */
  31683. constructor(engine: Engine, dataSource: number);
  31684. /**
  31685. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  31686. */
  31687. incrementReferences(): void;
  31688. /**
  31689. * Change the size of the texture (not the size of the content)
  31690. * @param width defines the new width
  31691. * @param height defines the new height
  31692. * @param depth defines the new depth (1 by default)
  31693. */
  31694. updateSize(width: int, height: int, depth?: int): void;
  31695. /** @ignore */
  31696. _rebuild(): void;
  31697. private _swapAndDie(target);
  31698. /**
  31699. * Dispose the current allocated resources
  31700. */
  31701. dispose(): void;
  31702. }
  31703. }
  31704. declare module BABYLON {
  31705. /**
  31706. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  31707. */
  31708. interface IInternalTextureTracker {
  31709. /**
  31710. * Gets or set the previous tracker in the list
  31711. */
  31712. previous: Nullable<IInternalTextureTracker>;
  31713. /**
  31714. * Gets or set the next tracker in the list
  31715. */
  31716. next: Nullable<IInternalTextureTracker>;
  31717. }
  31718. /**
  31719. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  31720. */
  31721. class DummyInternalTextureTracker {
  31722. /**
  31723. * Gets or set the previous tracker in the list
  31724. */
  31725. previous: Nullable<IInternalTextureTracker>;
  31726. /**
  31727. * Gets or set the next tracker in the list
  31728. */
  31729. next: Nullable<IInternalTextureTracker>;
  31730. }
  31731. }
  31732. declare module BABYLON {
  31733. class MirrorTexture extends RenderTargetTexture {
  31734. private scene;
  31735. mirrorPlane: Plane;
  31736. private _transformMatrix;
  31737. private _mirrorMatrix;
  31738. private _savedViewMatrix;
  31739. private _blurX;
  31740. private _blurY;
  31741. private _adaptiveBlurKernel;
  31742. private _blurKernelX;
  31743. private _blurKernelY;
  31744. private _blurRatio;
  31745. blurRatio: number;
  31746. adaptiveBlurKernel: number;
  31747. blurKernel: number;
  31748. blurKernelX: number;
  31749. blurKernelY: number;
  31750. private _autoComputeBlurKernel();
  31751. protected _onRatioRescale(): void;
  31752. private _updateGammaSpace();
  31753. private _imageProcessingConfigChangeObserver;
  31754. constructor(name: string, size: number | {
  31755. width: number;
  31756. height: number;
  31757. } | {
  31758. ratio: number;
  31759. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  31760. private _preparePostProcesses();
  31761. clone(): MirrorTexture;
  31762. serialize(): any;
  31763. dispose(): void;
  31764. }
  31765. }
  31766. declare module BABYLON {
  31767. interface IMultiRenderTargetOptions {
  31768. generateMipMaps?: boolean;
  31769. types?: number[];
  31770. samplingModes?: number[];
  31771. generateDepthBuffer?: boolean;
  31772. generateStencilBuffer?: boolean;
  31773. generateDepthTexture?: boolean;
  31774. textureCount?: number;
  31775. doNotChangeAspectRatio?: boolean;
  31776. defaultType?: number;
  31777. }
  31778. class MultiRenderTarget extends RenderTargetTexture {
  31779. private _internalTextures;
  31780. private _textures;
  31781. readonly isSupported: boolean;
  31782. private _multiRenderTargetOptions;
  31783. readonly textures: Texture[];
  31784. readonly depthTexture: Texture;
  31785. wrapU: number;
  31786. wrapV: number;
  31787. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  31788. _rebuild(): void;
  31789. private _createInternalTextures();
  31790. private _createTextures();
  31791. samples: number;
  31792. resize(size: any): void;
  31793. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  31794. dispose(): void;
  31795. releaseInternalTextures(): void;
  31796. }
  31797. }
  31798. declare module BABYLON {
  31799. class RawTexture extends Texture {
  31800. format: number;
  31801. private _engine;
  31802. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  31803. update(data: ArrayBufferView): void;
  31804. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  31805. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  31806. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  31807. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  31808. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  31809. }
  31810. }
  31811. declare module BABYLON {
  31812. /**
  31813. * Class used to store 3D textures containing user data
  31814. */
  31815. class RawTexture3D extends Texture {
  31816. /** Gets or sets the texture format to use*/
  31817. format: number;
  31818. private _engine;
  31819. /**
  31820. * Create a new RawTexture3D
  31821. * @param data defines the data of the texture
  31822. * @param width defines the width of the texture
  31823. * @param height defines the height of the texture
  31824. * @param depth defines the depth of the texture
  31825. * @param format defines the texture format to use
  31826. * @param scene defines the hosting scene
  31827. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  31828. * @param invertY defines if texture must be stored with Y axis inverted
  31829. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  31830. */
  31831. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  31832. /** Gets or sets the texture format to use*/
  31833. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number);
  31834. /**
  31835. * Update the texture with new data
  31836. * @param data defines the data to store in the texture
  31837. */
  31838. update(data: ArrayBufferView): void;
  31839. }
  31840. }
  31841. declare module BABYLON {
  31842. /**
  31843. * Creates a refraction texture used by refraction channel of the standard material.
  31844. * @param name the texture name
  31845. * @param size size of the underlying texture
  31846. * @param scene root scene
  31847. */
  31848. class RefractionTexture extends RenderTargetTexture {
  31849. refractionPlane: Plane;
  31850. depth: number;
  31851. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  31852. clone(): RefractionTexture;
  31853. serialize(): any;
  31854. }
  31855. }
  31856. declare module BABYLON {
  31857. class RenderTargetTexture extends Texture {
  31858. isCube: boolean;
  31859. static _REFRESHRATE_RENDER_ONCE: number;
  31860. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  31861. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  31862. static readonly REFRESHRATE_RENDER_ONCE: number;
  31863. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  31864. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  31865. /**
  31866. * Use this predicate to dynamically define the list of mesh you want to render.
  31867. * If set, the renderList property will be overwritten.
  31868. */
  31869. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  31870. /**
  31871. * Use this list to define the list of mesh you want to render.
  31872. */
  31873. renderList: Nullable<Array<AbstractMesh>>;
  31874. renderParticles: boolean;
  31875. renderSprites: boolean;
  31876. coordinatesMode: number;
  31877. activeCamera: Nullable<Camera>;
  31878. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  31879. useCameraPostProcesses: boolean;
  31880. ignoreCameraViewport: boolean;
  31881. private _postProcessManager;
  31882. private _postProcesses;
  31883. private _resizeObserver;
  31884. /**
  31885. * An event triggered when the texture is unbind.
  31886. */
  31887. onBeforeBindObservable: Observable<RenderTargetTexture>;
  31888. /**
  31889. * An event triggered when the texture is unbind.
  31890. */
  31891. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  31892. private _onAfterUnbindObserver;
  31893. onAfterUnbind: () => void;
  31894. /**
  31895. * An event triggered before rendering the texture
  31896. */
  31897. onBeforeRenderObservable: Observable<number>;
  31898. private _onBeforeRenderObserver;
  31899. onBeforeRender: (faceIndex: number) => void;
  31900. /**
  31901. * An event triggered after rendering the texture
  31902. */
  31903. onAfterRenderObservable: Observable<number>;
  31904. private _onAfterRenderObserver;
  31905. onAfterRender: (faceIndex: number) => void;
  31906. /**
  31907. * An event triggered after the texture clear
  31908. */
  31909. onClearObservable: Observable<Engine>;
  31910. private _onClearObserver;
  31911. onClear: (Engine: Engine) => void;
  31912. clearColor: Color4;
  31913. protected _size: number | {
  31914. width: number;
  31915. height: number;
  31916. };
  31917. protected _initialSizeParameter: number | {
  31918. width: number;
  31919. height: number;
  31920. } | {
  31921. ratio: number;
  31922. };
  31923. protected _sizeRatio: Nullable<number>;
  31924. _generateMipMaps: boolean;
  31925. protected _renderingManager: RenderingManager;
  31926. _waitingRenderList: string[];
  31927. protected _doNotChangeAspectRatio: boolean;
  31928. protected _currentRefreshId: number;
  31929. protected _refreshRate: number;
  31930. protected _textureMatrix: Matrix;
  31931. protected _samples: number;
  31932. protected _renderTargetOptions: RenderTargetCreationOptions;
  31933. readonly renderTargetOptions: RenderTargetCreationOptions;
  31934. protected _engine: Engine;
  31935. protected _onRatioRescale(): void;
  31936. /**
  31937. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  31938. * It must define where the camera used to render the texture is set
  31939. */
  31940. boundingBoxPosition: Vector3;
  31941. private _boundingBoxSize;
  31942. /**
  31943. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  31944. * When defined, the cubemap will switch to local mode
  31945. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  31946. * @example https://www.babylonjs-playground.com/#RNASML
  31947. */
  31948. boundingBoxSize: Vector3;
  31949. /**
  31950. * In case the RTT has been created with a depth texture, get the associated
  31951. * depth texture.
  31952. * Otherwise, return null.
  31953. */
  31954. depthStencilTexture: Nullable<InternalTexture>;
  31955. /**
  31956. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  31957. * or used a shadow, depth texture...
  31958. * @param name The friendly name of the texture
  31959. * @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)
  31960. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  31961. * @param generateMipMaps True if mip maps need to be generated after render.
  31962. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  31963. * @param type The type of the buffer in the RTT (int, half float, float...)
  31964. * @param isCube True if a cube texture needs to be created
  31965. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  31966. * @param generateDepthBuffer True to generate a depth buffer
  31967. * @param generateStencilBuffer True to generate a stencil buffer
  31968. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  31969. */
  31970. constructor(name: string, size: number | {
  31971. width: number;
  31972. height: number;
  31973. } | {
  31974. ratio: number;
  31975. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  31976. /**
  31977. * Creates a depth stencil texture.
  31978. * This is only available in WebGL 2 or with the depth texture extension available.
  31979. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  31980. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  31981. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  31982. */
  31983. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  31984. private _processSizeParameter(size);
  31985. samples: number;
  31986. resetRefreshCounter(): void;
  31987. refreshRate: number;
  31988. addPostProcess(postProcess: PostProcess): void;
  31989. clearPostProcesses(dispose?: boolean): void;
  31990. removePostProcess(postProcess: PostProcess): void;
  31991. _shouldRender(): boolean;
  31992. getRenderSize(): number;
  31993. getRenderWidth(): number;
  31994. getRenderHeight(): number;
  31995. readonly canRescale: boolean;
  31996. scale(ratio: number): void;
  31997. getReflectionTextureMatrix(): Matrix;
  31998. resize(size: number | {
  31999. width: number;
  32000. height: number;
  32001. } | {
  32002. ratio: number;
  32003. }): void;
  32004. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  32005. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  32006. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  32007. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  32008. /**
  32009. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  32010. * This allowed control for front to back rendering or reversly depending of the special needs.
  32011. *
  32012. * @param renderingGroupId The rendering group id corresponding to its index
  32013. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  32014. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  32015. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  32016. */
  32017. 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;
  32018. /**
  32019. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  32020. *
  32021. * @param renderingGroupId The rendering group id corresponding to its index
  32022. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  32023. */
  32024. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  32025. clone(): RenderTargetTexture;
  32026. serialize(): any;
  32027. disposeFramebufferObjects(): void;
  32028. dispose(): void;
  32029. _rebuild(): void;
  32030. /**
  32031. * Clear the info related to rendering groups preventing retention point in material dispose.
  32032. */
  32033. freeRenderingGroups(): void;
  32034. }
  32035. }
  32036. declare module BABYLON {
  32037. class Texture extends BaseTexture {
  32038. static NEAREST_SAMPLINGMODE: number;
  32039. static NEAREST_NEAREST_MIPLINEAR: number;
  32040. static BILINEAR_SAMPLINGMODE: number;
  32041. static LINEAR_LINEAR_MIPNEAREST: number;
  32042. static TRILINEAR_SAMPLINGMODE: number;
  32043. static LINEAR_LINEAR_MIPLINEAR: number;
  32044. static NEAREST_NEAREST_MIPNEAREST: number;
  32045. static NEAREST_LINEAR_MIPNEAREST: number;
  32046. static NEAREST_LINEAR_MIPLINEAR: number;
  32047. static NEAREST_LINEAR: number;
  32048. static NEAREST_NEAREST: number;
  32049. static LINEAR_NEAREST_MIPNEAREST: number;
  32050. static LINEAR_NEAREST_MIPLINEAR: number;
  32051. static LINEAR_LINEAR: number;
  32052. static LINEAR_NEAREST: number;
  32053. static EXPLICIT_MODE: number;
  32054. static SPHERICAL_MODE: number;
  32055. static PLANAR_MODE: number;
  32056. static CUBIC_MODE: number;
  32057. static PROJECTION_MODE: number;
  32058. static SKYBOX_MODE: number;
  32059. static INVCUBIC_MODE: number;
  32060. static EQUIRECTANGULAR_MODE: number;
  32061. static FIXED_EQUIRECTANGULAR_MODE: number;
  32062. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32063. static CLAMP_ADDRESSMODE: number;
  32064. static WRAP_ADDRESSMODE: number;
  32065. static MIRROR_ADDRESSMODE: number;
  32066. /**
  32067. * 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
  32068. */
  32069. static UseSerializedUrlIfAny: boolean;
  32070. url: Nullable<string>;
  32071. uOffset: number;
  32072. vOffset: number;
  32073. uScale: number;
  32074. vScale: number;
  32075. uAng: number;
  32076. vAng: number;
  32077. wAng: number;
  32078. readonly noMipmap: boolean;
  32079. private _noMipmap;
  32080. _invertY: boolean;
  32081. private _rowGenerationMatrix;
  32082. private _cachedTextureMatrix;
  32083. private _projectionModeMatrix;
  32084. private _t0;
  32085. private _t1;
  32086. private _t2;
  32087. private _cachedUOffset;
  32088. private _cachedVOffset;
  32089. private _cachedUScale;
  32090. private _cachedVScale;
  32091. private _cachedUAng;
  32092. private _cachedVAng;
  32093. private _cachedWAng;
  32094. private _cachedProjectionMatrixId;
  32095. private _cachedCoordinatesMode;
  32096. _samplingMode: number;
  32097. private _buffer;
  32098. private _deleteBuffer;
  32099. protected _format: Nullable<number>;
  32100. private _delayedOnLoad;
  32101. private _delayedOnError;
  32102. protected _onLoadObservable: Nullable<Observable<Texture>>;
  32103. protected _isBlocking: boolean;
  32104. isBlocking: boolean;
  32105. readonly samplingMode: number;
  32106. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: any, deleteBuffer?: boolean, format?: number);
  32107. updateURL(url: string): void;
  32108. delayLoad(): void;
  32109. updateSamplingMode(samplingMode: number): void;
  32110. private _prepareRowForTextureGeneration(x, y, z, t);
  32111. getTextureMatrix(): Matrix;
  32112. getReflectionTextureMatrix(): Matrix;
  32113. clone(): Texture;
  32114. readonly onLoadObservable: Observable<Texture>;
  32115. serialize(): any;
  32116. getClassName(): string;
  32117. dispose(): void;
  32118. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  32119. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  32120. 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;
  32121. }
  32122. }
  32123. declare module BABYLON {
  32124. /**
  32125. * Settings for finer control over video usage
  32126. */
  32127. interface VideoTextureSettings {
  32128. /**
  32129. * Applies `autoplay` to video, if specified
  32130. */
  32131. autoPlay?: boolean;
  32132. /**
  32133. * Applies `loop` to video, if specified
  32134. */
  32135. loop?: boolean;
  32136. /**
  32137. * Automatically updates internal texture from video at every frame in the render loop
  32138. */
  32139. autoUpdateTexture: boolean;
  32140. }
  32141. class VideoTexture extends Texture {
  32142. /**
  32143. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  32144. */
  32145. readonly autoUpdateTexture: boolean;
  32146. /**
  32147. * The video instance used by the texture internally
  32148. */
  32149. readonly video: HTMLVideoElement;
  32150. private _generateMipMaps;
  32151. private _engine;
  32152. /**
  32153. * Creates a video texture.
  32154. * Sample : https://doc.babylonjs.com/how_to/video_texture
  32155. * @param {string | null} name optional name, will detect from video source, if not defined
  32156. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  32157. * @param {BABYLON.Scene} scene is obviously the current scene.
  32158. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  32159. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  32160. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  32161. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  32162. */
  32163. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  32164. private _getName(src);
  32165. private _getVideo(src);
  32166. private _createInternalTexture;
  32167. private reset;
  32168. /**
  32169. * Internal method to initiate `update`.
  32170. */
  32171. _rebuild(): void;
  32172. /**
  32173. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  32174. */
  32175. update(): void;
  32176. /**
  32177. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  32178. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  32179. */
  32180. updateTexture(isVisible: boolean): void;
  32181. protected _updateInternalTexture: (e?: Event | undefined) => void;
  32182. /**
  32183. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  32184. * @param url New url.
  32185. */
  32186. updateURL(url: string): void;
  32187. dispose(): void;
  32188. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  32189. minWidth: number;
  32190. maxWidth: number;
  32191. minHeight: number;
  32192. maxHeight: number;
  32193. deviceId: string;
  32194. }): void;
  32195. }
  32196. }
  32197. declare module BABYLON {
  32198. /**
  32199. * Particle emitter emitting particles from the inside of a box.
  32200. * It emits the particles randomly between 2 given directions.
  32201. */
  32202. class BoxParticleEmitter implements IParticleEmitterType {
  32203. /**
  32204. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  32205. */
  32206. direction1: Vector3;
  32207. /**
  32208. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  32209. */
  32210. direction2: Vector3;
  32211. /**
  32212. * 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.
  32213. */
  32214. minEmitBox: Vector3;
  32215. /**
  32216. * 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.
  32217. */
  32218. maxEmitBox: Vector3;
  32219. /**
  32220. * Creates a new instance BoxParticleEmitter
  32221. */
  32222. constructor();
  32223. /**
  32224. * Called by the particle System when the direction is computed for the created particle.
  32225. * @param emitPower is the power of the particle (speed)
  32226. * @param worldMatrix is the world matrix of the particle system
  32227. * @param directionToUpdate is the direction vector to update with the result
  32228. * @param particle is the particle we are computed the direction for
  32229. */
  32230. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  32231. /**
  32232. * Called by the particle System when the position is computed for the created particle.
  32233. * @param worldMatrix is the world matrix of the particle system
  32234. * @param positionToUpdate is the position vector to update with the result
  32235. * @param particle is the particle we are computed the position for
  32236. */
  32237. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  32238. /**
  32239. * Clones the current emitter and returns a copy of it
  32240. * @returns the new emitter
  32241. */
  32242. clone(): BoxParticleEmitter;
  32243. /**
  32244. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  32245. * @param effect defines the update shader
  32246. */
  32247. applyToShader(effect: Effect): void;
  32248. /**
  32249. * Returns a string to use to update the GPU particles update shader
  32250. * @returns a string containng the defines string
  32251. */
  32252. getEffectDefines(): string;
  32253. /**
  32254. * Returns the string "BoxEmitter"
  32255. * @returns a string containing the class name
  32256. */
  32257. getClassName(): string;
  32258. /**
  32259. * Serializes the particle system to a JSON object.
  32260. * @returns the JSON object
  32261. */
  32262. serialize(): any;
  32263. /**
  32264. * Parse properties from a JSON object
  32265. * @param serializationObject defines the JSON object
  32266. */
  32267. parse(serializationObject: any): void;
  32268. }
  32269. }
  32270. declare module BABYLON {
  32271. /**
  32272. * Particle emitter emitting particles from the inside of a cone.
  32273. * It emits the particles alongside the cone volume from the base to the particle.
  32274. * The emission direction might be randomized.
  32275. */
  32276. class ConeParticleEmitter implements IParticleEmitterType {
  32277. /**
  32278. * The radius of the emission cone.
  32279. */
  32280. angle: number;
  32281. /**
  32282. * The cone base angle.
  32283. */
  32284. directionRandomizer: number;
  32285. private _radius;
  32286. private _height;
  32287. /**
  32288. * Gets the radius of the emission cone.
  32289. */
  32290. /**
  32291. * Sets the radius of the emission cone.
  32292. */
  32293. radius: number;
  32294. /**
  32295. * Creates a new instance ConeParticleEmitter
  32296. * @param radius the radius of the emission cone (1 by default)
  32297. * @param angles the cone base angle (PI by default)
  32298. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  32299. */
  32300. constructor(radius?: number,
  32301. /**
  32302. * The radius of the emission cone.
  32303. */
  32304. angle?: number,
  32305. /**
  32306. * The cone base angle.
  32307. */
  32308. directionRandomizer?: number);
  32309. /**
  32310. * Called by the particle System when the direction is computed for the created particle.
  32311. * @param emitPower is the power of the particle (speed)
  32312. * @param worldMatrix is the world matrix of the particle system
  32313. * @param directionToUpdate is the direction vector to update with the result
  32314. * @param particle is the particle we are computed the direction for
  32315. */
  32316. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  32317. /**
  32318. * Called by the particle System when the position is computed for the created particle.
  32319. * @param worldMatrix is the world matrix of the particle system
  32320. * @param positionToUpdate is the position vector to update with the result
  32321. * @param particle is the particle we are computed the position for
  32322. */
  32323. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  32324. /**
  32325. * Clones the current emitter and returns a copy of it
  32326. * @returns the new emitter
  32327. */
  32328. clone(): ConeParticleEmitter;
  32329. /**
  32330. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  32331. * @param effect defines the update shader
  32332. */
  32333. applyToShader(effect: Effect): void;
  32334. /**
  32335. * Returns a string to use to update the GPU particles update shader
  32336. * @returns a string containng the defines string
  32337. */
  32338. getEffectDefines(): string;
  32339. /**
  32340. * Returns the string "BoxEmitter"
  32341. * @returns a string containing the class name
  32342. */
  32343. getClassName(): string;
  32344. /**
  32345. * Serializes the particle system to a JSON object.
  32346. * @returns the JSON object
  32347. */
  32348. serialize(): any;
  32349. /**
  32350. * Parse properties from a JSON object
  32351. * @param serializationObject defines the JSON object
  32352. */
  32353. parse(serializationObject: any): void;
  32354. }
  32355. }
  32356. declare module BABYLON {
  32357. /**
  32358. * Particle emitter represents a volume emitting particles.
  32359. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  32360. */
  32361. interface IParticleEmitterType {
  32362. /**
  32363. * Called by the particle System when the direction is computed for the created particle.
  32364. * @param emitPower is the power of the particle (speed)
  32365. * @param worldMatrix is the world matrix of the particle system
  32366. * @param directionToUpdate is the direction vector to update with the result
  32367. * @param particle is the particle we are computed the direction for
  32368. */
  32369. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  32370. /**
  32371. * Called by the particle System when the position is computed for the created particle.
  32372. * @param worldMatrix is the world matrix of the particle system
  32373. * @param positionToUpdate is the position vector to update with the result
  32374. * @param particle is the particle we are computed the position for
  32375. */
  32376. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  32377. /**
  32378. * Clones the current emitter and returns a copy of it
  32379. * @returns the new emitter
  32380. */
  32381. clone(): IParticleEmitterType;
  32382. /**
  32383. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  32384. * @param effect defines the update shader
  32385. */
  32386. applyToShader(effect: Effect): void;
  32387. /**
  32388. * Returns a string to use to update the GPU particles update shader
  32389. * @returns the effect defines string
  32390. */
  32391. getEffectDefines(): string;
  32392. /**
  32393. * Returns a string representing the class name
  32394. * @returns a string containing the class name
  32395. */
  32396. getClassName(): string;
  32397. /**
  32398. * Serializes the particle system to a JSON object.
  32399. * @returns the JSON object
  32400. */
  32401. serialize(): any;
  32402. /**
  32403. * Parse properties from a JSON object
  32404. * @param serializationObject defines the JSON object
  32405. */
  32406. parse(serializationObject: any): void;
  32407. }
  32408. }
  32409. declare module BABYLON {
  32410. /**
  32411. * Particle emitter emitting particles from the inside of a sphere.
  32412. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  32413. */
  32414. class SphereParticleEmitter implements IParticleEmitterType {
  32415. /**
  32416. * The radius of the emission sphere.
  32417. */
  32418. radius: number;
  32419. /**
  32420. * How much to randomize the particle direction [0-1].
  32421. */
  32422. directionRandomizer: number;
  32423. /**
  32424. * Creates a new instance SphereParticleEmitter
  32425. * @param radius the radius of the emission sphere (1 by default)
  32426. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  32427. */
  32428. constructor(
  32429. /**
  32430. * The radius of the emission sphere.
  32431. */
  32432. radius?: number,
  32433. /**
  32434. * How much to randomize the particle direction [0-1].
  32435. */
  32436. directionRandomizer?: number);
  32437. /**
  32438. * Called by the particle System when the direction is computed for the created particle.
  32439. * @param emitPower is the power of the particle (speed)
  32440. * @param worldMatrix is the world matrix of the particle system
  32441. * @param directionToUpdate is the direction vector to update with the result
  32442. * @param particle is the particle we are computed the direction for
  32443. */
  32444. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  32445. /**
  32446. * Called by the particle System when the position is computed for the created particle.
  32447. * @param worldMatrix is the world matrix of the particle system
  32448. * @param positionToUpdate is the position vector to update with the result
  32449. * @param particle is the particle we are computed the position for
  32450. */
  32451. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  32452. /**
  32453. * Clones the current emitter and returns a copy of it
  32454. * @returns the new emitter
  32455. */
  32456. clone(): SphereParticleEmitter;
  32457. /**
  32458. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  32459. * @param effect defines the update shader
  32460. */
  32461. applyToShader(effect: Effect): void;
  32462. /**
  32463. * Returns a string to use to update the GPU particles update shader
  32464. * @returns a string containng the defines string
  32465. */
  32466. getEffectDefines(): string;
  32467. /**
  32468. * Returns the string "SphereParticleEmitter"
  32469. * @returns a string containing the class name
  32470. */
  32471. getClassName(): string;
  32472. /**
  32473. * Serializes the particle system to a JSON object.
  32474. * @returns the JSON object
  32475. */
  32476. serialize(): any;
  32477. /**
  32478. * Parse properties from a JSON object
  32479. * @param serializationObject defines the JSON object
  32480. */
  32481. parse(serializationObject: any): void;
  32482. }
  32483. /**
  32484. * Particle emitter emitting particles from the inside of a sphere.
  32485. * It emits the particles randomly between two vectors.
  32486. */
  32487. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  32488. /**
  32489. * The min limit of the emission direction.
  32490. */
  32491. direction1: Vector3;
  32492. /**
  32493. * The max limit of the emission direction.
  32494. */
  32495. direction2: Vector3;
  32496. /**
  32497. * Creates a new instance SphereDirectedParticleEmitter
  32498. * @param radius the radius of the emission sphere (1 by default)
  32499. * @param direction1 the min limit of the emission direction (up vector by default)
  32500. * @param direction2 the max limit of the emission direction (up vector by default)
  32501. */
  32502. constructor(radius?: number,
  32503. /**
  32504. * The min limit of the emission direction.
  32505. */
  32506. direction1?: Vector3,
  32507. /**
  32508. * The max limit of the emission direction.
  32509. */
  32510. direction2?: Vector3);
  32511. /**
  32512. * Called by the particle System when the direction is computed for the created particle.
  32513. * @param emitPower is the power of the particle (speed)
  32514. * @param worldMatrix is the world matrix of the particle system
  32515. * @param directionToUpdate is the direction vector to update with the result
  32516. * @param particle is the particle we are computed the direction for
  32517. */
  32518. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  32519. /**
  32520. * Clones the current emitter and returns a copy of it
  32521. * @returns the new emitter
  32522. */
  32523. clone(): SphereDirectedParticleEmitter;
  32524. /**
  32525. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  32526. * @param effect defines the update shader
  32527. */
  32528. applyToShader(effect: Effect): void;
  32529. /**
  32530. * Returns a string to use to update the GPU particles update shader
  32531. * @returns a string containng the defines string
  32532. */
  32533. getEffectDefines(): string;
  32534. /**
  32535. * Returns the string "SphereDirectedParticleEmitter"
  32536. * @returns a string containing the class name
  32537. */
  32538. getClassName(): string;
  32539. /**
  32540. * Serializes the particle system to a JSON object.
  32541. * @returns the JSON object
  32542. */
  32543. serialize(): any;
  32544. /**
  32545. * Parse properties from a JSON object
  32546. * @param serializationObject defines the JSON object
  32547. */
  32548. parse(serializationObject: any): void;
  32549. }
  32550. }
  32551. declare module BABYLON {
  32552. class CannonJSPlugin implements IPhysicsEnginePlugin {
  32553. private _useDeltaForWorldStep;
  32554. world: any;
  32555. name: string;
  32556. private _physicsMaterials;
  32557. private _fixedTimeStep;
  32558. BJSCANNON: any;
  32559. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  32560. setGravity(gravity: Vector3): void;
  32561. setTimeStep(timeStep: number): void;
  32562. getTimeStep(): number;
  32563. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32564. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32565. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32566. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32567. private _processChildMeshes(mainImpostor);
  32568. removePhysicsBody(impostor: PhysicsImpostor): void;
  32569. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  32570. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  32571. private _addMaterial(name, friction, restitution);
  32572. private _checkWithEpsilon(value);
  32573. private _createShape(impostor);
  32574. private _createHeightmap(object, pointDepth?);
  32575. private _minus90X;
  32576. private _plus90X;
  32577. private _tmpPosition;
  32578. private _tmpDeltaPosition;
  32579. private _tmpUnityRotation;
  32580. private _updatePhysicsBodyTransformation(impostor);
  32581. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32582. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32583. isSupported(): boolean;
  32584. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  32585. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  32586. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32587. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32588. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32589. getBodyMass(impostor: PhysicsImpostor): number;
  32590. getBodyFriction(impostor: PhysicsImpostor): number;
  32591. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32592. getBodyRestitution(impostor: PhysicsImpostor): number;
  32593. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32594. sleepBody(impostor: PhysicsImpostor): void;
  32595. wakeUpBody(impostor: PhysicsImpostor): void;
  32596. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32597. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  32598. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  32599. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32600. getRadius(impostor: PhysicsImpostor): number;
  32601. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32602. dispose(): void;
  32603. private _extendNamespace();
  32604. }
  32605. }
  32606. declare module BABYLON {
  32607. class OimoJSPlugin implements IPhysicsEnginePlugin {
  32608. world: any;
  32609. name: string;
  32610. BJSOIMO: any;
  32611. constructor(iterations?: number);
  32612. setGravity(gravity: Vector3): void;
  32613. setTimeStep(timeStep: number): void;
  32614. getTimeStep(): number;
  32615. private _tmpImpostorsArray;
  32616. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32617. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32618. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32619. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32620. private _tmpPositionVector;
  32621. removePhysicsBody(impostor: PhysicsImpostor): void;
  32622. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  32623. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  32624. isSupported(): boolean;
  32625. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32626. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32627. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  32628. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  32629. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32630. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32631. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32632. getBodyMass(impostor: PhysicsImpostor): number;
  32633. getBodyFriction(impostor: PhysicsImpostor): number;
  32634. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32635. getBodyRestitution(impostor: PhysicsImpostor): number;
  32636. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32637. sleepBody(impostor: PhysicsImpostor): void;
  32638. wakeUpBody(impostor: PhysicsImpostor): void;
  32639. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32640. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32641. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32642. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32643. getRadius(impostor: PhysicsImpostor): number;
  32644. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32645. dispose(): void;
  32646. }
  32647. }
  32648. declare var DracoDecoderModule: any;
  32649. declare var WebAssembly: any;
  32650. declare module BABYLON {
  32651. /**
  32652. * Configuration for Draco compression
  32653. */
  32654. interface IDracoCompressionConfiguration {
  32655. /**
  32656. * Configuration for the decoder.
  32657. */
  32658. decoder?: {
  32659. /**
  32660. * The url to the WebAssembly module.
  32661. */
  32662. wasmUrl?: string;
  32663. /**
  32664. * The url to the WebAssembly binary.
  32665. */
  32666. wasmBinaryUrl?: string;
  32667. /**
  32668. * The url to the fallback JavaScript module.
  32669. */
  32670. fallbackUrl?: string;
  32671. };
  32672. }
  32673. /**
  32674. * Draco compression (https://google.github.io/draco/)
  32675. */
  32676. class DracoCompression implements IDisposable {
  32677. private static _DecoderModulePromise;
  32678. /**
  32679. * The configuration.
  32680. */
  32681. static Configuration: IDracoCompressionConfiguration;
  32682. /**
  32683. * Returns true if the decoder is available.
  32684. */
  32685. static readonly DecoderAvailable: boolean;
  32686. /**
  32687. * Constructor
  32688. */
  32689. constructor();
  32690. /**
  32691. * Stop all async operations and release resources.
  32692. */
  32693. dispose(): void;
  32694. /**
  32695. * Decode Draco compressed mesh data to vertex data.
  32696. * @param data The array buffer view for the Draco compression data
  32697. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  32698. * @returns A promise that resolves with the decoded vertex data
  32699. */
  32700. decodeMeshAsync(data: ArrayBufferView, attributes: {
  32701. [kind: string]: number;
  32702. }): Promise<VertexData>;
  32703. private static _GetDecoderModule();
  32704. private static _LoadScriptAsync(url);
  32705. private static _LoadFileAsync(url);
  32706. }
  32707. }
  32708. declare module BABYLON {
  32709. /**
  32710. * This represents a set of one or more post processes in Babylon.
  32711. * A post process can be used to apply a shader to a texture after it is rendered.
  32712. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  32713. */
  32714. class PostProcessRenderEffect {
  32715. private _postProcesses;
  32716. private _getPostProcesses;
  32717. private _singleInstance;
  32718. private _cameras;
  32719. private _indicesForCamera;
  32720. /**
  32721. * Name of the effect
  32722. */
  32723. _name: string;
  32724. /**
  32725. * Instantiates a post process render effect.
  32726. * A post process can be used to apply a shader to a texture after it is rendered.
  32727. * @param engine The engine the effect is tied to
  32728. * @param name The name of the effect
  32729. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  32730. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  32731. */
  32732. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  32733. /**
  32734. * Checks if all the post processes in the effect are supported.
  32735. */
  32736. readonly isSupported: boolean;
  32737. /**
  32738. * Updates the current state of the effect
  32739. */
  32740. _update(): void;
  32741. /**
  32742. * Attaches the effect on cameras
  32743. * @param cameras The camera to attach to.
  32744. */
  32745. _attachCameras(cameras: Camera): void;
  32746. /**
  32747. * Attaches the effect on cameras
  32748. * @param cameras The camera to attach to.
  32749. */
  32750. _attachCameras(cameras: Camera[]): void;
  32751. /**
  32752. * Detatches the effect on cameras
  32753. * @param cameras The camera to detatch from.
  32754. */
  32755. _detachCameras(cameras: Camera): void;
  32756. /**
  32757. * Detatches the effect on cameras
  32758. * @param cameras The camera to detatch from.
  32759. */
  32760. _detachCameras(cameras: Camera[]): void;
  32761. /**
  32762. * Enables the effect on given cameras
  32763. * @param cameras The camera to enable.
  32764. */
  32765. _enable(cameras: Camera): void;
  32766. /**
  32767. * Enables the effect on given cameras
  32768. * @param cameras The camera to enable.
  32769. */
  32770. _enable(cameras: Nullable<Camera[]>): void;
  32771. /**
  32772. * Disables the effect on the given cameras
  32773. * @param cameras The camera to disable.
  32774. */
  32775. _disable(cameras: Camera): void;
  32776. /**
  32777. * Disables the effect on the given cameras
  32778. * @param cameras The camera to disable.
  32779. */
  32780. _disable(cameras: Nullable<Camera[]>): void;
  32781. /**
  32782. * Gets a list of the post processes contained in the effect.
  32783. * @param camera The camera to get the post processes on.
  32784. * @returns The list of the post processes in the effect.
  32785. */
  32786. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  32787. }
  32788. }
  32789. declare module BABYLON {
  32790. class PostProcessRenderPipeline {
  32791. private engine;
  32792. private _renderEffects;
  32793. private _renderEffectsForIsolatedPass;
  32794. protected _cameras: Camera[];
  32795. _name: string;
  32796. constructor(engine: Engine, name: string);
  32797. getClassName(): string;
  32798. readonly isSupported: boolean;
  32799. addEffect(renderEffect: PostProcessRenderEffect): void;
  32800. _rebuild(): void;
  32801. _enableEffect(renderEffectName: string, cameras: Camera): void;
  32802. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  32803. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  32804. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  32805. _attachCameras(cameras: Camera, unique: boolean): void;
  32806. _attachCameras(cameras: Camera[], unique: boolean): void;
  32807. _detachCameras(cameras: Camera): void;
  32808. _detachCameras(cameras: Nullable<Camera[]>): void;
  32809. _update(): void;
  32810. _reset(): void;
  32811. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  32812. dispose(): void;
  32813. }
  32814. }
  32815. declare module BABYLON {
  32816. class PostProcessRenderPipelineManager {
  32817. private _renderPipelines;
  32818. constructor();
  32819. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  32820. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  32821. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  32822. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  32823. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  32824. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  32825. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  32826. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  32827. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  32828. update(): void;
  32829. _rebuild(): void;
  32830. dispose(): void;
  32831. }
  32832. }
  32833. declare module BABYLON {
  32834. /**
  32835. * Helper class dealing with the extraction of spherical polynomial dataArray
  32836. * from a cube map.
  32837. */
  32838. class CubeMapToSphericalPolynomialTools {
  32839. private static FileFaces;
  32840. /**
  32841. * Converts a texture to the according Spherical Polynomial data.
  32842. * This extracts the first 3 orders only as they are the only one used in the lighting.
  32843. *
  32844. * @param texture The texture to extract the information from.
  32845. * @return The Spherical Polynomial data.
  32846. */
  32847. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  32848. /**
  32849. * Converts a cubemap to the according Spherical Polynomial data.
  32850. * This extracts the first 3 orders only as they are the only one used in the lighting.
  32851. *
  32852. * @param cubeInfo The Cube map to extract the information from.
  32853. * @return The Spherical Polynomial data.
  32854. */
  32855. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  32856. }
  32857. }
  32858. declare module BABYLON {
  32859. /**
  32860. * Header information of HDR texture files.
  32861. */
  32862. interface HDRInfo {
  32863. /**
  32864. * The height of the texture in pixels.
  32865. */
  32866. height: number;
  32867. /**
  32868. * The width of the texture in pixels.
  32869. */
  32870. width: number;
  32871. /**
  32872. * The index of the beginning of the data in the binary file.
  32873. */
  32874. dataPosition: number;
  32875. }
  32876. /**
  32877. * This groups tools to convert HDR texture to native colors array.
  32878. */
  32879. class HDRTools {
  32880. private static Ldexp(mantissa, exponent);
  32881. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  32882. private static readStringLine(uint8array, startIndex);
  32883. /**
  32884. * Reads header information from an RGBE texture stored in a native array.
  32885. * More information on this format are available here:
  32886. * https://en.wikipedia.org/wiki/RGBE_image_format
  32887. *
  32888. * @param uint8array The binary file stored in native array.
  32889. * @return The header information.
  32890. */
  32891. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  32892. /**
  32893. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  32894. * This RGBE texture needs to store the information as a panorama.
  32895. *
  32896. * More information on this format are available here:
  32897. * https://en.wikipedia.org/wiki/RGBE_image_format
  32898. *
  32899. * @param buffer The binary file stored in an array buffer.
  32900. * @param size The expected size of the extracted cubemap.
  32901. * @return The Cube Map information.
  32902. */
  32903. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  32904. /**
  32905. * Returns the pixels data extracted from an RGBE texture.
  32906. * This pixels will be stored left to right up to down in the R G B order in one array.
  32907. *
  32908. * More information on this format are available here:
  32909. * https://en.wikipedia.org/wiki/RGBE_image_format
  32910. *
  32911. * @param uint8array The binary file stored in an array buffer.
  32912. * @param hdrInfo The header information of the file.
  32913. * @return The pixels data in RGB right to left up to down order.
  32914. */
  32915. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  32916. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  32917. }
  32918. }
  32919. declare module BABYLON {
  32920. /**
  32921. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  32922. */
  32923. interface CubeMapInfo {
  32924. /**
  32925. * The pixel array for the front face.
  32926. * This is stored in format, left to right, up to down format.
  32927. */
  32928. front: Nullable<ArrayBufferView>;
  32929. /**
  32930. * The pixel array for the back face.
  32931. * This is stored in format, left to right, up to down format.
  32932. */
  32933. back: Nullable<ArrayBufferView>;
  32934. /**
  32935. * The pixel array for the left face.
  32936. * This is stored in format, left to right, up to down format.
  32937. */
  32938. left: Nullable<ArrayBufferView>;
  32939. /**
  32940. * The pixel array for the right face.
  32941. * This is stored in format, left to right, up to down format.
  32942. */
  32943. right: Nullable<ArrayBufferView>;
  32944. /**
  32945. * The pixel array for the up face.
  32946. * This is stored in format, left to right, up to down format.
  32947. */
  32948. up: Nullable<ArrayBufferView>;
  32949. /**
  32950. * The pixel array for the down face.
  32951. * This is stored in format, left to right, up to down format.
  32952. */
  32953. down: Nullable<ArrayBufferView>;
  32954. /**
  32955. * The size of the cubemap stored.
  32956. *
  32957. * Each faces will be size * size pixels.
  32958. */
  32959. size: number;
  32960. /**
  32961. * The format of the texture.
  32962. *
  32963. * RGBA, RGB.
  32964. */
  32965. format: number;
  32966. /**
  32967. * The type of the texture data.
  32968. *
  32969. * UNSIGNED_INT, FLOAT.
  32970. */
  32971. type: number;
  32972. /**
  32973. * Specifies whether the texture is in gamma space.
  32974. */
  32975. gammaSpace: boolean;
  32976. }
  32977. /**
  32978. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  32979. */
  32980. class PanoramaToCubeMapTools {
  32981. private static FACE_FRONT;
  32982. private static FACE_BACK;
  32983. private static FACE_RIGHT;
  32984. private static FACE_LEFT;
  32985. private static FACE_DOWN;
  32986. private static FACE_UP;
  32987. /**
  32988. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  32989. *
  32990. * @param float32Array The source data.
  32991. * @param inputWidth The width of the input panorama.
  32992. * @param inputhHeight The height of the input panorama.
  32993. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  32994. * @return The cubemap data
  32995. */
  32996. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  32997. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  32998. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  32999. }
  33000. }
  33001. declare module BABYLON {
  33002. class CustomProceduralTexture extends ProceduralTexture {
  33003. private _animate;
  33004. private _time;
  33005. private _config;
  33006. private _texturePath;
  33007. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  33008. private loadJson(jsonUrl);
  33009. isReady(): boolean;
  33010. render(useCameraPostProcess?: boolean): void;
  33011. updateTextures(): void;
  33012. updateShaderUniforms(): void;
  33013. animate: boolean;
  33014. }
  33015. }
  33016. declare module BABYLON {
  33017. class ProceduralTexture extends Texture {
  33018. isCube: boolean;
  33019. private _size;
  33020. _generateMipMaps: boolean;
  33021. isEnabled: boolean;
  33022. private _currentRefreshId;
  33023. private _refreshRate;
  33024. onGenerated: () => void;
  33025. private _vertexBuffers;
  33026. private _indexBuffer;
  33027. private _effect;
  33028. private _uniforms;
  33029. private _samplers;
  33030. private _fragment;
  33031. _textures: {
  33032. [key: string]: Texture;
  33033. };
  33034. private _floats;
  33035. private _floatsArrays;
  33036. private _colors3;
  33037. private _colors4;
  33038. private _vectors2;
  33039. private _vectors3;
  33040. private _matrices;
  33041. private _fallbackTexture;
  33042. private _fallbackTextureUsed;
  33043. private _engine;
  33044. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  33045. private _createIndexBuffer();
  33046. _rebuild(): void;
  33047. reset(): void;
  33048. isReady(): boolean;
  33049. resetRefreshCounter(): void;
  33050. setFragment(fragment: any): void;
  33051. refreshRate: number;
  33052. _shouldRender(): boolean;
  33053. getRenderSize(): number;
  33054. resize(size: number, generateMipMaps: boolean): void;
  33055. private _checkUniform(uniformName);
  33056. setTexture(name: string, texture: Texture): ProceduralTexture;
  33057. setFloat(name: string, value: number): ProceduralTexture;
  33058. setFloats(name: string, value: number[]): ProceduralTexture;
  33059. setColor3(name: string, value: Color3): ProceduralTexture;
  33060. setColor4(name: string, value: Color4): ProceduralTexture;
  33061. setVector2(name: string, value: Vector2): ProceduralTexture;
  33062. setVector3(name: string, value: Vector3): ProceduralTexture;
  33063. setMatrix(name: string, value: Matrix): ProceduralTexture;
  33064. render(useCameraPostProcess?: boolean): void;
  33065. clone(): ProceduralTexture;
  33066. dispose(): void;
  33067. }
  33068. }
  33069. declare module BABYLON {
  33070. /**
  33071. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  33072. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  33073. */
  33074. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  33075. private _scene;
  33076. private _originalCameras;
  33077. /**
  33078. * ID of the sharpen post process,
  33079. */
  33080. private readonly SharpenPostProcessId;
  33081. /**
  33082. * ID of the image processing post process;
  33083. */
  33084. readonly ImageProcessingPostProcessId: string;
  33085. /**
  33086. * ID of the Fast Approximate Anti-Aliasing post process;
  33087. */
  33088. readonly FxaaPostProcessId: string;
  33089. /**
  33090. * ID of the chromatic aberration post process,
  33091. */
  33092. private readonly ChromaticAberrationPostProcessId;
  33093. /**
  33094. * ID of the grain post process
  33095. */
  33096. private readonly GrainPostProcessId;
  33097. /**
  33098. * Sharpen post process which will apply a sharpen convolution to enhance edges
  33099. */
  33100. sharpen: SharpenPostProcess;
  33101. private _sharpenEffect;
  33102. private bloom;
  33103. /**
  33104. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  33105. */
  33106. depthOfField: DepthOfFieldEffect;
  33107. /**
  33108. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  33109. */
  33110. fxaa: FxaaPostProcess;
  33111. /**
  33112. * Image post processing pass used to perform operations such as tone mapping or color grading.
  33113. */
  33114. imageProcessing: ImageProcessingPostProcess;
  33115. /**
  33116. * Chromatic aberration post process which will shift rgb colors in the image
  33117. */
  33118. chromaticAberration: ChromaticAberrationPostProcess;
  33119. private _chromaticAberrationEffect;
  33120. /**
  33121. * Grain post process which add noise to the image
  33122. */
  33123. grain: GrainPostProcess;
  33124. private _grainEffect;
  33125. /**
  33126. * Animations which can be used to tweak settings over a period of time
  33127. */
  33128. animations: Animation[];
  33129. private _imageProcessingConfigurationObserver;
  33130. private _sharpenEnabled;
  33131. private _bloomEnabled;
  33132. private _depthOfFieldEnabled;
  33133. private _depthOfFieldBlurLevel;
  33134. private _fxaaEnabled;
  33135. private _imageProcessingEnabled;
  33136. private _defaultPipelineTextureType;
  33137. private _bloomScale;
  33138. private _chromaticAberrationEnabled;
  33139. private _grainEnabled;
  33140. private _buildAllowed;
  33141. /**
  33142. * Enable or disable the sharpen process from the pipeline
  33143. */
  33144. sharpenEnabled: boolean;
  33145. private _resizeObserver;
  33146. private _hardwareScaleLevel;
  33147. private _bloomKernel;
  33148. /**
  33149. * Specifies the size of the bloom blur kernel, relative to the final output size
  33150. */
  33151. bloomKernel: number;
  33152. /**
  33153. * Specifies the weight of the bloom in the final rendering
  33154. */
  33155. private _bloomWeight;
  33156. /**
  33157. * Specifies the luma threshold for the area that will be blurred by the bloom
  33158. */
  33159. private _bloomThreshold;
  33160. private _hdr;
  33161. /**
  33162. * The strength of the bloom.
  33163. */
  33164. bloomWeight: number;
  33165. /**
  33166. * The strength of the bloom.
  33167. */
  33168. bloomThreshold: number;
  33169. /**
  33170. * The scale of the bloom, lower value will provide better performance.
  33171. */
  33172. bloomScale: number;
  33173. /**
  33174. * Enable or disable the bloom from the pipeline
  33175. */
  33176. bloomEnabled: boolean;
  33177. private _rebuildBloom();
  33178. /**
  33179. * If the depth of field is enabled.
  33180. */
  33181. depthOfFieldEnabled: boolean;
  33182. /**
  33183. * Blur level of the depth of field effect. (Higher blur will effect performance)
  33184. */
  33185. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  33186. /**
  33187. * If the anti aliasing is enabled.
  33188. */
  33189. fxaaEnabled: boolean;
  33190. private _samples;
  33191. /**
  33192. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  33193. */
  33194. samples: number;
  33195. /**
  33196. * If image processing is enabled.
  33197. */
  33198. imageProcessingEnabled: boolean;
  33199. /**
  33200. * Enable or disable the chromaticAberration process from the pipeline
  33201. */
  33202. chromaticAberrationEnabled: boolean;
  33203. /**
  33204. * Enable or disable the grain process from the pipeline
  33205. */
  33206. grainEnabled: boolean;
  33207. /**
  33208. * @constructor
  33209. * @param {string} name - The rendering pipeline name
  33210. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  33211. * @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)
  33212. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  33213. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline
  33214. */
  33215. constructor(name: string, hdr: boolean, scene: Scene, cameras?: Camera[], automaticBuild?: boolean);
  33216. /**
  33217. * Force the compilation of the entire pipeline.
  33218. */
  33219. prepare(): void;
  33220. private _hasCleared;
  33221. private _prevPostProcess;
  33222. private _prevPrevPostProcess;
  33223. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  33224. private _buildPipeline();
  33225. private _disposePostProcesses(disposeNonRecreated?);
  33226. /**
  33227. * Dispose of the pipeline and stop all post processes
  33228. */
  33229. dispose(): void;
  33230. /**
  33231. * Serialize the rendering pipeline (Used when exporting)
  33232. * @returns the serialized object
  33233. */
  33234. serialize(): any;
  33235. /**
  33236. * Parse the serialized pipeline
  33237. * @param source Source pipeline.
  33238. * @param scene The scene to load the pipeline to.
  33239. * @param rootUrl The URL of the serialized pipeline.
  33240. * @returns An instantiated pipeline from the serialized object.
  33241. */
  33242. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  33243. }
  33244. }
  33245. declare module BABYLON {
  33246. class LensRenderingPipeline extends PostProcessRenderPipeline {
  33247. /**
  33248. * The chromatic aberration PostProcess id in the pipeline
  33249. */
  33250. LensChromaticAberrationEffect: string;
  33251. /**
  33252. * The highlights enhancing PostProcess id in the pipeline
  33253. */
  33254. HighlightsEnhancingEffect: string;
  33255. /**
  33256. * The depth-of-field PostProcess id in the pipeline
  33257. */
  33258. LensDepthOfFieldEffect: string;
  33259. private _scene;
  33260. private _depthTexture;
  33261. private _grainTexture;
  33262. private _chromaticAberrationPostProcess;
  33263. private _highlightsPostProcess;
  33264. private _depthOfFieldPostProcess;
  33265. private _edgeBlur;
  33266. private _grainAmount;
  33267. private _chromaticAberration;
  33268. private _distortion;
  33269. private _highlightsGain;
  33270. private _highlightsThreshold;
  33271. private _dofDistance;
  33272. private _dofAperture;
  33273. private _dofDarken;
  33274. private _dofPentagon;
  33275. private _blurNoise;
  33276. /**
  33277. * @constructor
  33278. *
  33279. * Effect parameters are as follow:
  33280. * {
  33281. * chromatic_aberration: number; // from 0 to x (1 for realism)
  33282. * edge_blur: number; // from 0 to x (1 for realism)
  33283. * distortion: number; // from 0 to x (1 for realism)
  33284. * grain_amount: number; // from 0 to 1
  33285. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  33286. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  33287. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  33288. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  33289. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  33290. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  33291. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  33292. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  33293. * }
  33294. * Note: if an effect parameter is unset, effect is disabled
  33295. *
  33296. * @param {string} name - The rendering pipeline name
  33297. * @param {object} parameters - An object containing all parameters (see above)
  33298. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  33299. * @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)
  33300. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  33301. */
  33302. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  33303. setEdgeBlur(amount: number): void;
  33304. disableEdgeBlur(): void;
  33305. setGrainAmount(amount: number): void;
  33306. disableGrain(): void;
  33307. setChromaticAberration(amount: number): void;
  33308. disableChromaticAberration(): void;
  33309. setEdgeDistortion(amount: number): void;
  33310. disableEdgeDistortion(): void;
  33311. setFocusDistance(amount: number): void;
  33312. disableDepthOfField(): void;
  33313. setAperture(amount: number): void;
  33314. setDarkenOutOfFocus(amount: number): void;
  33315. enablePentagonBokeh(): void;
  33316. disablePentagonBokeh(): void;
  33317. enableNoiseBlur(): void;
  33318. disableNoiseBlur(): void;
  33319. setHighlightsGain(amount: number): void;
  33320. setHighlightsThreshold(amount: number): void;
  33321. disableHighlights(): void;
  33322. /**
  33323. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  33324. */
  33325. dispose(disableDepthRender?: boolean): void;
  33326. private _createChromaticAberrationPostProcess(ratio);
  33327. private _createHighlightsPostProcess(ratio);
  33328. private _createDepthOfFieldPostProcess(ratio);
  33329. private _createGrainTexture();
  33330. }
  33331. }
  33332. declare module BABYLON {
  33333. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  33334. /**
  33335. * The PassPostProcess id in the pipeline that contains the original scene color
  33336. */
  33337. SSAOOriginalSceneColorEffect: string;
  33338. /**
  33339. * The SSAO PostProcess id in the pipeline
  33340. */
  33341. SSAORenderEffect: string;
  33342. /**
  33343. * The horizontal blur PostProcess id in the pipeline
  33344. */
  33345. SSAOBlurHRenderEffect: string;
  33346. /**
  33347. * The vertical blur PostProcess id in the pipeline
  33348. */
  33349. SSAOBlurVRenderEffect: string;
  33350. /**
  33351. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  33352. */
  33353. SSAOCombineRenderEffect: string;
  33354. /**
  33355. * The output strength of the SSAO post-process. Default value is 1.0.
  33356. */
  33357. totalStrength: number;
  33358. /**
  33359. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  33360. */
  33361. maxZ: number;
  33362. /**
  33363. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  33364. */
  33365. minZAspect: number;
  33366. /**
  33367. * Number of samples used for the SSAO calculations. Default value is 8
  33368. */
  33369. private _samples;
  33370. /**
  33371. * Dynamically generated sphere sampler.
  33372. */
  33373. private _sampleSphere;
  33374. /**
  33375. * Blur filter offsets
  33376. */
  33377. private _samplerOffsets;
  33378. samples: number;
  33379. /**
  33380. * Are we using bilateral blur ?
  33381. */
  33382. private _expensiveBlur;
  33383. expensiveBlur: boolean;
  33384. /**
  33385. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  33386. */
  33387. radius: number;
  33388. /**
  33389. * The base color of the SSAO post-process
  33390. * The final result is "base + ssao" between [0, 1]
  33391. */
  33392. base: number;
  33393. /**
  33394. * Support test.
  33395. */
  33396. static readonly IsSupported: boolean;
  33397. private _scene;
  33398. private _depthTexture;
  33399. private _normalTexture;
  33400. private _randomTexture;
  33401. private _originalColorPostProcess;
  33402. private _ssaoPostProcess;
  33403. private _blurHPostProcess;
  33404. private _blurVPostProcess;
  33405. private _ssaoCombinePostProcess;
  33406. private _firstUpdate;
  33407. /**
  33408. * @constructor
  33409. * @param {string} name - The rendering pipeline name
  33410. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  33411. * @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 }
  33412. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  33413. */
  33414. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  33415. /**
  33416. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  33417. */
  33418. dispose(disableGeometryBufferRenderer?: boolean): void;
  33419. private _createBlurPostProcess(ssaoRatio, blurRatio);
  33420. _rebuild(): void;
  33421. private _generateHemisphere();
  33422. private _createSSAOPostProcess(ratio);
  33423. private _createSSAOCombinePostProcess(ratio);
  33424. private _createRandomTexture();
  33425. }
  33426. }
  33427. declare module BABYLON {
  33428. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  33429. /**
  33430. * The PassPostProcess id in the pipeline that contains the original scene color
  33431. */
  33432. SSAOOriginalSceneColorEffect: string;
  33433. /**
  33434. * The SSAO PostProcess id in the pipeline
  33435. */
  33436. SSAORenderEffect: string;
  33437. /**
  33438. * The horizontal blur PostProcess id in the pipeline
  33439. */
  33440. SSAOBlurHRenderEffect: string;
  33441. /**
  33442. * The vertical blur PostProcess id in the pipeline
  33443. */
  33444. SSAOBlurVRenderEffect: string;
  33445. /**
  33446. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  33447. */
  33448. SSAOCombineRenderEffect: string;
  33449. /**
  33450. * The output strength of the SSAO post-process. Default value is 1.0.
  33451. */
  33452. totalStrength: number;
  33453. /**
  33454. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  33455. */
  33456. radius: number;
  33457. /**
  33458. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  33459. * Must not be equal to fallOff and superior to fallOff.
  33460. * Default value is 0.975
  33461. */
  33462. area: number;
  33463. /**
  33464. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  33465. * Must not be equal to area and inferior to area.
  33466. * Default value is 0.0
  33467. */
  33468. fallOff: number;
  33469. /**
  33470. * The base color of the SSAO post-process
  33471. * The final result is "base + ssao" between [0, 1]
  33472. */
  33473. base: number;
  33474. private _scene;
  33475. private _depthTexture;
  33476. private _randomTexture;
  33477. private _originalColorPostProcess;
  33478. private _ssaoPostProcess;
  33479. private _blurHPostProcess;
  33480. private _blurVPostProcess;
  33481. private _ssaoCombinePostProcess;
  33482. private _firstUpdate;
  33483. /**
  33484. * @constructor
  33485. * @param {string} name - The rendering pipeline name
  33486. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  33487. * @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 }
  33488. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  33489. */
  33490. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  33491. /**
  33492. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  33493. */
  33494. dispose(disableDepthRender?: boolean): void;
  33495. private _createBlurPostProcess(ratio);
  33496. _rebuild(): void;
  33497. private _createSSAOPostProcess(ratio);
  33498. private _createSSAOCombinePostProcess(ratio);
  33499. private _createRandomTexture();
  33500. }
  33501. }
  33502. declare module BABYLON {
  33503. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  33504. /**
  33505. * Public members
  33506. */
  33507. originalPostProcess: Nullable<PostProcess>;
  33508. downSampleX4PostProcess: Nullable<PostProcess>;
  33509. brightPassPostProcess: Nullable<PostProcess>;
  33510. blurHPostProcesses: PostProcess[];
  33511. blurVPostProcesses: PostProcess[];
  33512. textureAdderPostProcess: Nullable<PostProcess>;
  33513. volumetricLightPostProcess: Nullable<PostProcess>;
  33514. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  33515. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  33516. volumetricLightMergePostProces: Nullable<PostProcess>;
  33517. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  33518. luminancePostProcess: Nullable<PostProcess>;
  33519. luminanceDownSamplePostProcesses: PostProcess[];
  33520. hdrPostProcess: Nullable<PostProcess>;
  33521. textureAdderFinalPostProcess: Nullable<PostProcess>;
  33522. lensFlareFinalPostProcess: Nullable<PostProcess>;
  33523. hdrFinalPostProcess: Nullable<PostProcess>;
  33524. lensFlarePostProcess: Nullable<PostProcess>;
  33525. lensFlareComposePostProcess: Nullable<PostProcess>;
  33526. motionBlurPostProcess: Nullable<PostProcess>;
  33527. depthOfFieldPostProcess: Nullable<PostProcess>;
  33528. brightThreshold: number;
  33529. blurWidth: number;
  33530. horizontalBlur: boolean;
  33531. exposure: number;
  33532. lensTexture: Nullable<Texture>;
  33533. volumetricLightCoefficient: number;
  33534. volumetricLightPower: number;
  33535. volumetricLightBlurScale: number;
  33536. sourceLight: Nullable<SpotLight | DirectionalLight>;
  33537. hdrMinimumLuminance: number;
  33538. hdrDecreaseRate: number;
  33539. hdrIncreaseRate: number;
  33540. lensColorTexture: Nullable<Texture>;
  33541. lensFlareStrength: number;
  33542. lensFlareGhostDispersal: number;
  33543. lensFlareHaloWidth: number;
  33544. lensFlareDistortionStrength: number;
  33545. lensStarTexture: Nullable<Texture>;
  33546. lensFlareDirtTexture: Nullable<Texture>;
  33547. depthOfFieldDistance: number;
  33548. depthOfFieldBlurWidth: number;
  33549. motionStrength: number;
  33550. animations: Animation[];
  33551. /**
  33552. * Private members
  33553. */
  33554. private _scene;
  33555. private _currentDepthOfFieldSource;
  33556. private _basePostProcess;
  33557. private _hdrCurrentLuminance;
  33558. private _floatTextureType;
  33559. private _ratio;
  33560. private _bloomEnabled;
  33561. private _depthOfFieldEnabled;
  33562. private _vlsEnabled;
  33563. private _lensFlareEnabled;
  33564. private _hdrEnabled;
  33565. private _motionBlurEnabled;
  33566. private _motionBlurSamples;
  33567. private _volumetricLightStepsCount;
  33568. BloomEnabled: boolean;
  33569. DepthOfFieldEnabled: boolean;
  33570. LensFlareEnabled: boolean;
  33571. HDREnabled: boolean;
  33572. VLSEnabled: boolean;
  33573. MotionBlurEnabled: boolean;
  33574. volumetricLightStepsCount: number;
  33575. motionBlurSamples: number;
  33576. /**
  33577. * @constructor
  33578. * @param {string} name - The rendering pipeline name
  33579. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  33580. * @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)
  33581. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  33582. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  33583. */
  33584. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  33585. private _buildPipeline();
  33586. private _createDownSampleX4PostProcess(scene, ratio);
  33587. private _createBrightPassPostProcess(scene, ratio);
  33588. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  33589. private _createTextureAdderPostProcess(scene, ratio);
  33590. private _createVolumetricLightPostProcess(scene, ratio);
  33591. private _createLuminancePostProcesses(scene, textureType);
  33592. private _createHdrPostProcess(scene, ratio);
  33593. private _createLensFlarePostProcess(scene, ratio);
  33594. private _createDepthOfFieldPostProcess(scene, ratio);
  33595. private _createMotionBlurPostProcess(scene, ratio);
  33596. private _getDepthTexture();
  33597. private _disposePostProcesses();
  33598. dispose(): void;
  33599. serialize(): any;
  33600. /**
  33601. * Static members
  33602. */
  33603. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  33604. static LuminanceSteps: number;
  33605. }
  33606. }